documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192
  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. * @returns true if the loader can load the specified file
  1047. */
  1048. canLoad(extension: string): boolean;
  1049. /**
  1050. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1051. * @param data contains the texture data
  1052. * @param texture defines the BabylonJS internal texture
  1053. * @param createPolynomials will be true if polynomials have been requested
  1054. * @param onLoad defines the callback to trigger once the texture is ready
  1055. * @param onError defines the callback to trigger in case of error
  1056. */
  1057. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1058. /**
  1059. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1060. * @param data contains the texture data
  1061. * @param texture defines the BabylonJS internal texture
  1062. * @param callback defines the method to call once ready to upload
  1063. */
  1064. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1065. }
  1066. }
  1067. declare module BABYLON {
  1068. /**
  1069. * Class used to store and describe the pipeline context associated with an effect
  1070. */
  1071. export interface IPipelineContext {
  1072. /**
  1073. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1074. */
  1075. isAsync: boolean;
  1076. /**
  1077. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1078. */
  1079. isReady: boolean;
  1080. /** @hidden */
  1081. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1082. }
  1083. }
  1084. declare module BABYLON {
  1085. /**
  1086. * Class used to store gfx data (like WebGLBuffer)
  1087. */
  1088. export class DataBuffer {
  1089. /**
  1090. * Gets or sets the number of objects referencing this buffer
  1091. */
  1092. references: number;
  1093. /** Gets or sets the size of the underlying buffer */
  1094. capacity: number;
  1095. /**
  1096. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1097. */
  1098. is32Bits: boolean;
  1099. /**
  1100. * Gets the underlying buffer
  1101. */
  1102. get underlyingResource(): any;
  1103. }
  1104. }
  1105. declare module BABYLON {
  1106. /** @hidden */
  1107. export interface IShaderProcessor {
  1108. attributeProcessor?: (attribute: string) => string;
  1109. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1110. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1111. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1112. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1113. lineProcessor?: (line: string, isFragment: boolean) => string;
  1114. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1115. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1116. }
  1117. }
  1118. declare module BABYLON {
  1119. /** @hidden */
  1120. export interface ProcessingOptions {
  1121. defines: string[];
  1122. indexParameters: any;
  1123. isFragment: boolean;
  1124. shouldUseHighPrecisionShader: boolean;
  1125. supportsUniformBuffers: boolean;
  1126. shadersRepository: string;
  1127. includesShadersStore: {
  1128. [key: string]: string;
  1129. };
  1130. processor?: IShaderProcessor;
  1131. version: string;
  1132. platformName: string;
  1133. lookForClosingBracketForUniformBuffer?: boolean;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export class ShaderCodeNode {
  1139. line: string;
  1140. children: ShaderCodeNode[];
  1141. additionalDefineKey?: string;
  1142. additionalDefineValue?: string;
  1143. isValid(preprocessors: {
  1144. [key: string]: string;
  1145. }): boolean;
  1146. process(preprocessors: {
  1147. [key: string]: string;
  1148. }, options: ProcessingOptions): string;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /** @hidden */
  1153. export class ShaderCodeCursor {
  1154. private _lines;
  1155. lineIndex: number;
  1156. get currentLine(): string;
  1157. get canRead(): boolean;
  1158. set lines(value: string[]);
  1159. }
  1160. }
  1161. declare module BABYLON {
  1162. /** @hidden */
  1163. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderDefineExpression {
  1172. isTrue(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeTestNode extends ShaderCodeNode {
  1180. testExpression: ShaderDefineExpression;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. }
  1185. }
  1186. declare module BABYLON {
  1187. /** @hidden */
  1188. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1189. define: string;
  1190. not: boolean;
  1191. constructor(define: string, not?: boolean);
  1192. isTrue(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1200. leftOperand: ShaderDefineExpression;
  1201. rightOperand: ShaderDefineExpression;
  1202. isTrue(preprocessors: {
  1203. [key: string]: string;
  1204. }): boolean;
  1205. }
  1206. }
  1207. declare module BABYLON {
  1208. /** @hidden */
  1209. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1210. leftOperand: ShaderDefineExpression;
  1211. rightOperand: ShaderDefineExpression;
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. operand: string;
  1222. testValue: string;
  1223. constructor(define: string, operand: string, testValue: string);
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /**
  1231. * Class used to enable access to offline support
  1232. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1233. */
  1234. export interface IOfflineProvider {
  1235. /**
  1236. * Gets a boolean indicating if scene must be saved in the database
  1237. */
  1238. enableSceneOffline: boolean;
  1239. /**
  1240. * Gets a boolean indicating if textures must be saved in the database
  1241. */
  1242. enableTexturesOffline: boolean;
  1243. /**
  1244. * Open the offline support and make it available
  1245. * @param successCallback defines the callback to call on success
  1246. * @param errorCallback defines the callback to call on error
  1247. */
  1248. open(successCallback: () => void, errorCallback: () => void): void;
  1249. /**
  1250. * Loads an image from the offline support
  1251. * @param url defines the url to load from
  1252. * @param image defines the target DOM image
  1253. */
  1254. loadImage(url: string, image: HTMLImageElement): void;
  1255. /**
  1256. * Loads a file from offline support
  1257. * @param url defines the URL to load from
  1258. * @param sceneLoaded defines a callback to call on success
  1259. * @param progressCallBack defines a callback to call when progress changed
  1260. * @param errorCallback defines a callback to call on error
  1261. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1262. */
  1263. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1264. }
  1265. }
  1266. declare module BABYLON {
  1267. /**
  1268. * Class used to help managing file picking and drag'n'drop
  1269. * File Storage
  1270. */
  1271. export class FilesInputStore {
  1272. /**
  1273. * List of files ready to be loaded
  1274. */
  1275. static FilesToLoad: {
  1276. [key: string]: File;
  1277. };
  1278. }
  1279. }
  1280. declare module BABYLON {
  1281. /**
  1282. * Class used to define a retry strategy when error happens while loading assets
  1283. */
  1284. export class RetryStrategy {
  1285. /**
  1286. * Function used to defines an exponential back off strategy
  1287. * @param maxRetries defines the maximum number of retries (3 by default)
  1288. * @param baseInterval defines the interval between retries
  1289. * @returns the strategy function to use
  1290. */
  1291. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * @ignore
  1297. * Application error to support additional information when loading a file
  1298. */
  1299. export abstract class BaseError extends Error {
  1300. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /** @ignore */
  1305. export class LoadFileError extends BaseError {
  1306. request?: WebRequest;
  1307. file?: File;
  1308. /**
  1309. * Creates a new LoadFileError
  1310. * @param message defines the message of the error
  1311. * @param request defines the optional web request
  1312. * @param file defines the optional file
  1313. */
  1314. constructor(message: string, object?: WebRequest | File);
  1315. }
  1316. /** @ignore */
  1317. export class RequestFileError extends BaseError {
  1318. request: WebRequest;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. */
  1324. constructor(message: string, request: WebRequest);
  1325. }
  1326. /** @ignore */
  1327. export class ReadFileError extends BaseError {
  1328. file: File;
  1329. /**
  1330. * Creates a new ReadFileError
  1331. * @param message defines the message of the error
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, file: File);
  1335. }
  1336. /**
  1337. * @hidden
  1338. */
  1339. export class FileTools {
  1340. /**
  1341. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1342. */
  1343. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1344. /**
  1345. * Gets or sets the base URL to use to load assets
  1346. */
  1347. static BaseUrl: string;
  1348. /**
  1349. * Default behaviour for cors in the application.
  1350. * It can be a string if the expected behavior is identical in the entire app.
  1351. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1352. */
  1353. static CorsBehavior: string | ((url: string | string[]) => string);
  1354. /**
  1355. * Gets or sets a function used to pre-process url before using them to load assets
  1356. */
  1357. static PreprocessUrl: (url: string) => string;
  1358. /**
  1359. * Removes unwanted characters from an url
  1360. * @param url defines the url to clean
  1361. * @returns the cleaned url
  1362. */
  1363. private static _CleanUrl;
  1364. /**
  1365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1366. * @param url define the url we are trying
  1367. * @param element define the dom element where to configure the cors policy
  1368. */
  1369. static SetCorsBehavior(url: string | string[], element: {
  1370. crossOrigin: string | null;
  1371. }): void;
  1372. /**
  1373. * Loads an image as an HTMLImageElement.
  1374. * @param input url string, ArrayBuffer, or Blob to load
  1375. * @param onLoad callback called when the image successfully loads
  1376. * @param onError callback called when the image fails to load
  1377. * @param offlineProvider offline provider for caching
  1378. * @param mimeType optional mime type
  1379. * @returns the HTMLImageElement of the loaded image
  1380. */
  1381. 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>;
  1382. /**
  1383. * Reads a file from a File object
  1384. * @param file defines the file to load
  1385. * @param onSuccess defines the callback to call when data is loaded
  1386. * @param onProgress defines the callback to call during loading process
  1387. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1388. * @param onError defines the callback to call when an error occurs
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1392. /**
  1393. * Loads a file from a url
  1394. * @param url url to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Loads a file
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1409. * @param onError callback called when the file fails to load
  1410. * @param onOpened callback called when the web request is opened
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Checks if the loaded document was accessed via `file:`-Protocol.
  1416. * @returns boolean
  1417. */
  1418. static IsFileURL(): boolean;
  1419. }
  1420. }
  1421. declare module BABYLON {
  1422. /** @hidden */
  1423. export class ShaderProcessor {
  1424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1425. private static _ProcessPrecision;
  1426. private static _ExtractOperation;
  1427. private static _BuildSubExpression;
  1428. private static _BuildExpression;
  1429. private static _MoveCursorWithinIf;
  1430. private static _MoveCursor;
  1431. private static _EvaluatePreProcessors;
  1432. private static _PreparePreProcessors;
  1433. private static _ProcessShaderConversion;
  1434. private static _ProcessIncludes;
  1435. /**
  1436. * Loads a file from a url
  1437. * @param url url to load
  1438. * @param onSuccess callback called when the file successfully loads
  1439. * @param onProgress callback called while file is loading (if the server supports this mode)
  1440. * @param offlineProvider defines the offline provider for caching
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @returns a file request object
  1444. * @hidden
  1445. */
  1446. 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;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /**
  1451. * @hidden
  1452. */
  1453. export interface IColor4Like {
  1454. r: float;
  1455. g: float;
  1456. b: float;
  1457. a: float;
  1458. }
  1459. /**
  1460. * @hidden
  1461. */
  1462. export interface IColor3Like {
  1463. r: float;
  1464. g: float;
  1465. b: float;
  1466. }
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IVector4Like {
  1471. x: float;
  1472. y: float;
  1473. z: float;
  1474. w: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IVector3Like {
  1480. x: float;
  1481. y: float;
  1482. z: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector2Like {
  1488. x: float;
  1489. y: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IMatrixLike {
  1495. toArray(): DeepImmutable<Float32Array>;
  1496. updateFlag: int;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IViewportLike {
  1502. x: float;
  1503. y: float;
  1504. width: float;
  1505. height: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IPlaneLike {
  1511. normal: IVector3Like;
  1512. d: float;
  1513. normalize(): void;
  1514. }
  1515. }
  1516. declare module BABYLON {
  1517. /**
  1518. * Interface used to define common properties for effect fallbacks
  1519. */
  1520. export interface IEffectFallbacks {
  1521. /**
  1522. * Removes the defines that should be removed when falling back.
  1523. * @param currentDefines defines the current define statements for the shader.
  1524. * @param effect defines the current effect we try to compile
  1525. * @returns The resulting defines with defines of the current rank removed.
  1526. */
  1527. reduce(currentDefines: string, effect: Effect): string;
  1528. /**
  1529. * Removes the fallback from the bound mesh.
  1530. */
  1531. unBindMesh(): void;
  1532. /**
  1533. * Checks to see if more fallbacks are still availible.
  1534. */
  1535. hasMoreFallbacks: boolean;
  1536. }
  1537. }
  1538. declare module BABYLON {
  1539. /**
  1540. * Class used to evalaute queries containing `and` and `or` operators
  1541. */
  1542. export class AndOrNotEvaluator {
  1543. /**
  1544. * Evaluate a query
  1545. * @param query defines the query to evaluate
  1546. * @param evaluateCallback defines the callback used to filter result
  1547. * @returns true if the query matches
  1548. */
  1549. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1550. private static _HandleParenthesisContent;
  1551. private static _SimplifyNegation;
  1552. }
  1553. }
  1554. declare module BABYLON {
  1555. /**
  1556. * Class used to store custom tags
  1557. */
  1558. export class Tags {
  1559. /**
  1560. * Adds support for tags on the given object
  1561. * @param obj defines the object to use
  1562. */
  1563. static EnableFor(obj: any): void;
  1564. /**
  1565. * Removes tags support
  1566. * @param obj defines the object to use
  1567. */
  1568. static DisableFor(obj: any): void;
  1569. /**
  1570. * Gets a boolean indicating if the given object has tags
  1571. * @param obj defines the object to use
  1572. * @returns a boolean
  1573. */
  1574. static HasTags(obj: any): boolean;
  1575. /**
  1576. * Gets the tags available on a given object
  1577. * @param obj defines the object to use
  1578. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1579. * @returns the tags
  1580. */
  1581. static GetTags(obj: any, asString?: boolean): any;
  1582. /**
  1583. * Adds tags to an object
  1584. * @param obj defines the object to use
  1585. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1586. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1587. */
  1588. static AddTagsTo(obj: any, tagsString: string): void;
  1589. /**
  1590. * @hidden
  1591. */
  1592. static _AddTagTo(obj: any, tag: string): void;
  1593. /**
  1594. * Removes specific tags from a specific object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tags to remove
  1597. */
  1598. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _RemoveTagFrom(obj: any, tag: string): void;
  1603. /**
  1604. * Defines if tags hosted on an object match a given query
  1605. * @param obj defines the object to use
  1606. * @param tagsQuery defines the tag query
  1607. * @returns a boolean
  1608. */
  1609. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Scalar computation library
  1615. */
  1616. export class Scalar {
  1617. /**
  1618. * Two pi constants convenient for computation.
  1619. */
  1620. static TwoPi: number;
  1621. /**
  1622. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1623. * @param a number
  1624. * @param b number
  1625. * @param epsilon (default = 1.401298E-45)
  1626. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1627. */
  1628. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1629. /**
  1630. * Returns a string : the upper case translation of the number i to hexadecimal.
  1631. * @param i number
  1632. * @returns the upper case translation of the number i to hexadecimal.
  1633. */
  1634. static ToHex(i: number): string;
  1635. /**
  1636. * Returns -1 if value is negative and +1 is value is positive.
  1637. * @param value the value
  1638. * @returns the value itself if it's equal to zero.
  1639. */
  1640. static Sign(value: number): number;
  1641. /**
  1642. * Returns the value itself if it's between min and max.
  1643. * Returns min if the value is lower than min.
  1644. * Returns max if the value is greater than max.
  1645. * @param value the value to clmap
  1646. * @param min the min value to clamp to (default: 0)
  1647. * @param max the max value to clamp to (default: 1)
  1648. * @returns the clamped value
  1649. */
  1650. static Clamp(value: number, min?: number, max?: number): number;
  1651. /**
  1652. * the log2 of value.
  1653. * @param value the value to compute log2 of
  1654. * @returns the log2 of value.
  1655. */
  1656. static Log2(value: number): number;
  1657. /**
  1658. * Loops the value, so that it is never larger than length and never smaller than 0.
  1659. *
  1660. * This is similar to the modulo operator but it works with floating point numbers.
  1661. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1662. * With t = 5 and length = 2.5, the result would be 0.0.
  1663. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1664. * @param value the value
  1665. * @param length the length
  1666. * @returns the looped value
  1667. */
  1668. static Repeat(value: number, length: number): number;
  1669. /**
  1670. * Normalize the value between 0.0 and 1.0 using min and max values
  1671. * @param value value to normalize
  1672. * @param min max to normalize between
  1673. * @param max min to normalize between
  1674. * @returns the normalized value
  1675. */
  1676. static Normalize(value: number, min: number, max: number): number;
  1677. /**
  1678. * Denormalize the value from 0.0 and 1.0 using min and max values
  1679. * @param normalized value to denormalize
  1680. * @param min max to denormalize between
  1681. * @param max min to denormalize between
  1682. * @returns the denormalized value
  1683. */
  1684. static Denormalize(normalized: number, min: number, max: number): number;
  1685. /**
  1686. * Calculates the shortest difference between two given angles given in degrees.
  1687. * @param current current angle in degrees
  1688. * @param target target angle in degrees
  1689. * @returns the delta
  1690. */
  1691. static DeltaAngle(current: number, target: number): number;
  1692. /**
  1693. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1694. * @param tx value
  1695. * @param length length
  1696. * @returns The returned value will move back and forth between 0 and length
  1697. */
  1698. static PingPong(tx: number, length: number): number;
  1699. /**
  1700. * Interpolates between min and max with smoothing at the limits.
  1701. *
  1702. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1703. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1704. * @param from from
  1705. * @param to to
  1706. * @param tx value
  1707. * @returns the smooth stepped value
  1708. */
  1709. static SmoothStep(from: number, to: number, tx: number): number;
  1710. /**
  1711. * Moves a value current towards target.
  1712. *
  1713. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1714. * Negative values of maxDelta pushes the value away from target.
  1715. * @param current current value
  1716. * @param target target value
  1717. * @param maxDelta max distance to move
  1718. * @returns resulting value
  1719. */
  1720. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1721. /**
  1722. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1723. *
  1724. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1725. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting angle
  1730. */
  1731. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1734. * @param start start value
  1735. * @param end target value
  1736. * @param amount amount to lerp between
  1737. * @returns the lerped value
  1738. */
  1739. static Lerp(start: number, end: number, amount: number): number;
  1740. /**
  1741. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1742. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1743. * @param start start value
  1744. * @param end target value
  1745. * @param amount amount to lerp between
  1746. * @returns the lerped value
  1747. */
  1748. static LerpAngle(start: number, end: number, amount: number): number;
  1749. /**
  1750. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1751. * @param a start value
  1752. * @param b target value
  1753. * @param value value between a and b
  1754. * @returns the inverseLerp value
  1755. */
  1756. static InverseLerp(a: number, b: number, value: number): number;
  1757. /**
  1758. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1759. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1760. * @param value1 spline value
  1761. * @param tangent1 spline value
  1762. * @param value2 spline value
  1763. * @param tangent2 spline value
  1764. * @param amount input value
  1765. * @returns hermite result
  1766. */
  1767. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1768. /**
  1769. * Returns a random float number between and min and max values
  1770. * @param min min value of random
  1771. * @param max max value of random
  1772. * @returns random value
  1773. */
  1774. static RandomRange(min: number, max: number): number;
  1775. /**
  1776. * This function returns percentage of a number in a given range.
  1777. *
  1778. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1779. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1780. * @param number to convert to percentage
  1781. * @param min min range
  1782. * @param max max range
  1783. * @returns the percentage
  1784. */
  1785. static RangeToPercent(number: number, min: number, max: number): number;
  1786. /**
  1787. * This function returns number that corresponds to the percentage in a given range.
  1788. *
  1789. * PercentToRange(0.34,0,100) will return 34.
  1790. * @param percent to convert to number
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the number
  1794. */
  1795. static PercentToRange(percent: number, min: number, max: number): number;
  1796. /**
  1797. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1798. * @param angle The angle to normalize in radian.
  1799. * @return The converted angle.
  1800. */
  1801. static NormalizeRadians(angle: number): number;
  1802. }
  1803. }
  1804. declare module BABYLON {
  1805. /**
  1806. * Constant used to convert a value to gamma space
  1807. * @ignorenaming
  1808. */
  1809. export const ToGammaSpace: number;
  1810. /**
  1811. * Constant used to convert a value to linear space
  1812. * @ignorenaming
  1813. */
  1814. export const ToLinearSpace = 2.2;
  1815. /**
  1816. * Constant used to define the minimal number value in Babylon.js
  1817. * @ignorenaming
  1818. */
  1819. let Epsilon: number;
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Class used to represent a viewport on screen
  1824. */
  1825. export class Viewport {
  1826. /** viewport left coordinate */
  1827. x: number;
  1828. /** viewport top coordinate */
  1829. y: number;
  1830. /**viewport width */
  1831. width: number;
  1832. /** viewport height */
  1833. height: number;
  1834. /**
  1835. * Creates a Viewport object located at (x, y) and sized (width, height)
  1836. * @param x defines viewport left coordinate
  1837. * @param y defines viewport top coordinate
  1838. * @param width defines the viewport width
  1839. * @param height defines the viewport height
  1840. */
  1841. constructor(
  1842. /** viewport left coordinate */
  1843. x: number,
  1844. /** viewport top coordinate */
  1845. y: number,
  1846. /**viewport width */
  1847. width: number,
  1848. /** viewport height */
  1849. height: number);
  1850. /**
  1851. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1852. * @param renderWidth defines the rendering width
  1853. * @param renderHeight defines the rendering height
  1854. * @returns a new Viewport
  1855. */
  1856. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1857. /**
  1858. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1859. * @param renderWidth defines the rendering width
  1860. * @param renderHeight defines the rendering height
  1861. * @param ref defines the target viewport
  1862. * @returns the current viewport
  1863. */
  1864. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1865. /**
  1866. * Returns a new Viewport copied from the current one
  1867. * @returns a new Viewport
  1868. */
  1869. clone(): Viewport;
  1870. }
  1871. }
  1872. declare module BABYLON {
  1873. /**
  1874. * Class containing a set of static utilities functions for arrays.
  1875. */
  1876. export class ArrayTools {
  1877. /**
  1878. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1879. * @param size the number of element to construct and put in the array
  1880. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1881. * @returns a new array filled with new objects
  1882. */
  1883. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1884. }
  1885. }
  1886. declare module BABYLON {
  1887. /**
  1888. * Class representing a vector containing 2 coordinates
  1889. */
  1890. export class Vector2 {
  1891. /** defines the first coordinate */
  1892. x: number;
  1893. /** defines the second coordinate */
  1894. y: number;
  1895. /**
  1896. * Creates a new Vector2 from the given x and y coordinates
  1897. * @param x defines the first coordinate
  1898. * @param y defines the second coordinate
  1899. */
  1900. constructor(
  1901. /** defines the first coordinate */
  1902. x?: number,
  1903. /** defines the second coordinate */
  1904. y?: number);
  1905. /**
  1906. * Gets a string with the Vector2 coordinates
  1907. * @returns a string with the Vector2 coordinates
  1908. */
  1909. toString(): string;
  1910. /**
  1911. * Gets class name
  1912. * @returns the string "Vector2"
  1913. */
  1914. getClassName(): string;
  1915. /**
  1916. * Gets current vector hash code
  1917. * @returns the Vector2 hash code as a number
  1918. */
  1919. getHashCode(): number;
  1920. /**
  1921. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1922. * @param array defines the source array
  1923. * @param index defines the offset in source array
  1924. * @returns the current Vector2
  1925. */
  1926. toArray(array: FloatArray, index?: number): Vector2;
  1927. /**
  1928. * Copy the current vector to an array
  1929. * @returns a new array with 2 elements: the Vector2 coordinates.
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1934. * @param source defines the source Vector2
  1935. * @returns the current updated Vector2
  1936. */
  1937. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1938. /**
  1939. * Sets the Vector2 coordinates with the given floats
  1940. * @param x defines the first coordinate
  1941. * @param y defines the second coordinate
  1942. * @returns the current updated Vector2
  1943. */
  1944. copyFromFloats(x: number, y: number): Vector2;
  1945. /**
  1946. * Sets the Vector2 coordinates with the given floats
  1947. * @param x defines the first coordinate
  1948. * @param y defines the second coordinate
  1949. * @returns the current updated Vector2
  1950. */
  1951. set(x: number, y: number): Vector2;
  1952. /**
  1953. * Add another vector with the current one
  1954. * @param otherVector defines the other vector
  1955. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1956. */
  1957. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1960. * @param otherVector defines the other vector
  1961. * @param result defines the target vector
  1962. * @returns the unmodified current Vector2
  1963. */
  1964. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1965. /**
  1966. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1967. * @param otherVector defines the other vector
  1968. * @returns the current updated Vector2
  1969. */
  1970. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1973. * @param otherVector defines the other vector
  1974. * @returns a new Vector2
  1975. */
  1976. addVector3(otherVector: Vector3): Vector2;
  1977. /**
  1978. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1979. * @param otherVector defines the other vector
  1980. * @returns a new Vector2
  1981. */
  1982. subtract(otherVector: Vector2): Vector2;
  1983. /**
  1984. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1985. * @param otherVector defines the other vector
  1986. * @param result defines the target vector
  1987. * @returns the unmodified current Vector2
  1988. */
  1989. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1990. /**
  1991. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1992. * @param otherVector defines the other vector
  1993. * @returns the current updated Vector2
  1994. */
  1995. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1996. /**
  1997. * Multiplies in place the current Vector2 coordinates by the given ones
  1998. * @param otherVector defines the other vector
  1999. * @returns the current updated Vector2
  2000. */
  2001. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @returns a new Vector2
  2006. */
  2007. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2008. /**
  2009. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @param result defines the target vector
  2012. * @returns the unmodified current Vector2
  2013. */
  2014. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2015. /**
  2016. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2017. * @param x defines the first coordinate
  2018. * @param y defines the second coordinate
  2019. * @returns a new Vector2
  2020. */
  2021. multiplyByFloats(x: number, y: number): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. divide(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Divides the current Vector2 coordinates by the given ones
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Gets a new Vector2 with current Vector2 negated coordinates
  2043. * @returns a new Vector2
  2044. */
  2045. negate(): Vector2;
  2046. /**
  2047. * Negate this vector in place
  2048. * @returns this
  2049. */
  2050. negateInPlace(): Vector2;
  2051. /**
  2052. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2053. * @param result defines the Vector3 object where to store the result
  2054. * @returns the current Vector2
  2055. */
  2056. negateToRef(result: Vector2): Vector2;
  2057. /**
  2058. * Multiply the Vector2 coordinates by scale
  2059. * @param scale defines the scaling factor
  2060. * @returns the current updated Vector2
  2061. */
  2062. scaleInPlace(scale: number): Vector2;
  2063. /**
  2064. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2065. * @param scale defines the scaling factor
  2066. * @returns a new Vector2
  2067. */
  2068. scale(scale: number): Vector2;
  2069. /**
  2070. * Scale the current Vector2 values by a factor to a given Vector2
  2071. * @param scale defines the scale factor
  2072. * @param result defines the Vector2 object where to store the result
  2073. * @returns the unmodified current Vector2
  2074. */
  2075. scaleToRef(scale: number, result: Vector2): Vector2;
  2076. /**
  2077. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2078. * @param scale defines the scale factor
  2079. * @param result defines the Vector2 object where to store the result
  2080. * @returns the unmodified current Vector2
  2081. */
  2082. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2083. /**
  2084. * Gets a boolean if two vectors are equals
  2085. * @param otherVector defines the other vector
  2086. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2087. */
  2088. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2089. /**
  2090. * Gets a boolean if two vectors are equals (using an epsilon value)
  2091. * @param otherVector defines the other vector
  2092. * @param epsilon defines the minimal distance to consider equality
  2093. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2094. */
  2095. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2096. /**
  2097. * Gets a new Vector2 from current Vector2 floored values
  2098. * @returns a new Vector2
  2099. */
  2100. floor(): Vector2;
  2101. /**
  2102. * Gets a new Vector2 from current Vector2 floored values
  2103. * @returns a new Vector2
  2104. */
  2105. fract(): Vector2;
  2106. /**
  2107. * Gets the length of the vector
  2108. * @returns the vector length (float)
  2109. */
  2110. length(): number;
  2111. /**
  2112. * Gets the vector squared length
  2113. * @returns the vector squared length (float)
  2114. */
  2115. lengthSquared(): number;
  2116. /**
  2117. * Normalize the vector
  2118. * @returns the current updated Vector2
  2119. */
  2120. normalize(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 copied from the Vector2
  2123. * @returns a new Vector2
  2124. */
  2125. clone(): Vector2;
  2126. /**
  2127. * Gets a new Vector2(0, 0)
  2128. * @returns a new Vector2
  2129. */
  2130. static Zero(): Vector2;
  2131. /**
  2132. * Gets a new Vector2(1, 1)
  2133. * @returns a new Vector2
  2134. */
  2135. static One(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 set from the given index element of the given array
  2138. * @param array defines the data source
  2139. * @param offset defines the offset in the data source
  2140. * @returns a new Vector2
  2141. */
  2142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2143. /**
  2144. * Sets "result" from the given index element of the given array
  2145. * @param array defines the data source
  2146. * @param offset defines the offset in the data source
  2147. * @param result defines the target vector
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2150. /**
  2151. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2152. * @param value1 defines 1st point of control
  2153. * @param value2 defines 2nd point of control
  2154. * @param value3 defines 3rd point of control
  2155. * @param value4 defines 4th point of control
  2156. * @param amount defines the interpolation factor
  2157. * @returns a new Vector2
  2158. */
  2159. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2160. /**
  2161. * 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".
  2162. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2163. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2164. * @param value defines the value to clamp
  2165. * @param min defines the lower limit
  2166. * @param max defines the upper limit
  2167. * @returns a new Vector2
  2168. */
  2169. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2170. /**
  2171. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2172. * @param value1 defines the 1st control point
  2173. * @param tangent1 defines the outgoing tangent
  2174. * @param value2 defines the 2nd control point
  2175. * @param tangent2 defines the incoming tangent
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2182. * @param start defines the start vector
  2183. * @param end defines the end vector
  2184. * @param amount defines the interpolation factor
  2185. * @returns a new Vector2
  2186. */
  2187. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2188. /**
  2189. * Gets the dot product of the vector "left" and the vector "right"
  2190. * @param left defines first vector
  2191. * @param right defines second vector
  2192. * @returns the dot product (float)
  2193. */
  2194. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2195. /**
  2196. * Returns a new Vector2 equal to the normalized given vector
  2197. * @param vector defines the vector to normalize
  2198. * @returns a new Vector2
  2199. */
  2200. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2203. * @param left defines 1st vector
  2204. * @param right defines 2nd vector
  2205. * @returns a new Vector2
  2206. */
  2207. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2210. * @param left defines 1st vector
  2211. * @param right defines 2nd vector
  2212. * @returns a new Vector2
  2213. */
  2214. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2217. * @param vector defines the vector to transform
  2218. * @param transformation defines the matrix to apply
  2219. * @returns a new Vector2
  2220. */
  2221. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2222. /**
  2223. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2224. * @param vector defines the vector to transform
  2225. * @param transformation defines the matrix to apply
  2226. * @param result defines the target vector
  2227. */
  2228. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2229. /**
  2230. * Determines if a given vector is included in a triangle
  2231. * @param p defines the vector to test
  2232. * @param p0 defines 1st triangle point
  2233. * @param p1 defines 2nd triangle point
  2234. * @param p2 defines 3rd triangle point
  2235. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2236. */
  2237. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2238. /**
  2239. * Gets the distance between the vectors "value1" and "value2"
  2240. * @param value1 defines first vector
  2241. * @param value2 defines second vector
  2242. * @returns the distance between vectors
  2243. */
  2244. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2245. /**
  2246. * Returns the squared distance between the vectors "value1" and "value2"
  2247. * @param value1 defines first vector
  2248. * @param value2 defines second vector
  2249. * @returns the squared distance between vectors
  2250. */
  2251. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2252. /**
  2253. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2254. * @param value1 defines first vector
  2255. * @param value2 defines second vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2261. * @param p defines the middle point
  2262. * @param segA defines one point of the segment
  2263. * @param segB defines the other point of the segment
  2264. * @returns the shortest distance
  2265. */
  2266. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2267. }
  2268. /**
  2269. * Class used to store (x,y,z) vector representation
  2270. * A Vector3 is the main object used in 3D geometry
  2271. * It can represent etiher the coordinates of a point the space, either a direction
  2272. * Reminder: js uses a left handed forward facing system
  2273. */
  2274. export class Vector3 {
  2275. /**
  2276. * Defines the first coordinates (on X axis)
  2277. */
  2278. x: number;
  2279. /**
  2280. * Defines the second coordinates (on Y axis)
  2281. */
  2282. y: number;
  2283. /**
  2284. * Defines the third coordinates (on Z axis)
  2285. */
  2286. z: number;
  2287. private static _UpReadOnly;
  2288. private static _ZeroReadOnly;
  2289. /**
  2290. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2291. * @param x defines the first coordinates (on X axis)
  2292. * @param y defines the second coordinates (on Y axis)
  2293. * @param z defines the third coordinates (on Z axis)
  2294. */
  2295. constructor(
  2296. /**
  2297. * Defines the first coordinates (on X axis)
  2298. */
  2299. x?: number,
  2300. /**
  2301. * Defines the second coordinates (on Y axis)
  2302. */
  2303. y?: number,
  2304. /**
  2305. * Defines the third coordinates (on Z axis)
  2306. */
  2307. z?: number);
  2308. /**
  2309. * Creates a string representation of the Vector3
  2310. * @returns a string with the Vector3 coordinates.
  2311. */
  2312. toString(): string;
  2313. /**
  2314. * Gets the class name
  2315. * @returns the string "Vector3"
  2316. */
  2317. getClassName(): string;
  2318. /**
  2319. * Creates the Vector3 hash code
  2320. * @returns a number which tends to be unique between Vector3 instances
  2321. */
  2322. getHashCode(): number;
  2323. /**
  2324. * Creates an array containing three elements : the coordinates of the Vector3
  2325. * @returns a new array of numbers
  2326. */
  2327. asArray(): number[];
  2328. /**
  2329. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2330. * @param array defines the destination array
  2331. * @param index defines the offset in the destination array
  2332. * @returns the current Vector3
  2333. */
  2334. toArray(array: FloatArray, index?: number): Vector3;
  2335. /**
  2336. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2337. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2338. */
  2339. toQuaternion(): Quaternion;
  2340. /**
  2341. * Adds the given vector to the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Adds the given coordinates to the current Vector3
  2348. * @param x defines the x coordinate of the operand
  2349. * @param y defines the y coordinate of the operand
  2350. * @param z defines the z coordinate of the operand
  2351. * @returns the current updated Vector3
  2352. */
  2353. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2354. /**
  2355. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2356. * @param otherVector defines the second operand
  2357. * @returns the resulting Vector3
  2358. */
  2359. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2360. /**
  2361. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2362. * @param otherVector defines the second operand
  2363. * @param result defines the Vector3 object where to store the result
  2364. * @returns the current Vector3
  2365. */
  2366. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2367. /**
  2368. * Subtract the given vector from the current Vector3
  2369. * @param otherVector defines the second operand
  2370. * @returns the current updated Vector3
  2371. */
  2372. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the resulting Vector3
  2377. */
  2378. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2381. * @param otherVector defines the second operand
  2382. * @param result defines the Vector3 object where to store the result
  2383. * @returns the current Vector3
  2384. */
  2385. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2386. /**
  2387. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2388. * @param x defines the x coordinate of the operand
  2389. * @param y defines the y coordinate of the operand
  2390. * @param z defines the z coordinate of the operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2394. /**
  2395. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2396. * @param x defines the x coordinate of the operand
  2397. * @param y defines the y coordinate of the operand
  2398. * @param z defines the z coordinate of the operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2403. /**
  2404. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2405. * @returns a new Vector3
  2406. */
  2407. negate(): Vector3;
  2408. /**
  2409. * Negate this vector in place
  2410. * @returns this
  2411. */
  2412. negateInPlace(): Vector3;
  2413. /**
  2414. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. negateToRef(result: Vector3): Vector3;
  2419. /**
  2420. * Multiplies the Vector3 coordinates by the float "scale"
  2421. * @param scale defines the multiplier factor
  2422. * @returns the current updated Vector3
  2423. */
  2424. scaleInPlace(scale: number): Vector3;
  2425. /**
  2426. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2427. * @param scale defines the multiplier factor
  2428. * @returns a new Vector3
  2429. */
  2430. scale(scale: number): Vector3;
  2431. /**
  2432. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2433. * @param scale defines the multiplier factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. scaleToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2440. * @param scale defines the scale factor
  2441. * @param result defines the Vector3 object where to store the result
  2442. * @returns the unmodified current Vector3
  2443. */
  2444. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2445. /**
  2446. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2447. * @param otherVector defines the second operand
  2448. * @returns true if both vectors are equals
  2449. */
  2450. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2453. * @param otherVector defines the second operand
  2454. * @param epsilon defines the minimal distance to define values as equals
  2455. * @returns true if both vectors are distant less than epsilon
  2456. */
  2457. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2458. /**
  2459. * Returns true if the current Vector3 coordinates equals the given floats
  2460. * @param x defines the x coordinate of the operand
  2461. * @param y defines the y coordinate of the operand
  2462. * @param z defines the z coordinate of the operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equalsToFloats(x: number, y: number, z: number): boolean;
  2466. /**
  2467. * Multiplies the current Vector3 coordinates by the given ones
  2468. * @param otherVector defines the second operand
  2469. * @returns the current updated Vector3
  2470. */
  2471. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2472. /**
  2473. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2474. * @param otherVector defines the second operand
  2475. * @returns the new Vector3
  2476. */
  2477. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2478. /**
  2479. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2480. * @param otherVector defines the second operand
  2481. * @param result defines the Vector3 object where to store the result
  2482. * @returns the current Vector3
  2483. */
  2484. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2485. /**
  2486. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2487. * @param x defines the x coordinate of the operand
  2488. * @param y defines the y coordinate of the operand
  2489. * @param z defines the z coordinate of the operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2493. /**
  2494. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2495. * @param otherVector defines the second operand
  2496. * @returns the new Vector3
  2497. */
  2498. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2501. * @param otherVector defines the second operand
  2502. * @param result defines the Vector3 object where to store the result
  2503. * @returns the current Vector3
  2504. */
  2505. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2506. /**
  2507. * Divides the current Vector3 coordinates by the given ones.
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. divideInPlace(otherVector: Vector3): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2514. * @param other defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2520. * @param other defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2526. * @param x defines the x coordinate of the operand
  2527. * @param y defines the y coordinate of the operand
  2528. * @param z defines the z coordinate of the operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2534. * @param x defines the x coordinate of the operand
  2535. * @param y defines the y coordinate of the operand
  2536. * @param z defines the z coordinate of the operand
  2537. * @returns the current updated Vector3
  2538. */
  2539. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2540. /**
  2541. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2542. * Check if is non uniform within a certain amount of decimal places to account for this
  2543. * @param epsilon the amount the values can differ
  2544. * @returns if the the vector is non uniform to a certain number of decimal places
  2545. */
  2546. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2547. /**
  2548. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2549. */
  2550. get isNonUniform(): boolean;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. floor(): Vector3;
  2556. /**
  2557. * Gets a new Vector3 from current Vector3 floored values
  2558. * @returns a new Vector3
  2559. */
  2560. fract(): Vector3;
  2561. /**
  2562. * Gets the length of the Vector3
  2563. * @returns the length of the Vector3
  2564. */
  2565. length(): number;
  2566. /**
  2567. * Gets the squared length of the Vector3
  2568. * @returns squared length of the Vector3
  2569. */
  2570. lengthSquared(): number;
  2571. /**
  2572. * Normalize the current Vector3.
  2573. * Please note that this is an in place operation.
  2574. * @returns the current updated Vector3
  2575. */
  2576. normalize(): Vector3;
  2577. /**
  2578. * Reorders the x y z properties of the vector in place
  2579. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2580. * @returns the current updated vector
  2581. */
  2582. reorderInPlace(order: string): this;
  2583. /**
  2584. * Rotates the vector around 0,0,0 by a quaternion
  2585. * @param quaternion the rotation quaternion
  2586. * @param result vector to store the result
  2587. * @returns the resulting vector
  2588. */
  2589. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2590. /**
  2591. * Rotates a vector around a given point
  2592. * @param quaternion the rotation quaternion
  2593. * @param point the point to rotate around
  2594. * @param result vector to store the result
  2595. * @returns the resulting vector
  2596. */
  2597. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2598. /**
  2599. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2600. * The cross product is then orthogonal to both current and "other"
  2601. * @param other defines the right operand
  2602. * @returns the cross product
  2603. */
  2604. cross(other: Vector3): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 with the given input length.
  2607. * Please note that this is an in place operation.
  2608. * @param len the length of the vector
  2609. * @returns the current updated Vector3
  2610. */
  2611. normalizeFromLength(len: number): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to a new vector
  2614. * @returns the new Vector3
  2615. */
  2616. normalizeToNew(): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 to the reference
  2619. * @param reference define the Vector3 to update
  2620. * @returns the updated Vector3
  2621. */
  2622. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Creates a new Vector3 copied from the current Vector3
  2625. * @returns the new Vector3
  2626. */
  2627. clone(): Vector3;
  2628. /**
  2629. * Copies the given vector coordinates to the current Vector3 ones
  2630. * @param source defines the source Vector3
  2631. * @returns the current updated Vector3
  2632. */
  2633. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Copies the given floats to the current Vector3 coordinates
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @returns the current updated Vector3
  2640. */
  2641. copyFromFloats(x: number, y: number, z: number): Vector3;
  2642. /**
  2643. * Copies the given floats to the current Vector3 coordinates
  2644. * @param x defines the x coordinate of the operand
  2645. * @param y defines the y coordinate of the operand
  2646. * @param z defines the z coordinate of the operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. set(x: number, y: number, z: number): Vector3;
  2650. /**
  2651. * Copies the given float to the current Vector3 coordinates
  2652. * @param v defines the x, y and z coordinates of the operand
  2653. * @returns the current updated Vector3
  2654. */
  2655. setAll(v: number): Vector3;
  2656. /**
  2657. * Get the clip factor between two vectors
  2658. * @param vector0 defines the first operand
  2659. * @param vector1 defines the second operand
  2660. * @param axis defines the axis to use
  2661. * @param size defines the size along the axis
  2662. * @returns the clip factor
  2663. */
  2664. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2665. /**
  2666. * Get angle between two vectors
  2667. * @param vector0 angle between vector0 and vector1
  2668. * @param vector1 angle between vector0 and vector1
  2669. * @param normal direction of the normal
  2670. * @return the angle between vector0 and vector1
  2671. */
  2672. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. */
  2679. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2682. * @param array defines the source array
  2683. * @param offset defines the offset in the source array
  2684. * @returns the new Vector3
  2685. * @deprecated Please use FromArray instead.
  2686. */
  2687. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. */
  2694. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2695. /**
  2696. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @param result defines the Vector3 where to store the result
  2700. * @deprecated Please use FromArrayToRef instead.
  2701. */
  2702. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2703. /**
  2704. * Sets the given vector "result" with the given floats.
  2705. * @param x defines the x coordinate of the source
  2706. * @param y defines the y coordinate of the source
  2707. * @param z defines the z coordinate of the source
  2708. * @param result defines the Vector3 where to store the result
  2709. */
  2710. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2711. /**
  2712. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2713. * @returns a new empty Vector3
  2714. */
  2715. static Zero(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2718. * @returns a new unit Vector3
  2719. */
  2720. static One(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2723. * @returns a new up Vector3
  2724. */
  2725. static Up(): Vector3;
  2726. /**
  2727. * Gets a up Vector3 that must not be updated
  2728. */
  2729. static get UpReadOnly(): DeepImmutable<Vector3>;
  2730. /**
  2731. * Gets a zero Vector3 that must not be updated
  2732. */
  2733. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2736. * @returns a new down Vector3
  2737. */
  2738. static Down(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Forward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2746. * @returns a new forward Vector3
  2747. */
  2748. static Backward(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2751. * @returns a new right Vector3
  2752. */
  2753. static Right(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2756. * @returns a new left Vector3
  2757. */
  2758. static Left(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2761. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2762. * @param vector defines the Vector3 to transform
  2763. * @param transformation defines the transformation matrix
  2764. * @returns the transformed Vector3
  2765. */
  2766. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2767. /**
  2768. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2769. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2770. * @param vector defines the Vector3 to transform
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2777. * This method computes tranformed coordinates only, not transformed direction vectors
  2778. * @param x define the x coordinate of the source vector
  2779. * @param y define the y coordinate of the source vector
  2780. * @param z define the z coordinate of the source vector
  2781. * @param transformation defines the transformation matrix
  2782. * @param result defines the Vector3 where to store the result
  2783. */
  2784. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2785. /**
  2786. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2787. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @returns the new Vector3
  2791. */
  2792. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2793. /**
  2794. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2795. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2796. * @param vector defines the Vector3 to transform
  2797. * @param transformation defines the transformation matrix
  2798. * @param result defines the Vector3 where to store the result
  2799. */
  2800. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2801. /**
  2802. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2803. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2804. * @param x define the x coordinate of the source vector
  2805. * @param y define the y coordinate of the source vector
  2806. * @param z define the z coordinate of the source vector
  2807. * @param transformation defines the transformation matrix
  2808. * @param result defines the Vector3 where to store the result
  2809. */
  2810. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2811. /**
  2812. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2813. * @param value1 defines the first control point
  2814. * @param value2 defines the second control point
  2815. * @param value3 defines the third control point
  2816. * @param value4 defines the fourth control point
  2817. * @param amount defines the amount on the spline to use
  2818. * @returns the new Vector3
  2819. */
  2820. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2821. /**
  2822. * 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"
  2823. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2824. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2825. * @param value defines the current value
  2826. * @param min defines the lower range value
  2827. * @param max defines the upper range value
  2828. * @returns the new Vector3
  2829. */
  2830. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2831. /**
  2832. * 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"
  2833. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2834. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2835. * @param value defines the current value
  2836. * @param min defines the lower range value
  2837. * @param max defines the upper range value
  2838. * @param result defines the Vector3 where to store the result
  2839. */
  2840. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2841. /**
  2842. * Checks if a given vector is inside a specific range
  2843. * @param v defines the vector to test
  2844. * @param min defines the minimum range
  2845. * @param max defines the maximum range
  2846. */
  2847. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2850. * @param value1 defines the first control point
  2851. * @param tangent1 defines the first tangent vector
  2852. * @param value2 defines the second control point
  2853. * @param tangent2 defines the second tangent vector
  2854. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2855. * @returns the new Vector3
  2856. */
  2857. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2860. * @param start defines the start value
  2861. * @param end defines the end value
  2862. * @param amount max defines amount between both (between 0 and 1)
  2863. * @returns the new Vector3
  2864. */
  2865. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2868. * @param start defines the start value
  2869. * @param end defines the end value
  2870. * @param amount max defines amount between both (between 0 and 1)
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2874. /**
  2875. * Returns the dot product (float) between the vectors "left" and "right"
  2876. * @param left defines the left operand
  2877. * @param right defines the right operand
  2878. * @returns the dot product
  2879. */
  2880. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2881. /**
  2882. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2883. * The cross product is then orthogonal to both "left" and "right"
  2884. * @param left defines the left operand
  2885. * @param right defines the right operand
  2886. * @returns the cross product
  2887. */
  2888. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the cross product of "left" and "right"
  2891. * The cross product is then orthogonal to both "left" and "right"
  2892. * @param left defines the left operand
  2893. * @param right defines the right operand
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 as the normalization of the given vector
  2899. * @param vector defines the Vector3 to normalize
  2900. * @returns the new Vector3
  2901. */
  2902. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2903. /**
  2904. * Sets the given vector "result" with the normalization of the given first vector
  2905. * @param vector defines the Vector3 to normalize
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2909. /**
  2910. * Project a Vector3 onto screen space
  2911. * @param vector defines the Vector3 to project
  2912. * @param world defines the world matrix to use
  2913. * @param transform defines the transform (view x projection) matrix to use
  2914. * @param viewport defines the screen viewport to use
  2915. * @returns the new Vector3
  2916. */
  2917. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2918. /** @hidden */
  2919. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param transform defines the transform (view x projection) matrix to use
  2927. * @returns the new Vector3
  2928. */
  2929. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2930. /**
  2931. * Unproject from screen space to object space
  2932. * @param source defines the screen space Vector3 to use
  2933. * @param viewportWidth defines the current width of the viewport
  2934. * @param viewportHeight defines the current height of the viewport
  2935. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2936. * @param view defines the view matrix to use
  2937. * @param projection defines the projection matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param sourceX defines the screen space x coordinate to use
  2955. * @param sourceY defines the screen space y coordinate to use
  2956. * @param sourceZ defines the screen space z coordinate to use
  2957. * @param viewportWidth defines the current width of the viewport
  2958. * @param viewportHeight defines the current height of the viewport
  2959. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2960. * @param view defines the view matrix to use
  2961. * @param projection defines the projection matrix to use
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Gets the minimal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Gets the maximal coordinate values between two Vector3
  2974. * @param left defines the first operand
  2975. * @param right defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Returns the distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the distance
  2984. */
  2985. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns the squared distance between the vectors "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the squared distance
  2991. */
  2992. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2993. /**
  2994. * Returns a new Vector3 located at the center between "value1" and "value2"
  2995. * @param value1 defines the first operand
  2996. * @param value2 defines the second operand
  2997. * @returns the new Vector3
  2998. */
  2999. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3000. /**
  3001. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3002. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3003. * to something in order to rotate it from its local system to the given target system
  3004. * Note: axis1, axis2 and axis3 are normalized during this operation
  3005. * @param axis1 defines the first axis
  3006. * @param axis2 defines the second axis
  3007. * @param axis3 defines the third axis
  3008. * @returns a new Vector3
  3009. */
  3010. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3013. * @param axis1 defines the first axis
  3014. * @param axis2 defines the second axis
  3015. * @param axis3 defines the third axis
  3016. * @param ref defines the Vector3 where to store the result
  3017. */
  3018. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3019. }
  3020. /**
  3021. * Vector4 class created for EulerAngle class conversion to Quaternion
  3022. */
  3023. export class Vector4 {
  3024. /** x value of the vector */
  3025. x: number;
  3026. /** y value of the vector */
  3027. y: number;
  3028. /** z value of the vector */
  3029. z: number;
  3030. /** w value of the vector */
  3031. w: number;
  3032. /**
  3033. * Creates a Vector4 object from the given floats.
  3034. * @param x x value of the vector
  3035. * @param y y value of the vector
  3036. * @param z z value of the vector
  3037. * @param w w value of the vector
  3038. */
  3039. constructor(
  3040. /** x value of the vector */
  3041. x: number,
  3042. /** y value of the vector */
  3043. y: number,
  3044. /** z value of the vector */
  3045. z: number,
  3046. /** w value of the vector */
  3047. w: number);
  3048. /**
  3049. * Returns the string with the Vector4 coordinates.
  3050. * @returns a string containing all the vector values
  3051. */
  3052. toString(): string;
  3053. /**
  3054. * Returns the string "Vector4".
  3055. * @returns "Vector4"
  3056. */
  3057. getClassName(): string;
  3058. /**
  3059. * Returns the Vector4 hash code.
  3060. * @returns a unique hash code
  3061. */
  3062. getHashCode(): number;
  3063. /**
  3064. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3065. * @returns the resulting array
  3066. */
  3067. asArray(): number[];
  3068. /**
  3069. * Populates the given array from the given index with the Vector4 coordinates.
  3070. * @param array array to populate
  3071. * @param index index of the array to start at (default: 0)
  3072. * @returns the Vector4.
  3073. */
  3074. toArray(array: FloatArray, index?: number): Vector4;
  3075. /**
  3076. * Adds the given vector to the current Vector4.
  3077. * @param otherVector the vector to add
  3078. * @returns the updated Vector4.
  3079. */
  3080. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3081. /**
  3082. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3083. * @param otherVector the vector to add
  3084. * @returns the resulting vector
  3085. */
  3086. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3087. /**
  3088. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3089. * @param otherVector the vector to add
  3090. * @param result the vector to store the result
  3091. * @returns the current Vector4.
  3092. */
  3093. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3094. /**
  3095. * Subtract in place the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @returns the updated Vector4.
  3098. */
  3099. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3100. /**
  3101. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the new vector with the result
  3104. */
  3105. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @param result the vector to store the result
  3110. * @returns the current Vector4.
  3111. */
  3112. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3113. /**
  3114. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. */
  3116. /**
  3117. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3118. * @param x value to subtract
  3119. * @param y value to subtract
  3120. * @param z value to subtract
  3121. * @param w value to subtract
  3122. * @returns new vector containing the result
  3123. */
  3124. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3125. /**
  3126. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. * @param x value to subtract
  3128. * @param y value to subtract
  3129. * @param z value to subtract
  3130. * @param w value to subtract
  3131. * @param result the vector to store the result in
  3132. * @returns the current Vector4.
  3133. */
  3134. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3135. /**
  3136. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3137. * @returns a new vector with the negated values
  3138. */
  3139. negate(): Vector4;
  3140. /**
  3141. * Negate this vector in place
  3142. * @returns this
  3143. */
  3144. negateInPlace(): Vector4;
  3145. /**
  3146. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3147. * @param result defines the Vector3 object where to store the result
  3148. * @returns the current Vector4
  3149. */
  3150. negateToRef(result: Vector4): Vector4;
  3151. /**
  3152. * Multiplies the current Vector4 coordinates by scale (float).
  3153. * @param scale the number to scale with
  3154. * @returns the updated Vector4.
  3155. */
  3156. scaleInPlace(scale: number): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3159. * @param scale the number to scale with
  3160. * @returns a new vector with the result
  3161. */
  3162. scale(scale: number): Vector4;
  3163. /**
  3164. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3165. * @param scale the number to scale with
  3166. * @param result a vector to store the result in
  3167. * @returns the current Vector4.
  3168. */
  3169. scaleToRef(scale: number, result: Vector4): Vector4;
  3170. /**
  3171. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3172. * @param scale defines the scale factor
  3173. * @param result defines the Vector4 object where to store the result
  3174. * @returns the unmodified current Vector4
  3175. */
  3176. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3179. * @param otherVector the vector to compare against
  3180. * @returns true if they are equal
  3181. */
  3182. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3183. /**
  3184. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3185. * @param otherVector vector to compare against
  3186. * @param epsilon (Default: very small number)
  3187. * @returns true if they are equal
  3188. */
  3189. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3190. /**
  3191. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3192. * @param x x value to compare against
  3193. * @param y y value to compare against
  3194. * @param z z value to compare against
  3195. * @param w w value to compare against
  3196. * @returns true if equal
  3197. */
  3198. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3199. /**
  3200. * Multiplies in place the current Vector4 by the given one.
  3201. * @param otherVector vector to multiple with
  3202. * @returns the updated Vector4.
  3203. */
  3204. multiplyInPlace(otherVector: Vector4): Vector4;
  3205. /**
  3206. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3207. * @param otherVector vector to multiple with
  3208. * @returns resulting new vector
  3209. */
  3210. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @param result vector to store the result
  3215. * @returns the current Vector4.
  3216. */
  3217. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3218. /**
  3219. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3220. * @param x x value multiply with
  3221. * @param y y value multiply with
  3222. * @param z z value multiply with
  3223. * @param w w value multiply with
  3224. * @returns resulting new vector
  3225. */
  3226. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3227. /**
  3228. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3229. * @param otherVector vector to devide with
  3230. * @returns resulting new vector
  3231. */
  3232. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3235. * @param otherVector vector to devide with
  3236. * @param result vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Divides the current Vector3 coordinates by the given ones.
  3242. * @param otherVector vector to devide with
  3243. * @returns the updated Vector3.
  3244. */
  3245. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3248. * @param other defines the second operand
  3249. * @returns the current updated Vector4
  3250. */
  3251. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3254. * @param other defines the second operand
  3255. * @returns the current updated Vector4
  3256. */
  3257. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Gets a new Vector4 from current Vector4 floored values
  3260. * @returns a new Vector4
  3261. */
  3262. floor(): Vector4;
  3263. /**
  3264. * Gets a new Vector4 from current Vector3 floored values
  3265. * @returns a new Vector4
  3266. */
  3267. fract(): Vector4;
  3268. /**
  3269. * Returns the Vector4 length (float).
  3270. * @returns the length
  3271. */
  3272. length(): number;
  3273. /**
  3274. * Returns the Vector4 squared length (float).
  3275. * @returns the length squared
  3276. */
  3277. lengthSquared(): number;
  3278. /**
  3279. * Normalizes in place the Vector4.
  3280. * @returns the updated Vector4.
  3281. */
  3282. normalize(): Vector4;
  3283. /**
  3284. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3285. * @returns this converted to a new vector3
  3286. */
  3287. toVector3(): Vector3;
  3288. /**
  3289. * Returns a new Vector4 copied from the current one.
  3290. * @returns the new cloned vector
  3291. */
  3292. clone(): Vector4;
  3293. /**
  3294. * Updates the current Vector4 with the given one coordinates.
  3295. * @param source the source vector to copy from
  3296. * @returns the updated Vector4.
  3297. */
  3298. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3299. /**
  3300. * Updates the current Vector4 coordinates with the given floats.
  3301. * @param x float to copy from
  3302. * @param y float to copy from
  3303. * @param z float to copy from
  3304. * @param w float to copy from
  3305. * @returns the updated Vector4.
  3306. */
  3307. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3308. /**
  3309. * Updates the current Vector4 coordinates with the given floats.
  3310. * @param x float to set from
  3311. * @param y float to set from
  3312. * @param z float to set from
  3313. * @param w float to set from
  3314. * @returns the updated Vector4.
  3315. */
  3316. set(x: number, y: number, z: number, w: number): Vector4;
  3317. /**
  3318. * Copies the given float to the current Vector3 coordinates
  3319. * @param v defines the x, y, z and w coordinates of the operand
  3320. * @returns the current updated Vector3
  3321. */
  3322. setAll(v: number): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set from the starting index of the given array.
  3325. * @param array the array to pull values from
  3326. * @param offset the offset into the array to start at
  3327. * @returns the new vector
  3328. */
  3329. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3330. /**
  3331. * Updates the given vector "result" from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @param result the vector to store the result in
  3335. */
  3336. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given Float32Array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" coordinates from the given floats.
  3346. * @param x float to set from
  3347. * @param y float to set from
  3348. * @param z float to set from
  3349. * @param w float to set from
  3350. * @param result the vector to the floats in
  3351. */
  3352. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3353. /**
  3354. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3355. * @returns the new vector
  3356. */
  3357. static Zero(): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3360. * @returns the new vector
  3361. */
  3362. static One(): Vector4;
  3363. /**
  3364. * Returns a new normalized Vector4 from the given one.
  3365. * @param vector the vector to normalize
  3366. * @returns the vector
  3367. */
  3368. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Updates the given vector "result" from the normalization of the given one.
  3371. * @param vector the vector to normalize
  3372. * @param result the vector to store the result in
  3373. */
  3374. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3375. /**
  3376. * Returns a vector with the minimum values from the left and right vectors
  3377. * @param left left vector to minimize
  3378. * @param right right vector to minimize
  3379. * @returns a new vector with the minimum of the left and right vector values
  3380. */
  3381. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3382. /**
  3383. * Returns a vector with the maximum values from the left and right vectors
  3384. * @param left left vector to maximize
  3385. * @param right right vector to maximize
  3386. * @returns a new vector with the maximum of the left and right vector values
  3387. */
  3388. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns the distance (float) between the vectors "value1" and "value2".
  3391. * @param value1 value to calulate the distance between
  3392. * @param value2 value to calulate the distance between
  3393. * @return the distance between the two vectors
  3394. */
  3395. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3396. /**
  3397. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors squared
  3401. */
  3402. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the center between
  3406. * @param value2 value to calulate the center between
  3407. * @return the center between the two vectors
  3408. */
  3409. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param vector the vector to transform
  3414. * @param transformation the transformation matrix to apply
  3415. * @returns the new vector
  3416. */
  3417. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3418. /**
  3419. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3420. * This methods computes transformed normalized direction vectors only.
  3421. * @param vector the vector to transform
  3422. * @param transformation the transformation matrix to apply
  3423. * @param result the vector to store the result in
  3424. */
  3425. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3426. /**
  3427. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3428. * This methods computes transformed normalized direction vectors only.
  3429. * @param x value to transform
  3430. * @param y value to transform
  3431. * @param z value to transform
  3432. * @param w value to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the results in
  3435. */
  3436. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Creates a new Vector4 from a Vector3
  3439. * @param source defines the source data
  3440. * @param w defines the 4th component (default is 0)
  3441. * @returns a new Vector4
  3442. */
  3443. static FromVector3(source: Vector3, w?: number): Vector4;
  3444. }
  3445. /**
  3446. * Class used to store quaternion data
  3447. * @see https://en.wikipedia.org/wiki/Quaternion
  3448. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3449. */
  3450. export class Quaternion {
  3451. /** defines the first component (0 by default) */
  3452. x: number;
  3453. /** defines the second component (0 by default) */
  3454. y: number;
  3455. /** defines the third component (0 by default) */
  3456. z: number;
  3457. /** defines the fourth component (1.0 by default) */
  3458. w: number;
  3459. /**
  3460. * Creates a new Quaternion from the given floats
  3461. * @param x defines the first component (0 by default)
  3462. * @param y defines the second component (0 by default)
  3463. * @param z defines the third component (0 by default)
  3464. * @param w defines the fourth component (1.0 by default)
  3465. */
  3466. constructor(
  3467. /** defines the first component (0 by default) */
  3468. x?: number,
  3469. /** defines the second component (0 by default) */
  3470. y?: number,
  3471. /** defines the third component (0 by default) */
  3472. z?: number,
  3473. /** defines the fourth component (1.0 by default) */
  3474. w?: number);
  3475. /**
  3476. * Gets a string representation for the current quaternion
  3477. * @returns a string with the Quaternion coordinates
  3478. */
  3479. toString(): string;
  3480. /**
  3481. * Gets the class name of the quaternion
  3482. * @returns the string "Quaternion"
  3483. */
  3484. getClassName(): string;
  3485. /**
  3486. * Gets a hash code for this quaternion
  3487. * @returns the quaternion hash code
  3488. */
  3489. getHashCode(): number;
  3490. /**
  3491. * Copy the quaternion to an array
  3492. * @returns a new array populated with 4 elements from the quaternion coordinates
  3493. */
  3494. asArray(): number[];
  3495. /**
  3496. * Check if two quaternions are equals
  3497. * @param otherQuaternion defines the second operand
  3498. * @return true if the current quaternion and the given one coordinates are strictly equals
  3499. */
  3500. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3501. /**
  3502. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3503. * @param otherQuaternion defines the other quaternion
  3504. * @param epsilon defines the minimal distance to consider equality
  3505. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3506. */
  3507. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. get m(): DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, 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 right 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 LookAtRH(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 right 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 LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module BABYLON {
  4617. /**
  4618. * Defines potential orientation for back face culling
  4619. */
  4620. export enum Orientation {
  4621. /**
  4622. * Clockwise
  4623. */
  4624. CW = 0,
  4625. /** Counter clockwise */
  4626. CCW = 1
  4627. }
  4628. /** Class used to represent a Bezier curve */
  4629. export class BezierCurve {
  4630. /**
  4631. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4632. * @param t defines the time
  4633. * @param x1 defines the left coordinate on X axis
  4634. * @param y1 defines the left coordinate on Y axis
  4635. * @param x2 defines the right coordinate on X axis
  4636. * @param y2 defines the right coordinate on Y axis
  4637. * @returns the interpolated value
  4638. */
  4639. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4640. }
  4641. /**
  4642. * Defines angle representation
  4643. */
  4644. export class Angle {
  4645. private _radians;
  4646. /**
  4647. * Creates an Angle object of "radians" radians (float).
  4648. * @param radians the angle in radians
  4649. */
  4650. constructor(radians: number);
  4651. /**
  4652. * Get value in degrees
  4653. * @returns the Angle value in degrees (float)
  4654. */
  4655. degrees(): number;
  4656. /**
  4657. * Get value in radians
  4658. * @returns the Angle value in radians (float)
  4659. */
  4660. radians(): number;
  4661. /**
  4662. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4663. * @param a defines first vector
  4664. * @param b defines second vector
  4665. * @returns a new Angle
  4666. */
  4667. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4668. /**
  4669. * Gets a new Angle object from the given float in radians
  4670. * @param radians defines the angle value in radians
  4671. * @returns a new Angle
  4672. */
  4673. static FromRadians(radians: number): Angle;
  4674. /**
  4675. * Gets a new Angle object from the given float in degrees
  4676. * @param degrees defines the angle value in degrees
  4677. * @returns a new Angle
  4678. */
  4679. static FromDegrees(degrees: number): Angle;
  4680. }
  4681. /**
  4682. * This represents an arc in a 2d space.
  4683. */
  4684. export class Arc2 {
  4685. /** Defines the start point of the arc */
  4686. startPoint: Vector2;
  4687. /** Defines the mid point of the arc */
  4688. midPoint: Vector2;
  4689. /** Defines the end point of the arc */
  4690. endPoint: Vector2;
  4691. /**
  4692. * Defines the center point of the arc.
  4693. */
  4694. centerPoint: Vector2;
  4695. /**
  4696. * Defines the radius of the arc.
  4697. */
  4698. radius: number;
  4699. /**
  4700. * Defines the angle of the arc (from mid point to end point).
  4701. */
  4702. angle: Angle;
  4703. /**
  4704. * Defines the start angle of the arc (from start point to middle point).
  4705. */
  4706. startAngle: Angle;
  4707. /**
  4708. * Defines the orientation of the arc (clock wise/counter clock wise).
  4709. */
  4710. orientation: Orientation;
  4711. /**
  4712. * Creates an Arc object from the three given points : start, middle and end.
  4713. * @param startPoint Defines the start point of the arc
  4714. * @param midPoint Defines the midlle point of the arc
  4715. * @param endPoint Defines the end point of the arc
  4716. */
  4717. constructor(
  4718. /** Defines the start point of the arc */
  4719. startPoint: Vector2,
  4720. /** Defines the mid point of the arc */
  4721. midPoint: Vector2,
  4722. /** Defines the end point of the arc */
  4723. endPoint: Vector2);
  4724. }
  4725. /**
  4726. * Represents a 2D path made up of multiple 2D points
  4727. */
  4728. export class Path2 {
  4729. private _points;
  4730. private _length;
  4731. /**
  4732. * If the path start and end point are the same
  4733. */
  4734. closed: boolean;
  4735. /**
  4736. * Creates a Path2 object from the starting 2D coordinates x and y.
  4737. * @param x the starting points x value
  4738. * @param y the starting points y value
  4739. */
  4740. constructor(x: number, y: number);
  4741. /**
  4742. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4743. * @param x the added points x value
  4744. * @param y the added points y value
  4745. * @returns the updated Path2.
  4746. */
  4747. addLineTo(x: number, y: number): Path2;
  4748. /**
  4749. * 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.
  4750. * @param midX middle point x value
  4751. * @param midY middle point y value
  4752. * @param endX end point x value
  4753. * @param endY end point y value
  4754. * @param numberOfSegments (default: 36)
  4755. * @returns the updated Path2.
  4756. */
  4757. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4758. /**
  4759. * Closes the Path2.
  4760. * @returns the Path2.
  4761. */
  4762. close(): Path2;
  4763. /**
  4764. * Gets the sum of the distance between each sequential point in the path
  4765. * @returns the Path2 total length (float).
  4766. */
  4767. length(): number;
  4768. /**
  4769. * Gets the points which construct the path
  4770. * @returns the Path2 internal array of points.
  4771. */
  4772. getPoints(): Vector2[];
  4773. /**
  4774. * Retreives the point at the distance aways from the starting point
  4775. * @param normalizedLengthPosition the length along the path to retreive the point from
  4776. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4777. */
  4778. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4779. /**
  4780. * Creates a new path starting from an x and y position
  4781. * @param x starting x value
  4782. * @param y starting y value
  4783. * @returns a new Path2 starting at the coordinates (x, y).
  4784. */
  4785. static StartingAt(x: number, y: number): Path2;
  4786. }
  4787. /**
  4788. * Represents a 3D path made up of multiple 3D points
  4789. */
  4790. export class Path3D {
  4791. /**
  4792. * an array of Vector3, the curve axis of the Path3D
  4793. */
  4794. path: Vector3[];
  4795. private _curve;
  4796. private _distances;
  4797. private _tangents;
  4798. private _normals;
  4799. private _binormals;
  4800. private _raw;
  4801. private _alignTangentsWithPath;
  4802. private readonly _pointAtData;
  4803. /**
  4804. * new Path3D(path, normal, raw)
  4805. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4806. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4807. * @param path an array of Vector3, the curve axis of the Path3D
  4808. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4809. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4810. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4811. */
  4812. constructor(
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4817. /**
  4818. * Returns the Path3D array of successive Vector3 designing its curve.
  4819. * @returns the Path3D array of successive Vector3 designing its curve.
  4820. */
  4821. getCurve(): Vector3[];
  4822. /**
  4823. * Returns the Path3D array of successive Vector3 designing its curve.
  4824. * @returns the Path3D array of successive Vector3 designing its curve.
  4825. */
  4826. getPoints(): Vector3[];
  4827. /**
  4828. * @returns the computed length (float) of the path.
  4829. */
  4830. length(): number;
  4831. /**
  4832. * Returns an array populated with tangent vectors on each Path3D curve point.
  4833. * @returns an array populated with tangent vectors on each Path3D curve point.
  4834. */
  4835. getTangents(): Vector3[];
  4836. /**
  4837. * Returns an array populated with normal vectors on each Path3D curve point.
  4838. * @returns an array populated with normal vectors on each Path3D curve point.
  4839. */
  4840. getNormals(): Vector3[];
  4841. /**
  4842. * Returns an array populated with binormal vectors on each Path3D curve point.
  4843. * @returns an array populated with binormal vectors on each Path3D curve point.
  4844. */
  4845. getBinormals(): Vector3[];
  4846. /**
  4847. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4848. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. */
  4850. getDistances(): number[];
  4851. /**
  4852. * Returns an interpolated point along this path
  4853. * @param position the position of the point along this path, from 0.0 to 1.0
  4854. * @returns a new Vector3 as the point
  4855. */
  4856. getPointAt(position: number): Vector3;
  4857. /**
  4858. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4859. * @param position the position of the point along this path, from 0.0 to 1.0
  4860. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4861. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4862. */
  4863. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4868. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4869. */
  4870. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4875. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4876. */
  4877. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4882. */
  4883. getDistanceAt(position: number): number;
  4884. /**
  4885. * Returns the array index of the previous point of an interpolated point along this path
  4886. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4887. * @returns the array index
  4888. */
  4889. getPreviousPointIndexAt(position: number): number;
  4890. /**
  4891. * 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)
  4892. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4893. * @returns the sub position
  4894. */
  4895. getSubPositionAt(position: number): number;
  4896. /**
  4897. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4898. * @param target the vector of which to get the closest position to
  4899. * @returns the position of the closest virtual point on this path to the target vector
  4900. */
  4901. getClosestPositionTo(target: Vector3): number;
  4902. /**
  4903. * Returns a sub path (slice) of this path
  4904. * @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
  4905. * @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
  4906. * @returns a sub path (slice) of this path
  4907. */
  4908. slice(start?: number, end?: number): Path3D;
  4909. /**
  4910. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4911. * @param path path which all values are copied into the curves points
  4912. * @param firstNormal which should be projected onto the curve
  4913. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4914. * @returns the same object updated.
  4915. */
  4916. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4917. private _compute;
  4918. private _getFirstNonNullVector;
  4919. private _getLastNonNullVector;
  4920. private _normalVector;
  4921. /**
  4922. * Updates the point at data for an interpolated point along this curve
  4923. * @param position the position of the point along this curve, from 0.0 to 1.0
  4924. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4925. * @returns the (updated) point at data
  4926. */
  4927. private _updatePointAtData;
  4928. /**
  4929. * Updates the point at data from the specified parameters
  4930. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4931. * @param point the interpolated point
  4932. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4933. */
  4934. private _setPointAtData;
  4935. /**
  4936. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4937. */
  4938. private _updateInterpolationMatrix;
  4939. }
  4940. /**
  4941. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4942. * A Curve3 is designed from a series of successive Vector3.
  4943. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4944. */
  4945. export class Curve3 {
  4946. private _points;
  4947. private _length;
  4948. /**
  4949. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4950. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4951. * @param v1 (Vector3) the control point
  4952. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4953. * @param nbPoints (integer) the wanted number of points in the curve
  4954. * @returns the created Curve3
  4955. */
  4956. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4957. /**
  4958. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4960. * @param v1 (Vector3) the first control point
  4961. * @param v2 (Vector3) the second control point
  4962. * @param v3 (Vector3) the end point of the Cubic Bezier
  4963. * @param nbPoints (integer) the wanted number of points in the curve
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4967. /**
  4968. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4969. * @param p1 (Vector3) the origin point of the Hermite Spline
  4970. * @param t1 (Vector3) the tangent vector at the origin point
  4971. * @param p2 (Vector3) the end point of the Hermite Spline
  4972. * @param t2 (Vector3) the tangent vector at the end point
  4973. * @param nbPoints (integer) the wanted number of points in the curve
  4974. * @returns the created Curve3
  4975. */
  4976. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4977. /**
  4978. * Returns a Curve3 object along a CatmullRom Spline curve :
  4979. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4980. * @param nbPoints (integer) the wanted number of points between each curve control points
  4981. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4985. /**
  4986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4987. * A Curve3 is designed from a series of successive Vector3.
  4988. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4989. * @param points points which make up the curve
  4990. */
  4991. constructor(points: Vector3[]);
  4992. /**
  4993. * @returns the Curve3 stored array of successive Vector3
  4994. */
  4995. getPoints(): Vector3[];
  4996. /**
  4997. * @returns the computed length (float) of the curve.
  4998. */
  4999. length(): number;
  5000. /**
  5001. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5002. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5003. * curveA and curveB keep unchanged.
  5004. * @param curve the curve to continue from this curve
  5005. * @returns the newly constructed curve
  5006. */
  5007. continue(curve: DeepImmutable<Curve3>): Curve3;
  5008. private _computeLength;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /**
  5013. * This represents the main contract an easing function should follow.
  5014. * Easing functions are used throughout the animation system.
  5015. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5016. */
  5017. export interface IEasingFunction {
  5018. /**
  5019. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5020. * of the easing function.
  5021. * The link below provides some of the most common examples of easing functions.
  5022. * @see https://easings.net/
  5023. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5024. * @returns the corresponding value on the curve defined by the easing function
  5025. */
  5026. ease(gradient: number): number;
  5027. }
  5028. /**
  5029. * Base class used for every default easing function.
  5030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5031. */
  5032. export class EasingFunction implements IEasingFunction {
  5033. /**
  5034. * Interpolation follows the mathematical formula associated with the easing function.
  5035. */
  5036. static readonly EASINGMODE_EASEIN: number;
  5037. /**
  5038. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5039. */
  5040. static readonly EASINGMODE_EASEOUT: number;
  5041. /**
  5042. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5043. */
  5044. static readonly EASINGMODE_EASEINOUT: number;
  5045. private _easingMode;
  5046. /**
  5047. * Sets the easing mode of the current function.
  5048. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5049. */
  5050. setEasingMode(easingMode: number): void;
  5051. /**
  5052. * Gets the current easing mode.
  5053. * @returns the easing mode
  5054. */
  5055. getEasingMode(): number;
  5056. /**
  5057. * @hidden
  5058. */
  5059. easeInCore(gradient: number): number;
  5060. /**
  5061. * Given an input gradient between 0 and 1, this returns the corresponding value
  5062. * of the easing function.
  5063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5064. * @returns the corresponding value on the curve defined by the easing function
  5065. */
  5066. ease(gradient: number): number;
  5067. }
  5068. /**
  5069. * Easing function with a circle shape (see link below).
  5070. * @see https://easings.net/#easeInCirc
  5071. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5072. */
  5073. export class CircleEase extends EasingFunction implements IEasingFunction {
  5074. /** @hidden */
  5075. easeInCore(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a ease back shape (see link below).
  5079. * @see https://easings.net/#easeInBack
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class BackEase extends EasingFunction implements IEasingFunction {
  5083. /** Defines the amplitude of the function */
  5084. amplitude: number;
  5085. /**
  5086. * Instantiates a back ease easing
  5087. * @see https://easings.net/#easeInBack
  5088. * @param amplitude Defines the amplitude of the function
  5089. */
  5090. constructor(
  5091. /** Defines the amplitude of the function */
  5092. amplitude?: number);
  5093. /** @hidden */
  5094. easeInCore(gradient: number): number;
  5095. }
  5096. /**
  5097. * Easing function with a bouncing shape (see link below).
  5098. * @see https://easings.net/#easeInBounce
  5099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5100. */
  5101. export class BounceEase extends EasingFunction implements IEasingFunction {
  5102. /** Defines the number of bounces */
  5103. bounces: number;
  5104. /** Defines the amplitude of the bounce */
  5105. bounciness: number;
  5106. /**
  5107. * Instantiates a bounce easing
  5108. * @see https://easings.net/#easeInBounce
  5109. * @param bounces Defines the number of bounces
  5110. * @param bounciness Defines the amplitude of the bounce
  5111. */
  5112. constructor(
  5113. /** Defines the number of bounces */
  5114. bounces?: number,
  5115. /** Defines the amplitude of the bounce */
  5116. bounciness?: number);
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a power of 3 shape (see link below).
  5122. * @see https://easings.net/#easeInCubic
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class CubicEase extends EasingFunction implements IEasingFunction {
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with an elastic shape (see link below).
  5131. * @see https://easings.net/#easeInElastic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5135. /** Defines the number of oscillations*/
  5136. oscillations: number;
  5137. /** Defines the amplitude of the oscillations*/
  5138. springiness: number;
  5139. /**
  5140. * Instantiates an elastic easing function
  5141. * @see https://easings.net/#easeInElastic
  5142. * @param oscillations Defines the number of oscillations
  5143. * @param springiness Defines the amplitude of the oscillations
  5144. */
  5145. constructor(
  5146. /** Defines the number of oscillations*/
  5147. oscillations?: number,
  5148. /** Defines the amplitude of the oscillations*/
  5149. springiness?: number);
  5150. /** @hidden */
  5151. easeInCore(gradient: number): number;
  5152. }
  5153. /**
  5154. * Easing function with an exponential shape (see link below).
  5155. * @see https://easings.net/#easeInExpo
  5156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5157. */
  5158. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5159. /** Defines the exponent of the function */
  5160. exponent: number;
  5161. /**
  5162. * Instantiates an exponential easing function
  5163. * @see https://easings.net/#easeInExpo
  5164. * @param exponent Defines the exponent of the function
  5165. */
  5166. constructor(
  5167. /** Defines the exponent of the function */
  5168. exponent?: number);
  5169. /** @hidden */
  5170. easeInCore(gradient: number): number;
  5171. }
  5172. /**
  5173. * Easing function with a power shape (see link below).
  5174. * @see https://easings.net/#easeInQuad
  5175. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5176. */
  5177. export class PowerEase extends EasingFunction implements IEasingFunction {
  5178. /** Defines the power of the function */
  5179. power: number;
  5180. /**
  5181. * Instantiates an power base easing function
  5182. * @see https://easings.net/#easeInQuad
  5183. * @param power Defines the power of the function
  5184. */
  5185. constructor(
  5186. /** Defines the power of the function */
  5187. power?: number);
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 2 shape (see link below).
  5193. * @see https://easings.net/#easeInQuad
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 4 shape (see link below).
  5202. * @see https://easings.net/#easeInQuart
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 5 shape (see link below).
  5211. * @see https://easings.net/#easeInQuint
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a sin shape (see link below).
  5220. * @see https://easings.net/#easeInSine
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class SineEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a bezier shape (see link below).
  5229. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5233. /** Defines the x component of the start tangent in the bezier curve */
  5234. x1: number;
  5235. /** Defines the y component of the start tangent in the bezier curve */
  5236. y1: number;
  5237. /** Defines the x component of the end tangent in the bezier curve */
  5238. x2: number;
  5239. /** Defines the y component of the end tangent in the bezier curve */
  5240. y2: number;
  5241. /**
  5242. * Instantiates a bezier function
  5243. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5244. * @param x1 Defines the x component of the start tangent in the bezier curve
  5245. * @param y1 Defines the y component of the start tangent in the bezier curve
  5246. * @param x2 Defines the x component of the end tangent in the bezier curve
  5247. * @param y2 Defines the y component of the end tangent in the bezier curve
  5248. */
  5249. constructor(
  5250. /** Defines the x component of the start tangent in the bezier curve */
  5251. x1?: number,
  5252. /** Defines the y component of the start tangent in the bezier curve */
  5253. y1?: number,
  5254. /** Defines the x component of the end tangent in the bezier curve */
  5255. x2?: number,
  5256. /** Defines the y component of the end tangent in the bezier curve */
  5257. y2?: number);
  5258. /** @hidden */
  5259. easeInCore(gradient: number): number;
  5260. }
  5261. }
  5262. declare module BABYLON {
  5263. /**
  5264. * Class used to hold a RBG color
  5265. */
  5266. export class Color3 {
  5267. /**
  5268. * Defines the red component (between 0 and 1, default is 0)
  5269. */
  5270. r: number;
  5271. /**
  5272. * Defines the green component (between 0 and 1, default is 0)
  5273. */
  5274. g: number;
  5275. /**
  5276. * Defines the blue component (between 0 and 1, default is 0)
  5277. */
  5278. b: number;
  5279. /**
  5280. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5281. * @param r defines the red component (between 0 and 1, default is 0)
  5282. * @param g defines the green component (between 0 and 1, default is 0)
  5283. * @param b defines the blue component (between 0 and 1, default is 0)
  5284. */
  5285. constructor(
  5286. /**
  5287. * Defines the red component (between 0 and 1, default is 0)
  5288. */
  5289. r?: number,
  5290. /**
  5291. * Defines the green component (between 0 and 1, default is 0)
  5292. */
  5293. g?: number,
  5294. /**
  5295. * Defines the blue component (between 0 and 1, default is 0)
  5296. */
  5297. b?: number);
  5298. /**
  5299. * Creates a string with the Color3 current values
  5300. * @returns the string representation of the Color3 object
  5301. */
  5302. toString(): string;
  5303. /**
  5304. * Returns the string "Color3"
  5305. * @returns "Color3"
  5306. */
  5307. getClassName(): string;
  5308. /**
  5309. * Compute the Color3 hash code
  5310. * @returns an unique number that can be used to hash Color3 objects
  5311. */
  5312. getHashCode(): number;
  5313. /**
  5314. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5315. * @param array defines the array where to store the r,g,b components
  5316. * @param index defines an optional index in the target array to define where to start storing values
  5317. * @returns the current Color3 object
  5318. */
  5319. toArray(array: FloatArray, index?: number): Color3;
  5320. /**
  5321. * Returns a new Color4 object from the current Color3 and the given alpha
  5322. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5323. * @returns a new Color4 object
  5324. */
  5325. toColor4(alpha?: number): Color4;
  5326. /**
  5327. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5328. * @returns the new array
  5329. */
  5330. asArray(): number[];
  5331. /**
  5332. * Returns the luminance value
  5333. * @returns a float value
  5334. */
  5335. toLuminance(): number;
  5336. /**
  5337. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5338. * @param otherColor defines the second operand
  5339. * @returns the new Color3 object
  5340. */
  5341. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5342. /**
  5343. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5344. * @param otherColor defines the second operand
  5345. * @param result defines the Color3 object where to store the result
  5346. * @returns the current Color3
  5347. */
  5348. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5349. /**
  5350. * Determines equality between Color3 objects
  5351. * @param otherColor defines the second operand
  5352. * @returns true if the rgb values are equal to the given ones
  5353. */
  5354. equals(otherColor: DeepImmutable<Color3>): boolean;
  5355. /**
  5356. * Determines equality between the current Color3 object and a set of r,b,g values
  5357. * @param r defines the red component to check
  5358. * @param g defines the green component to check
  5359. * @param b defines the blue component to check
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equalsFloats(r: number, g: number, b: number): boolean;
  5363. /**
  5364. * Multiplies in place each rgb value by scale
  5365. * @param scale defines the scaling factor
  5366. * @returns the updated Color3
  5367. */
  5368. scale(scale: number): Color3;
  5369. /**
  5370. * Multiplies the rgb values by scale and stores the result into "result"
  5371. * @param scale defines the scaling factor
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the unmodified current Color3
  5374. */
  5375. scaleToRef(scale: number, result: Color3): Color3;
  5376. /**
  5377. * Scale the current Color3 values by a factor and add the result to a given Color3
  5378. * @param scale defines the scale factor
  5379. * @param result defines color to store the result into
  5380. * @returns the unmodified current Color3
  5381. */
  5382. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5383. /**
  5384. * Clamps the rgb values by the min and max values and stores the result into "result"
  5385. * @param min defines minimum clamping value (default is 0)
  5386. * @param max defines maximum clamping value (default is 1)
  5387. * @param result defines color to store the result into
  5388. * @returns the original Color3
  5389. */
  5390. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5391. /**
  5392. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5393. * @param otherColor defines the second operand
  5394. * @returns the new Color3
  5395. */
  5396. add(otherColor: DeepImmutable<Color3>): Color3;
  5397. /**
  5398. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5399. * @param otherColor defines the second operand
  5400. * @param result defines Color3 object to store the result into
  5401. * @returns the unmodified current Color3
  5402. */
  5403. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5404. /**
  5405. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5406. * @param otherColor defines the second operand
  5407. * @returns the new Color3
  5408. */
  5409. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5410. /**
  5411. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5412. * @param otherColor defines the second operand
  5413. * @param result defines Color3 object to store the result into
  5414. * @returns the unmodified current Color3
  5415. */
  5416. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5417. /**
  5418. * Copy the current object
  5419. * @returns a new Color3 copied the current one
  5420. */
  5421. clone(): Color3;
  5422. /**
  5423. * Copies the rgb values from the source in the current Color3
  5424. * @param source defines the source Color3 object
  5425. * @returns the updated Color3 object
  5426. */
  5427. copyFrom(source: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Updates the Color3 rgb values from the given floats
  5430. * @param r defines the red component to read from
  5431. * @param g defines the green component to read from
  5432. * @param b defines the blue component to read from
  5433. * @returns the current Color3 object
  5434. */
  5435. copyFromFloats(r: number, g: number, b: number): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. set(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Compute the Color3 hexadecimal code as a string
  5446. * @returns a string containing the hexadecimal representation of the Color3 object
  5447. */
  5448. toHexString(): string;
  5449. /**
  5450. * Computes a new Color3 converted from the current one to linear space
  5451. * @returns a new Color3 object
  5452. */
  5453. toLinearSpace(): Color3;
  5454. /**
  5455. * Converts current color in rgb space to HSV values
  5456. * @returns a new color3 representing the HSV values
  5457. */
  5458. toHSV(): Color3;
  5459. /**
  5460. * Converts current color in rgb space to HSV values
  5461. * @param result defines the Color3 where to store the HSV values
  5462. */
  5463. toHSVToRef(result: Color3): void;
  5464. /**
  5465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5466. * @param convertedColor defines the Color3 object where to store the linear space version
  5467. * @returns the unmodified Color3
  5468. */
  5469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5470. /**
  5471. * Computes a new Color3 converted from the current one to gamma space
  5472. * @returns a new Color3 object
  5473. */
  5474. toGammaSpace(): Color3;
  5475. /**
  5476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5477. * @param convertedColor defines the Color3 object where to store the gamma space version
  5478. * @returns the unmodified Color3
  5479. */
  5480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5481. private static _BlackReadOnly;
  5482. /**
  5483. * Convert Hue, saturation and value to a Color3 (RGB)
  5484. * @param hue defines the hue
  5485. * @param saturation defines the saturation
  5486. * @param value defines the value
  5487. * @param result defines the Color3 where to store the RGB values
  5488. */
  5489. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5490. /**
  5491. * Creates a new Color3 from the string containing valid hexadecimal values
  5492. * @param hex defines a string containing valid hexadecimal values
  5493. * @returns a new Color3 object
  5494. */
  5495. static FromHexString(hex: string): Color3;
  5496. /**
  5497. * Creates a new Color3 from the starting index of the given array
  5498. * @param array defines the source array
  5499. * @param offset defines an offset in the source array
  5500. * @returns a new Color3 object
  5501. */
  5502. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5503. /**
  5504. * Creates a new Color3 from integer values (< 256)
  5505. * @param r defines the red component to read from (value between 0 and 255)
  5506. * @param g defines the green component to read from (value between 0 and 255)
  5507. * @param b defines the blue component to read from (value between 0 and 255)
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromInts(r: number, g: number, b: number): Color3;
  5511. /**
  5512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5513. * @param start defines the start Color3 value
  5514. * @param end defines the end Color3 value
  5515. * @param amount defines the gradient value between start and end
  5516. * @returns a new Color3 object
  5517. */
  5518. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param left defines the start value
  5522. * @param right defines the end value
  5523. * @param amount defines the gradient factor
  5524. * @param result defines the Color3 object where to store the result
  5525. */
  5526. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5527. /**
  5528. * Returns a Color3 value containing a red color
  5529. * @returns a new Color3 object
  5530. */
  5531. static Red(): Color3;
  5532. /**
  5533. * Returns a Color3 value containing a green color
  5534. * @returns a new Color3 object
  5535. */
  5536. static Green(): Color3;
  5537. /**
  5538. * Returns a Color3 value containing a blue color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Blue(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a black color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Black(): Color3;
  5547. /**
  5548. * Gets a Color3 value containing a black color that must not be updated
  5549. */
  5550. static get BlackReadOnly(): DeepImmutable<Color3>;
  5551. /**
  5552. * Returns a Color3 value containing a white color
  5553. * @returns a new Color3 object
  5554. */
  5555. static White(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a purple color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Purple(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a magenta color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Magenta(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a yellow color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Yellow(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a gray color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Gray(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a teal color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Teal(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a random color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Random(): Color3;
  5586. }
  5587. /**
  5588. * Class used to hold a RBGA color
  5589. */
  5590. export class Color4 {
  5591. /**
  5592. * Defines the red component (between 0 and 1, default is 0)
  5593. */
  5594. r: number;
  5595. /**
  5596. * Defines the green component (between 0 and 1, default is 0)
  5597. */
  5598. g: number;
  5599. /**
  5600. * Defines the blue component (between 0 and 1, default is 0)
  5601. */
  5602. b: number;
  5603. /**
  5604. * Defines the alpha component (between 0 and 1, default is 1)
  5605. */
  5606. a: number;
  5607. /**
  5608. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5609. * @param r defines the red component (between 0 and 1, default is 0)
  5610. * @param g defines the green component (between 0 and 1, default is 0)
  5611. * @param b defines the blue component (between 0 and 1, default is 0)
  5612. * @param a defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. constructor(
  5615. /**
  5616. * Defines the red component (between 0 and 1, default is 0)
  5617. */
  5618. r?: number,
  5619. /**
  5620. * Defines the green component (between 0 and 1, default is 0)
  5621. */
  5622. g?: number,
  5623. /**
  5624. * Defines the blue component (between 0 and 1, default is 0)
  5625. */
  5626. b?: number,
  5627. /**
  5628. * Defines the alpha component (between 0 and 1, default is 1)
  5629. */
  5630. a?: number);
  5631. /**
  5632. * Adds in place the given Color4 values to the current Color4 object
  5633. * @param right defines the second operand
  5634. * @returns the current updated Color4 object
  5635. */
  5636. addInPlace(right: DeepImmutable<Color4>): Color4;
  5637. /**
  5638. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5639. * @returns the new array
  5640. */
  5641. asArray(): number[];
  5642. /**
  5643. * Stores from the starting index in the given array the Color4 successive values
  5644. * @param array defines the array where to store the r,g,b components
  5645. * @param index defines an optional index in the target array to define where to start storing values
  5646. * @returns the current Color4 object
  5647. */
  5648. toArray(array: number[], index?: number): Color4;
  5649. /**
  5650. * Determines equality between Color4 objects
  5651. * @param otherColor defines the second operand
  5652. * @returns true if the rgba values are equal to the given ones
  5653. */
  5654. equals(otherColor: DeepImmutable<Color4>): boolean;
  5655. /**
  5656. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5657. * @param right defines the second operand
  5658. * @returns a new Color4 object
  5659. */
  5660. add(right: DeepImmutable<Color4>): Color4;
  5661. /**
  5662. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5663. * @param right defines the second operand
  5664. * @returns a new Color4 object
  5665. */
  5666. subtract(right: DeepImmutable<Color4>): Color4;
  5667. /**
  5668. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5669. * @param right defines the second operand
  5670. * @param result defines the Color4 object where to store the result
  5671. * @returns the current Color4 object
  5672. */
  5673. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5674. /**
  5675. * Creates a new Color4 with the current Color4 values multiplied by scale
  5676. * @param scale defines the scaling factor to apply
  5677. * @returns a new Color4 object
  5678. */
  5679. scale(scale: number): Color4;
  5680. /**
  5681. * Multiplies the current Color4 values by scale and stores the result in "result"
  5682. * @param scale defines the scaling factor to apply
  5683. * @param result defines the Color4 object where to store the result
  5684. * @returns the current unmodified Color4
  5685. */
  5686. scaleToRef(scale: number, result: Color4): Color4;
  5687. /**
  5688. * Scale the current Color4 values by a factor and add the result to a given Color4
  5689. * @param scale defines the scale factor
  5690. * @param result defines the Color4 object where to store the result
  5691. * @returns the unmodified current Color4
  5692. */
  5693. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5694. /**
  5695. * Clamps the rgb values by the min and max values and stores the result into "result"
  5696. * @param min defines minimum clamping value (default is 0)
  5697. * @param max defines maximum clamping value (default is 1)
  5698. * @param result defines color to store the result into.
  5699. * @returns the cuurent Color4
  5700. */
  5701. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5702. /**
  5703. * Multipy an Color4 value by another and return a new Color4 object
  5704. * @param color defines the Color4 value to multiply by
  5705. * @returns a new Color4 object
  5706. */
  5707. multiply(color: Color4): Color4;
  5708. /**
  5709. * Multipy a Color4 value by another and push the result in a reference value
  5710. * @param color defines the Color4 value to multiply by
  5711. * @param result defines the Color4 to fill the result in
  5712. * @returns the result Color4
  5713. */
  5714. multiplyToRef(color: Color4, result: Color4): Color4;
  5715. /**
  5716. * Creates a string with the Color4 current values
  5717. * @returns the string representation of the Color4 object
  5718. */
  5719. toString(): string;
  5720. /**
  5721. * Returns the string "Color4"
  5722. * @returns "Color4"
  5723. */
  5724. getClassName(): string;
  5725. /**
  5726. * Compute the Color4 hash code
  5727. * @returns an unique number that can be used to hash Color4 objects
  5728. */
  5729. getHashCode(): number;
  5730. /**
  5731. * Creates a new Color4 copied from the current one
  5732. * @returns a new Color4 object
  5733. */
  5734. clone(): Color4;
  5735. /**
  5736. * Copies the given Color4 values into the current one
  5737. * @param source defines the source Color4 object
  5738. * @returns the current updated Color4 object
  5739. */
  5740. copyFrom(source: Color4): Color4;
  5741. /**
  5742. * Copies the given float values into the current one
  5743. * @param r defines the red component to read from
  5744. * @param g defines the green component to read from
  5745. * @param b defines the blue component to read from
  5746. * @param a defines the alpha component to read from
  5747. * @returns the current updated Color4 object
  5748. */
  5749. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5750. /**
  5751. * Copies the given float values into the current one
  5752. * @param r defines the red component to read from
  5753. * @param g defines the green component to read from
  5754. * @param b defines the blue component to read from
  5755. * @param a defines the alpha component to read from
  5756. * @returns the current updated Color4 object
  5757. */
  5758. set(r: number, g: number, b: number, a: number): Color4;
  5759. /**
  5760. * Compute the Color4 hexadecimal code as a string
  5761. * @returns a string containing the hexadecimal representation of the Color4 object
  5762. */
  5763. toHexString(): string;
  5764. /**
  5765. * Computes a new Color4 converted from the current one to linear space
  5766. * @returns a new Color4 object
  5767. */
  5768. toLinearSpace(): Color4;
  5769. /**
  5770. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5771. * @param convertedColor defines the Color4 object where to store the linear space version
  5772. * @returns the unmodified Color4
  5773. */
  5774. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5775. /**
  5776. * Computes a new Color4 converted from the current one to gamma space
  5777. * @returns a new Color4 object
  5778. */
  5779. toGammaSpace(): Color4;
  5780. /**
  5781. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5782. * @param convertedColor defines the Color4 object where to store the gamma space version
  5783. * @returns the unmodified Color4
  5784. */
  5785. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5786. /**
  5787. * Creates a new Color4 from the string containing valid hexadecimal values
  5788. * @param hex defines a string containing valid hexadecimal values
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromHexString(hex: string): Color4;
  5792. /**
  5793. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5794. * @param left defines the start value
  5795. * @param right defines the end value
  5796. * @param amount defines the gradient factor
  5797. * @returns a new Color4 object
  5798. */
  5799. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5800. /**
  5801. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @param result defines the Color4 object where to store data
  5806. */
  5807. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5808. /**
  5809. * Creates a new Color4 from a Color3 and an alpha value
  5810. * @param color3 defines the source Color3 to read from
  5811. * @param alpha defines the alpha component (1.0 by default)
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5815. /**
  5816. * Creates a new Color4 from the starting index element of the given array
  5817. * @param array defines the source array to read from
  5818. * @param offset defines the offset in the source array
  5819. * @returns a new Color4 object
  5820. */
  5821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5822. /**
  5823. * Creates a new Color3 from integer values (< 256)
  5824. * @param r defines the red component to read from (value between 0 and 255)
  5825. * @param g defines the green component to read from (value between 0 and 255)
  5826. * @param b defines the blue component to read from (value between 0 and 255)
  5827. * @param a defines the alpha component to read from (value between 0 and 255)
  5828. * @returns a new Color3 object
  5829. */
  5830. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5831. /**
  5832. * Check the content of a given array and convert it to an array containing RGBA data
  5833. * If the original array was already containing count * 4 values then it is returned directly
  5834. * @param colors defines the array to check
  5835. * @param count defines the number of RGBA data to expect
  5836. * @returns an array containing count * 4 values (RGBA)
  5837. */
  5838. static CheckColors4(colors: number[], count: number): number[];
  5839. }
  5840. /**
  5841. * @hidden
  5842. */
  5843. export class TmpColors {
  5844. static Color3: Color3[];
  5845. static Color4: Color4[];
  5846. }
  5847. }
  5848. declare module BABYLON {
  5849. /**
  5850. * Defines an interface which represents an animation key frame
  5851. */
  5852. export interface IAnimationKey {
  5853. /**
  5854. * Frame of the key frame
  5855. */
  5856. frame: number;
  5857. /**
  5858. * Value at the specifies key frame
  5859. */
  5860. value: any;
  5861. /**
  5862. * The input tangent for the cubic hermite spline
  5863. */
  5864. inTangent?: any;
  5865. /**
  5866. * The output tangent for the cubic hermite spline
  5867. */
  5868. outTangent?: any;
  5869. /**
  5870. * The animation interpolation type
  5871. */
  5872. interpolation?: AnimationKeyInterpolation;
  5873. }
  5874. /**
  5875. * Enum for the animation key frame interpolation type
  5876. */
  5877. export enum AnimationKeyInterpolation {
  5878. /**
  5879. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5880. */
  5881. STEP = 1
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. /**
  5886. * Represents the range of an animation
  5887. */
  5888. export class AnimationRange {
  5889. /**The name of the animation range**/
  5890. name: string;
  5891. /**The starting frame of the animation */
  5892. from: number;
  5893. /**The ending frame of the animation*/
  5894. to: number;
  5895. /**
  5896. * Initializes the range of an animation
  5897. * @param name The name of the animation range
  5898. * @param from The starting frame of the animation
  5899. * @param to The ending frame of the animation
  5900. */
  5901. constructor(
  5902. /**The name of the animation range**/
  5903. name: string,
  5904. /**The starting frame of the animation */
  5905. from: number,
  5906. /**The ending frame of the animation*/
  5907. to: number);
  5908. /**
  5909. * Makes a copy of the animation range
  5910. * @returns A copy of the animation range
  5911. */
  5912. clone(): AnimationRange;
  5913. }
  5914. }
  5915. declare module BABYLON {
  5916. /**
  5917. * Composed of a frame, and an action function
  5918. */
  5919. export class AnimationEvent {
  5920. /** The frame for which the event is triggered **/
  5921. frame: number;
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void;
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined;
  5926. /**
  5927. * Specifies if the animation event is done
  5928. */
  5929. isDone: boolean;
  5930. /**
  5931. * Initializes the animation event
  5932. * @param frame The frame for which the event is triggered
  5933. * @param action The event to perform when triggered
  5934. * @param onlyOnce Specifies if the event should be triggered only once
  5935. */
  5936. constructor(
  5937. /** The frame for which the event is triggered **/
  5938. frame: number,
  5939. /** The event to perform when triggered **/
  5940. action: (currentFrame: number) => void,
  5941. /** Specifies if the event should be triggered only once**/
  5942. onlyOnce?: boolean | undefined);
  5943. /** @hidden */
  5944. _clone(): AnimationEvent;
  5945. }
  5946. }
  5947. declare module BABYLON {
  5948. /**
  5949. * Interface used to define a behavior
  5950. */
  5951. export interface Behavior<T> {
  5952. /** gets or sets behavior's name */
  5953. name: string;
  5954. /**
  5955. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5956. */
  5957. init(): void;
  5958. /**
  5959. * Called when the behavior is attached to a target
  5960. * @param target defines the target where the behavior is attached to
  5961. */
  5962. attach(target: T): void;
  5963. /**
  5964. * Called when the behavior is detached from its target
  5965. */
  5966. detach(): void;
  5967. }
  5968. /**
  5969. * Interface implemented by classes supporting behaviors
  5970. */
  5971. export interface IBehaviorAware<T> {
  5972. /**
  5973. * Attach a behavior
  5974. * @param behavior defines the behavior to attach
  5975. * @returns the current host
  5976. */
  5977. addBehavior(behavior: Behavior<T>): T;
  5978. /**
  5979. * Remove a behavior from the current object
  5980. * @param behavior defines the behavior to detach
  5981. * @returns the current host
  5982. */
  5983. removeBehavior(behavior: Behavior<T>): T;
  5984. /**
  5985. * Gets a behavior using its name to search
  5986. * @param name defines the name to search
  5987. * @returns the behavior or null if not found
  5988. */
  5989. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5990. }
  5991. }
  5992. declare module BABYLON {
  5993. /**
  5994. * Defines an array and its length.
  5995. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5996. */
  5997. export interface ISmartArrayLike<T> {
  5998. /**
  5999. * The data of the array.
  6000. */
  6001. data: Array<T>;
  6002. /**
  6003. * The active length of the array.
  6004. */
  6005. length: number;
  6006. }
  6007. /**
  6008. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6009. */
  6010. export class SmartArray<T> implements ISmartArrayLike<T> {
  6011. /**
  6012. * The full set of data from the array.
  6013. */
  6014. data: Array<T>;
  6015. /**
  6016. * The active length of the array.
  6017. */
  6018. length: number;
  6019. protected _id: number;
  6020. /**
  6021. * Instantiates a Smart Array.
  6022. * @param capacity defines the default capacity of the array.
  6023. */
  6024. constructor(capacity: number);
  6025. /**
  6026. * Pushes a value at the end of the active data.
  6027. * @param value defines the object to push in the array.
  6028. */
  6029. push(value: T): void;
  6030. /**
  6031. * Iterates over the active data and apply the lambda to them.
  6032. * @param func defines the action to apply on each value.
  6033. */
  6034. forEach(func: (content: T) => void): void;
  6035. /**
  6036. * Sorts the full sets of data.
  6037. * @param compareFn defines the comparison function to apply.
  6038. */
  6039. sort(compareFn: (a: T, b: T) => number): void;
  6040. /**
  6041. * Resets the active data to an empty array.
  6042. */
  6043. reset(): void;
  6044. /**
  6045. * Releases all the data from the array as well as the array.
  6046. */
  6047. dispose(): void;
  6048. /**
  6049. * Concats the active data with a given array.
  6050. * @param array defines the data to concatenate with.
  6051. */
  6052. concat(array: any): void;
  6053. /**
  6054. * Returns the position of a value in the active data.
  6055. * @param value defines the value to find the index for
  6056. * @returns the index if found in the active data otherwise -1
  6057. */
  6058. indexOf(value: T): number;
  6059. /**
  6060. * Returns whether an element is part of the active data.
  6061. * @param value defines the value to look for
  6062. * @returns true if found in the active data otherwise false
  6063. */
  6064. contains(value: T): boolean;
  6065. private static _GlobalId;
  6066. }
  6067. /**
  6068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6069. * The data in this array can only be present once
  6070. */
  6071. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6072. private _duplicateId;
  6073. /**
  6074. * Pushes a value at the end of the active data.
  6075. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6076. * @param value defines the object to push in the array.
  6077. */
  6078. push(value: T): void;
  6079. /**
  6080. * Pushes a value at the end of the active data.
  6081. * If the data is already present, it won t be added again
  6082. * @param value defines the object to push in the array.
  6083. * @returns true if added false if it was already present
  6084. */
  6085. pushNoDuplicate(value: T): boolean;
  6086. /**
  6087. * Resets the active data to an empty array.
  6088. */
  6089. reset(): void;
  6090. /**
  6091. * Concats the active data with a given array.
  6092. * This ensures no dupplicate will be present in the result.
  6093. * @param array defines the data to concatenate with.
  6094. */
  6095. concatWithNoDuplicate(array: any): void;
  6096. }
  6097. }
  6098. declare module BABYLON {
  6099. /**
  6100. * @ignore
  6101. * This is a list of all the different input types that are available in the application.
  6102. * Fo instance: ArcRotateCameraGamepadInput...
  6103. */
  6104. export var CameraInputTypes: {};
  6105. /**
  6106. * This is the contract to implement in order to create a new input class.
  6107. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6108. */
  6109. export interface ICameraInput<TCamera extends Camera> {
  6110. /**
  6111. * Defines the camera the input is attached to.
  6112. */
  6113. camera: Nullable<TCamera>;
  6114. /**
  6115. * Gets the class name of the current intput.
  6116. * @returns the class name
  6117. */
  6118. getClassName(): string;
  6119. /**
  6120. * Get the friendly name associated with the input class.
  6121. * @returns the input friendly name
  6122. */
  6123. getSimpleName(): string;
  6124. /**
  6125. * Attach the input controls to a specific dom element to get the input from.
  6126. * @param element Defines the element the controls should be listened from
  6127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6128. */
  6129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6130. /**
  6131. * Detach the current controls from the specified dom element.
  6132. * @param element Defines the element to stop listening the inputs from
  6133. */
  6134. detachControl(element: Nullable<HTMLElement>): void;
  6135. /**
  6136. * Update the current camera state depending on the inputs that have been used this frame.
  6137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6138. */
  6139. checkInputs?: () => void;
  6140. }
  6141. /**
  6142. * Represents a map of input types to input instance or input index to input instance.
  6143. */
  6144. export interface CameraInputsMap<TCamera extends Camera> {
  6145. /**
  6146. * Accessor to the input by input type.
  6147. */
  6148. [name: string]: ICameraInput<TCamera>;
  6149. /**
  6150. * Accessor to the input by input index.
  6151. */
  6152. [idx: number]: ICameraInput<TCamera>;
  6153. }
  6154. /**
  6155. * This represents the input manager used within a camera.
  6156. * It helps dealing with all the different kind of input attached to a camera.
  6157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6158. */
  6159. export class CameraInputsManager<TCamera extends Camera> {
  6160. /**
  6161. * Defines the list of inputs attahed to the camera.
  6162. */
  6163. attached: CameraInputsMap<TCamera>;
  6164. /**
  6165. * Defines the dom element the camera is collecting inputs from.
  6166. * This is null if the controls have not been attached.
  6167. */
  6168. attachedElement: Nullable<HTMLElement>;
  6169. /**
  6170. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. noPreventDefault: boolean;
  6173. /**
  6174. * Defined the camera the input manager belongs to.
  6175. */
  6176. camera: TCamera;
  6177. /**
  6178. * Update the current camera state depending on the inputs that have been used this frame.
  6179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6180. */
  6181. checkInputs: () => void;
  6182. /**
  6183. * Instantiate a new Camera Input Manager.
  6184. * @param camera Defines the camera the input manager blongs to
  6185. */
  6186. constructor(camera: TCamera);
  6187. /**
  6188. * Add an input method to a camera
  6189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6190. * @param input camera input method
  6191. */
  6192. add(input: ICameraInput<TCamera>): void;
  6193. /**
  6194. * Remove a specific input method from a camera
  6195. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6196. * @param inputToRemove camera input method
  6197. */
  6198. remove(inputToRemove: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input type from a camera
  6201. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6202. * @param inputType the type of the input to remove
  6203. */
  6204. removeByType(inputType: string): void;
  6205. private _addCheckInputs;
  6206. /**
  6207. * Attach the input controls to the currently attached dom element to listen the events from.
  6208. * @param input Defines the input to attach
  6209. */
  6210. attachInput(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6213. * @param element Defines the dom element to collect the events from
  6214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6215. */
  6216. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6217. /**
  6218. * Detach the current manager inputs controls from a specific dom element.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6221. */
  6222. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6223. /**
  6224. * Rebuild the dynamic inputCheck function from the current list of
  6225. * defined inputs in the manager.
  6226. */
  6227. rebuildInputCheck(): void;
  6228. /**
  6229. * Remove all attached input methods from a camera
  6230. */
  6231. clear(): void;
  6232. /**
  6233. * Serialize the current input manager attached to a camera.
  6234. * This ensures than once parsed,
  6235. * the input associated to the camera will be identical to the current ones
  6236. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6237. */
  6238. serialize(serializedCamera: any): void;
  6239. /**
  6240. * Parses an input manager serialized JSON to restore the previous list of inputs
  6241. * and states associated to a camera.
  6242. * @param parsedCamera Defines the JSON to parse
  6243. */
  6244. parse(parsedCamera: any): void;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * Class used to store data that will be store in GPU memory
  6250. */
  6251. export class Buffer {
  6252. private _engine;
  6253. private _buffer;
  6254. /** @hidden */
  6255. _data: Nullable<DataArray>;
  6256. private _updatable;
  6257. private _instanced;
  6258. private _divisor;
  6259. /**
  6260. * Gets the byte stride.
  6261. */
  6262. readonly byteStride: number;
  6263. /**
  6264. * Constructor
  6265. * @param engine the engine
  6266. * @param data the data to use for this buffer
  6267. * @param updatable whether the data is updatable
  6268. * @param stride the stride (optional)
  6269. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6270. * @param instanced whether the buffer is instanced (optional)
  6271. * @param useBytes set to true if the stride in in bytes (optional)
  6272. * @param divisor sets an optional divisor for instances (1 by default)
  6273. */
  6274. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6275. /**
  6276. * Create a new VertexBuffer based on the current buffer
  6277. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6278. * @param offset defines offset in the buffer (0 by default)
  6279. * @param size defines the size in floats of attributes (position is 3 for instance)
  6280. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6281. * @param instanced defines if the vertex buffer contains indexed data
  6282. * @param useBytes defines if the offset and stride are in bytes *
  6283. * @param divisor sets an optional divisor for instances (1 by default)
  6284. * @returns the new vertex buffer
  6285. */
  6286. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6287. /**
  6288. * Gets a boolean indicating if the Buffer is updatable?
  6289. * @returns true if the buffer is updatable
  6290. */
  6291. isUpdatable(): boolean;
  6292. /**
  6293. * Gets current buffer's data
  6294. * @returns a DataArray or null
  6295. */
  6296. getData(): Nullable<DataArray>;
  6297. /**
  6298. * Gets underlying native buffer
  6299. * @returns underlying native buffer
  6300. */
  6301. getBuffer(): Nullable<DataBuffer>;
  6302. /**
  6303. * Gets the stride in float32 units (i.e. byte stride / 4).
  6304. * May not be an integer if the byte stride is not divisible by 4.
  6305. * @returns the stride in float32 units
  6306. * @deprecated Please use byteStride instead.
  6307. */
  6308. getStrideSize(): number;
  6309. /**
  6310. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6311. * @param data defines the data to store
  6312. */
  6313. create(data?: Nullable<DataArray>): void;
  6314. /** @hidden */
  6315. _rebuild(): void;
  6316. /**
  6317. * Update current buffer data
  6318. * @param data defines the data to store
  6319. */
  6320. update(data: DataArray): void;
  6321. /**
  6322. * Updates the data directly.
  6323. * @param data the new data
  6324. * @param offset the new offset
  6325. * @param vertexCount the vertex count (optional)
  6326. * @param useBytes set to true if the offset is in bytes
  6327. */
  6328. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6329. /**
  6330. * Release all resources
  6331. */
  6332. dispose(): void;
  6333. }
  6334. /**
  6335. * Specialized buffer used to store vertex data
  6336. */
  6337. export class VertexBuffer {
  6338. /** @hidden */
  6339. _buffer: Buffer;
  6340. private _kind;
  6341. private _size;
  6342. private _ownsBuffer;
  6343. private _instanced;
  6344. private _instanceDivisor;
  6345. /**
  6346. * The byte type.
  6347. */
  6348. static readonly BYTE: number;
  6349. /**
  6350. * The unsigned byte type.
  6351. */
  6352. static readonly UNSIGNED_BYTE: number;
  6353. /**
  6354. * The short type.
  6355. */
  6356. static readonly SHORT: number;
  6357. /**
  6358. * The unsigned short type.
  6359. */
  6360. static readonly UNSIGNED_SHORT: number;
  6361. /**
  6362. * The integer type.
  6363. */
  6364. static readonly INT: number;
  6365. /**
  6366. * The unsigned integer type.
  6367. */
  6368. static readonly UNSIGNED_INT: number;
  6369. /**
  6370. * The float type.
  6371. */
  6372. static readonly FLOAT: number;
  6373. /**
  6374. * Gets or sets the instance divisor when in instanced mode
  6375. */
  6376. get instanceDivisor(): number;
  6377. set instanceDivisor(value: number);
  6378. /**
  6379. * Gets the byte stride.
  6380. */
  6381. readonly byteStride: number;
  6382. /**
  6383. * Gets the byte offset.
  6384. */
  6385. readonly byteOffset: number;
  6386. /**
  6387. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6388. */
  6389. readonly normalized: boolean;
  6390. /**
  6391. * Gets the data type of each component in the array.
  6392. */
  6393. readonly type: number;
  6394. /**
  6395. * Constructor
  6396. * @param engine the engine
  6397. * @param data the data to use for this vertex buffer
  6398. * @param kind the vertex buffer kind
  6399. * @param updatable whether the data is updatable
  6400. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6401. * @param stride the stride (optional)
  6402. * @param instanced whether the buffer is instanced (optional)
  6403. * @param offset the offset of the data (optional)
  6404. * @param size the number of components (optional)
  6405. * @param type the type of the component (optional)
  6406. * @param normalized whether the data contains normalized data (optional)
  6407. * @param useBytes set to true if stride and offset are in bytes (optional)
  6408. * @param divisor defines the instance divisor to use (1 by default)
  6409. */
  6410. 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);
  6411. /** @hidden */
  6412. _rebuild(): void;
  6413. /**
  6414. * Returns the kind of the VertexBuffer (string)
  6415. * @returns a string
  6416. */
  6417. getKind(): string;
  6418. /**
  6419. * Gets a boolean indicating if the VertexBuffer is updatable?
  6420. * @returns true if the buffer is updatable
  6421. */
  6422. isUpdatable(): boolean;
  6423. /**
  6424. * Gets current buffer's data
  6425. * @returns a DataArray or null
  6426. */
  6427. getData(): Nullable<DataArray>;
  6428. /**
  6429. * Gets underlying native buffer
  6430. * @returns underlying native buffer
  6431. */
  6432. getBuffer(): Nullable<DataBuffer>;
  6433. /**
  6434. * Gets the stride in float32 units (i.e. byte stride / 4).
  6435. * May not be an integer if the byte stride is not divisible by 4.
  6436. * @returns the stride in float32 units
  6437. * @deprecated Please use byteStride instead.
  6438. */
  6439. getStrideSize(): number;
  6440. /**
  6441. * Returns the offset as a multiple of the type byte length.
  6442. * @returns the offset in bytes
  6443. * @deprecated Please use byteOffset instead.
  6444. */
  6445. getOffset(): number;
  6446. /**
  6447. * Returns the number of components per vertex attribute (integer)
  6448. * @returns the size in float
  6449. */
  6450. getSize(): number;
  6451. /**
  6452. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6453. * @returns true if this buffer is instanced
  6454. */
  6455. getIsInstanced(): boolean;
  6456. /**
  6457. * Returns the instancing divisor, zero for non-instanced (integer).
  6458. * @returns a number
  6459. */
  6460. getInstanceDivisor(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: DataArray): void;
  6466. /**
  6467. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6468. * This function will create a new buffer if the current one is not updatable
  6469. * @param data defines the data to store
  6470. */
  6471. update(data: DataArray): void;
  6472. /**
  6473. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6474. * Returns the directly updated WebGLBuffer.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param useBytes set to true if the offset is in bytes
  6478. */
  6479. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6480. /**
  6481. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6482. */
  6483. dispose(): void;
  6484. /**
  6485. * Enumerates each value of this vertex buffer as numbers.
  6486. * @param count the number of values to enumerate
  6487. * @param callback the callback function called for each value
  6488. */
  6489. forEach(count: number, callback: (value: number, index: number) => void): void;
  6490. /**
  6491. * Positions
  6492. */
  6493. static readonly PositionKind: string;
  6494. /**
  6495. * Normals
  6496. */
  6497. static readonly NormalKind: string;
  6498. /**
  6499. * Tangents
  6500. */
  6501. static readonly TangentKind: string;
  6502. /**
  6503. * Texture coordinates
  6504. */
  6505. static readonly UVKind: string;
  6506. /**
  6507. * Texture coordinates 2
  6508. */
  6509. static readonly UV2Kind: string;
  6510. /**
  6511. * Texture coordinates 3
  6512. */
  6513. static readonly UV3Kind: string;
  6514. /**
  6515. * Texture coordinates 4
  6516. */
  6517. static readonly UV4Kind: string;
  6518. /**
  6519. * Texture coordinates 5
  6520. */
  6521. static readonly UV5Kind: string;
  6522. /**
  6523. * Texture coordinates 6
  6524. */
  6525. static readonly UV6Kind: string;
  6526. /**
  6527. * Colors
  6528. */
  6529. static readonly ColorKind: string;
  6530. /**
  6531. * Matrix indices (for bones)
  6532. */
  6533. static readonly MatricesIndicesKind: string;
  6534. /**
  6535. * Matrix weights (for bones)
  6536. */
  6537. static readonly MatricesWeightsKind: string;
  6538. /**
  6539. * Additional matrix indices (for bones)
  6540. */
  6541. static readonly MatricesIndicesExtraKind: string;
  6542. /**
  6543. * Additional matrix weights (for bones)
  6544. */
  6545. static readonly MatricesWeightsExtraKind: string;
  6546. /**
  6547. * Deduces the stride given a kind.
  6548. * @param kind The kind string to deduce
  6549. * @returns The deduced stride
  6550. */
  6551. static DeduceStride(kind: string): number;
  6552. /**
  6553. * Gets the byte length of the given type.
  6554. * @param type the type
  6555. * @returns the number of bytes
  6556. */
  6557. static GetTypeByteLength(type: number): number;
  6558. /**
  6559. * Enumerates each value of the given parameters as numbers.
  6560. * @param data the data to enumerate
  6561. * @param byteOffset the byte offset of the data
  6562. * @param byteStride the byte stride of the data
  6563. * @param componentCount the number of components per element
  6564. * @param componentType the type of the component
  6565. * @param count the number of values to enumerate
  6566. * @param normalized whether the data is normalized
  6567. * @param callback the callback function called for each value
  6568. */
  6569. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6570. private static _GetFloatValue;
  6571. }
  6572. }
  6573. declare module BABYLON {
  6574. /**
  6575. * @hidden
  6576. */
  6577. export class IntersectionInfo {
  6578. bu: Nullable<number>;
  6579. bv: Nullable<number>;
  6580. distance: number;
  6581. faceId: number;
  6582. subMeshId: number;
  6583. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6584. }
  6585. }
  6586. declare module BABYLON {
  6587. /**
  6588. * Represens a plane by the equation ax + by + cz + d = 0
  6589. */
  6590. export class Plane {
  6591. private static _TmpMatrix;
  6592. /**
  6593. * Normal of the plane (a,b,c)
  6594. */
  6595. normal: Vector3;
  6596. /**
  6597. * d component of the plane
  6598. */
  6599. d: number;
  6600. /**
  6601. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6602. * @param a a component of the plane
  6603. * @param b b component of the plane
  6604. * @param c c component of the plane
  6605. * @param d d component of the plane
  6606. */
  6607. constructor(a: number, b: number, c: number, d: number);
  6608. /**
  6609. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6610. */
  6611. asArray(): number[];
  6612. /**
  6613. * @returns a new plane copied from the current Plane.
  6614. */
  6615. clone(): Plane;
  6616. /**
  6617. * @returns the string "Plane".
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * @returns the Plane hash code.
  6622. */
  6623. getHashCode(): number;
  6624. /**
  6625. * Normalize the current Plane in place.
  6626. * @returns the updated Plane.
  6627. */
  6628. normalize(): Plane;
  6629. /**
  6630. * Applies a transformation the plane and returns the result
  6631. * @param transformation the transformation matrix to be applied to the plane
  6632. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6633. */
  6634. transform(transformation: DeepImmutable<Matrix>): Plane;
  6635. /**
  6636. * Calcualtte the dot product between the point and the plane normal
  6637. * @param point point to calculate the dot product with
  6638. * @returns the dot product (float) of the point coordinates and the plane normal.
  6639. */
  6640. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6641. /**
  6642. * Updates the current Plane from the plane defined by the three given points.
  6643. * @param point1 one of the points used to contruct the plane
  6644. * @param point2 one of the points used to contruct the plane
  6645. * @param point3 one of the points used to contruct the plane
  6646. * @returns the updated Plane.
  6647. */
  6648. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6649. /**
  6650. * Checks if the plane is facing a given direction
  6651. * @param direction the direction to check if the plane is facing
  6652. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6653. * @returns True is the vector "direction" is the same side than the plane normal.
  6654. */
  6655. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6656. /**
  6657. * Calculates the distance to a point
  6658. * @param point point to calculate distance to
  6659. * @returns the signed distance (float) from the given point to the Plane.
  6660. */
  6661. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6662. /**
  6663. * Creates a plane from an array
  6664. * @param array the array to create a plane from
  6665. * @returns a new Plane from the given array.
  6666. */
  6667. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6668. /**
  6669. * Creates a plane from three points
  6670. * @param point1 point used to create the plane
  6671. * @param point2 point used to create the plane
  6672. * @param point3 point used to create the plane
  6673. * @returns a new Plane defined by the three given points.
  6674. */
  6675. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Creates a plane from an origin point and a normal
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @returns a new Plane the normal vector to this plane at the given origin point.
  6681. * Note : the vector "normal" is updated because normalized.
  6682. */
  6683. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6684. /**
  6685. * Calculates the distance from a plane and a point
  6686. * @param origin origin of the plane to be constructed
  6687. * @param normal normal of the plane to be constructed
  6688. * @param point point to calculate distance to
  6689. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6690. */
  6691. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Class used to store bounding sphere information
  6697. */
  6698. export class BoundingSphere {
  6699. /**
  6700. * Gets the center of the bounding sphere in local space
  6701. */
  6702. readonly center: Vector3;
  6703. /**
  6704. * Radius of the bounding sphere in local space
  6705. */
  6706. radius: number;
  6707. /**
  6708. * Gets the center of the bounding sphere in world space
  6709. */
  6710. readonly centerWorld: Vector3;
  6711. /**
  6712. * Radius of the bounding sphere in world space
  6713. */
  6714. radiusWorld: number;
  6715. /**
  6716. * Gets the minimum vector in local space
  6717. */
  6718. readonly minimum: Vector3;
  6719. /**
  6720. * Gets the maximum vector in local space
  6721. */
  6722. readonly maximum: Vector3;
  6723. private _worldMatrix;
  6724. private static readonly TmpVector3;
  6725. /**
  6726. * Creates a new bounding sphere
  6727. * @param min defines the minimum vector (in local space)
  6728. * @param max defines the maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6732. /**
  6733. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6734. * @param min defines the new minimum vector (in local space)
  6735. * @param max defines the new maximum vector (in local space)
  6736. * @param worldMatrix defines the new world matrix
  6737. */
  6738. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6739. /**
  6740. * Scale the current bounding sphere by applying a scale factor
  6741. * @param factor defines the scale factor to apply
  6742. * @returns the current bounding box
  6743. */
  6744. scale(factor: number): BoundingSphere;
  6745. /**
  6746. * Gets the world matrix of the bounding box
  6747. * @returns a matrix
  6748. */
  6749. getWorldMatrix(): DeepImmutable<Matrix>;
  6750. /** @hidden */
  6751. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Tests if the bounding sphere is intersecting the frustum planes
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if there is an intersection
  6756. */
  6757. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if the bounding sphere center is in between the frustum planes.
  6760. * Used for optimistic fast inclusion.
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @returns true if the sphere center is in between the frustum planes
  6763. */
  6764. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a point is inside the bounding sphere
  6767. * @param point defines the point to test
  6768. * @returns true if the point is inside the bounding sphere
  6769. */
  6770. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6771. /**
  6772. * Checks if two sphere intersct
  6773. * @param sphere0 sphere 0
  6774. * @param sphere1 sphere 1
  6775. * @returns true if the speres intersect
  6776. */
  6777. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6778. }
  6779. }
  6780. declare module BABYLON {
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module BABYLON {
  6926. /** @hidden */
  6927. export class Collider {
  6928. /** Define if a collision was found */
  6929. collisionFound: boolean;
  6930. /**
  6931. * Define last intersection point in local space
  6932. */
  6933. intersectionPoint: Vector3;
  6934. /**
  6935. * Define last collided mesh
  6936. */
  6937. collidedMesh: Nullable<AbstractMesh>;
  6938. private _collisionPoint;
  6939. private _planeIntersectionPoint;
  6940. private _tempVector;
  6941. private _tempVector2;
  6942. private _tempVector3;
  6943. private _tempVector4;
  6944. private _edge;
  6945. private _baseToVertex;
  6946. private _destinationPoint;
  6947. private _slidePlaneNormal;
  6948. private _displacementVector;
  6949. /** @hidden */
  6950. _radius: Vector3;
  6951. /** @hidden */
  6952. _retry: number;
  6953. private _velocity;
  6954. private _basePoint;
  6955. private _epsilon;
  6956. /** @hidden */
  6957. _velocityWorldLength: number;
  6958. /** @hidden */
  6959. _basePointWorld: Vector3;
  6960. private _velocityWorld;
  6961. private _normalizedVelocity;
  6962. /** @hidden */
  6963. _initialVelocity: Vector3;
  6964. /** @hidden */
  6965. _initialPosition: Vector3;
  6966. private _nearestDistance;
  6967. private _collisionMask;
  6968. get collisionMask(): number;
  6969. set collisionMask(mask: number);
  6970. /**
  6971. * Gets the plane normal used to compute the sliding response (in local space)
  6972. */
  6973. get slidePlaneNormal(): Vector3;
  6974. /** @hidden */
  6975. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6976. /** @hidden */
  6977. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6978. /** @hidden */
  6979. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6980. /** @hidden */
  6981. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6982. /** @hidden */
  6983. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6984. /** @hidden */
  6985. _getResponse(pos: Vector3, vel: Vector3): void;
  6986. }
  6987. }
  6988. declare module BABYLON {
  6989. /**
  6990. * Interface for cullable objects
  6991. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6992. */
  6993. export interface ICullable {
  6994. /**
  6995. * Checks if the object or part of the object is in the frustum
  6996. * @param frustumPlanes Camera near/planes
  6997. * @returns true if the object is in frustum otherwise false
  6998. */
  6999. isInFrustum(frustumPlanes: Plane[]): boolean;
  7000. /**
  7001. * Checks if a cullable object (mesh...) is in the camera frustum
  7002. * Unlike isInFrustum this cheks the full bounding box
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7007. }
  7008. /**
  7009. * Info for a bounding data of a mesh
  7010. */
  7011. export class BoundingInfo implements ICullable {
  7012. /**
  7013. * Bounding box for the mesh
  7014. */
  7015. readonly boundingBox: BoundingBox;
  7016. /**
  7017. * Bounding sphere for the mesh
  7018. */
  7019. readonly boundingSphere: BoundingSphere;
  7020. private _isLocked;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * Constructs bounding info
  7024. * @param minimum min vector of the bounding box/sphere
  7025. * @param maximum max vector of the bounding box/sphere
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7029. /**
  7030. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7031. * @param min defines the new minimum vector (in local space)
  7032. * @param max defines the new maximum vector (in local space)
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7036. /**
  7037. * min vector of the bounding box/sphere
  7038. */
  7039. get minimum(): Vector3;
  7040. /**
  7041. * max vector of the bounding box/sphere
  7042. */
  7043. get maximum(): Vector3;
  7044. /**
  7045. * If the info is locked and won't be updated to avoid perf overhead
  7046. */
  7047. get isLocked(): boolean;
  7048. set isLocked(value: boolean);
  7049. /**
  7050. * Updates the bounding sphere and box
  7051. * @param world world matrix to be used to update
  7052. */
  7053. update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7056. * @param center New center of the bounding info
  7057. * @param extend New extend of the bounding info
  7058. * @returns the current bounding info
  7059. */
  7060. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7061. /**
  7062. * Scale the current bounding info by applying a scale factor
  7063. * @param factor defines the scale factor to apply
  7064. * @returns the current bounding info
  7065. */
  7066. scale(factor: number): BoundingInfo;
  7067. /**
  7068. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7069. * @param frustumPlanes defines the frustum to test
  7070. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7071. * @returns true if the bounding info is in the frustum planes
  7072. */
  7073. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7074. /**
  7075. * Gets the world distance between the min and max points of the bounding box
  7076. */
  7077. get diagonalLength(): number;
  7078. /**
  7079. * Checks if a cullable object (mesh...) is in the camera frustum
  7080. * Unlike isInFrustum this cheks the full bounding box
  7081. * @param frustumPlanes Camera near/planes
  7082. * @returns true if the object is in frustum otherwise false
  7083. */
  7084. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /** @hidden */
  7086. _checkCollision(collider: Collider): boolean;
  7087. /**
  7088. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7089. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7090. * @param point the point to check intersection with
  7091. * @returns if the point intersects
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7096. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7097. * @param boundingInfo the bounding info to check intersection with
  7098. * @param precise if the intersection should be done using OBB
  7099. * @returns if the bounding info intersects
  7100. */
  7101. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Extracts minimum and maximum values from a list of indexed positions
  7107. * @param positions defines the positions to use
  7108. * @param indices defines the indices to the positions
  7109. * @param indexStart defines the start index
  7110. * @param indexCount defines the end index
  7111. * @param bias defines bias value to add to the result
  7112. * @return minimum and maximum values
  7113. */
  7114. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7115. minimum: Vector3;
  7116. maximum: Vector3;
  7117. };
  7118. /**
  7119. * Extracts minimum and maximum values from a list of positions
  7120. * @param positions defines the positions to use
  7121. * @param start defines the start index in the positions array
  7122. * @param count defines the number of positions to handle
  7123. * @param bias defines bias value to add to the result
  7124. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7125. * @return minimum and maximum values
  7126. */
  7127. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7128. minimum: Vector3;
  7129. maximum: Vector3;
  7130. };
  7131. }
  7132. declare module BABYLON {
  7133. /** @hidden */
  7134. export class WebGLDataBuffer extends DataBuffer {
  7135. private _buffer;
  7136. constructor(resource: WebGLBuffer);
  7137. get underlyingResource(): any;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. /** @hidden */
  7142. export class WebGLPipelineContext implements IPipelineContext {
  7143. engine: ThinEngine;
  7144. program: Nullable<WebGLProgram>;
  7145. context?: WebGLRenderingContext;
  7146. vertexShader?: WebGLShader;
  7147. fragmentShader?: WebGLShader;
  7148. isParallelCompiled: boolean;
  7149. onCompiled?: () => void;
  7150. transformFeedback?: WebGLTransformFeedback | null;
  7151. vertexCompilationError: Nullable<string>;
  7152. fragmentCompilationError: Nullable<string>;
  7153. programLinkError: Nullable<string>;
  7154. programValidationError: Nullable<string>;
  7155. get isAsync(): boolean;
  7156. get isReady(): boolean;
  7157. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7158. }
  7159. }
  7160. declare module BABYLON {
  7161. interface ThinEngine {
  7162. /**
  7163. * Create an uniform buffer
  7164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7165. * @param elements defines the content of the uniform buffer
  7166. * @returns the webGL uniform buffer
  7167. */
  7168. createUniformBuffer(elements: FloatArray): DataBuffer;
  7169. /**
  7170. * Create a dynamic uniform buffer
  7171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7172. * @param elements defines the content of the uniform buffer
  7173. * @returns the webGL uniform buffer
  7174. */
  7175. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7176. /**
  7177. * Update an existing uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param uniformBuffer defines the target uniform buffer
  7180. * @param elements defines the content to update
  7181. * @param offset defines the offset in the uniform buffer where update should start
  7182. * @param count defines the size of the data to update
  7183. */
  7184. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7185. /**
  7186. * Bind an uniform buffer to the current webGL context
  7187. * @param buffer defines the buffer to bind
  7188. */
  7189. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7190. /**
  7191. * Bind a buffer to the current webGL context at a given location
  7192. * @param buffer defines the buffer to bind
  7193. * @param location defines the index where to bind the buffer
  7194. */
  7195. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7196. /**
  7197. * Bind a specific block at a given index in a specific shader program
  7198. * @param pipelineContext defines the pipeline context to use
  7199. * @param blockName defines the block name
  7200. * @param index defines the index where to bind the block
  7201. */
  7202. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7203. }
  7204. }
  7205. declare module BABYLON {
  7206. /**
  7207. * Uniform buffer objects.
  7208. *
  7209. * Handles blocks of uniform on the GPU.
  7210. *
  7211. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7212. *
  7213. * For more information, please refer to :
  7214. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7215. */
  7216. export class UniformBuffer {
  7217. private _engine;
  7218. private _buffer;
  7219. private _data;
  7220. private _bufferData;
  7221. private _dynamic?;
  7222. private _uniformLocations;
  7223. private _uniformSizes;
  7224. private _uniformLocationPointer;
  7225. private _needSync;
  7226. private _noUBO;
  7227. private _currentEffect;
  7228. /** @hidden */
  7229. _alreadyBound: boolean;
  7230. private static _MAX_UNIFORM_SIZE;
  7231. private static _tempBuffer;
  7232. /**
  7233. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7234. * This is dynamic to allow compat with webgl 1 and 2.
  7235. * You will need to pass the name of the uniform as well as the value.
  7236. */
  7237. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7238. /**
  7239. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7240. * This is dynamic to allow compat with webgl 1 and 2.
  7241. * You will need to pass the name of the uniform as well as the value.
  7242. */
  7243. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7244. /**
  7245. * Lambda to Update a single float in a uniform buffer.
  7246. * This is dynamic to allow compat with webgl 1 and 2.
  7247. * You will need to pass the name of the uniform as well as the value.
  7248. */
  7249. updateFloat: (name: string, x: number) => void;
  7250. /**
  7251. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7256. /**
  7257. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7262. /**
  7263. * Lambda to Update a vec4 of 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7268. /**
  7269. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7274. /**
  7275. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7280. /**
  7281. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7286. /**
  7287. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7298. /**
  7299. * Instantiates a new Uniform buffer objects.
  7300. *
  7301. * Handles blocks of uniform on the GPU.
  7302. *
  7303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7304. *
  7305. * For more information, please refer to :
  7306. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7307. * @param engine Define the engine the buffer is associated with
  7308. * @param data Define the data contained in the buffer
  7309. * @param dynamic Define if the buffer is updatable
  7310. */
  7311. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7312. /**
  7313. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7314. * or just falling back on setUniformXXX calls.
  7315. */
  7316. get useUbo(): boolean;
  7317. /**
  7318. * Indicates if the WebGL underlying uniform buffer is in sync
  7319. * with the javascript cache data.
  7320. */
  7321. get isSync(): boolean;
  7322. /**
  7323. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7324. * Also, a dynamic UniformBuffer will disable cache verification and always
  7325. * update the underlying WebGL uniform buffer to the GPU.
  7326. * @returns if Dynamic, otherwise false
  7327. */
  7328. isDynamic(): boolean;
  7329. /**
  7330. * The data cache on JS side.
  7331. * @returns the underlying data as a float array
  7332. */
  7333. getData(): Float32Array;
  7334. /**
  7335. * The underlying WebGL Uniform buffer.
  7336. * @returns the webgl buffer
  7337. */
  7338. getBuffer(): Nullable<DataBuffer>;
  7339. /**
  7340. * std140 layout specifies how to align data within an UBO structure.
  7341. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7342. * for specs.
  7343. */
  7344. private _fillAlignment;
  7345. /**
  7346. * Adds an uniform in the buffer.
  7347. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7348. * for the layout to be correct !
  7349. * @param name Name of the uniform, as used in the uniform block in the shader.
  7350. * @param size Data size, or data directly.
  7351. */
  7352. addUniform(name: string, size: number | number[]): void;
  7353. /**
  7354. * Adds a Matrix 4x4 to the uniform buffer.
  7355. * @param name Name of the uniform, as used in the uniform block in the shader.
  7356. * @param mat A 4x4 matrix.
  7357. */
  7358. addMatrix(name: string, mat: Matrix): void;
  7359. /**
  7360. * Adds a vec2 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param x Define the x component value of the vec2
  7363. * @param y Define the y component value of the vec2
  7364. */
  7365. addFloat2(name: string, x: number, y: number): void;
  7366. /**
  7367. * Adds a vec3 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. * @param x Define the x component value of the vec3
  7370. * @param y Define the y component value of the vec3
  7371. * @param z Define the z component value of the vec3
  7372. */
  7373. addFloat3(name: string, x: number, y: number, z: number): void;
  7374. /**
  7375. * Adds a vec3 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param color Define the vec3 from a Color
  7378. */
  7379. addColor3(name: string, color: Color3): void;
  7380. /**
  7381. * Adds a vec4 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param color Define the rgb components from a Color
  7384. * @param alpha Define the a component of the vec4
  7385. */
  7386. addColor4(name: string, color: Color3, alpha: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param vector Define the vec3 components from a Vector
  7391. */
  7392. addVector3(name: string, vector: Vector3): void;
  7393. /**
  7394. * Adds a Matrix 3x3 to the uniform buffer.
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. */
  7397. addMatrix3x3(name: string): void;
  7398. /**
  7399. * Adds a Matrix 2x2 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. */
  7402. addMatrix2x2(name: string): void;
  7403. /**
  7404. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7405. */
  7406. create(): void;
  7407. /** @hidden */
  7408. _rebuild(): void;
  7409. /**
  7410. * Updates the WebGL Uniform Buffer on the GPU.
  7411. * If the `dynamic` flag is set to true, no cache comparison is done.
  7412. * Otherwise, the buffer will be updated only if the cache differs.
  7413. */
  7414. update(): void;
  7415. /**
  7416. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7418. * @param data Define the flattened data
  7419. * @param size Define the size of the data.
  7420. */
  7421. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7422. private _valueCache;
  7423. private _cacheMatrix;
  7424. private _updateMatrix3x3ForUniform;
  7425. private _updateMatrix3x3ForEffect;
  7426. private _updateMatrix2x2ForEffect;
  7427. private _updateMatrix2x2ForUniform;
  7428. private _updateFloatForEffect;
  7429. private _updateFloatForUniform;
  7430. private _updateFloat2ForEffect;
  7431. private _updateFloat2ForUniform;
  7432. private _updateFloat3ForEffect;
  7433. private _updateFloat3ForUniform;
  7434. private _updateFloat4ForEffect;
  7435. private _updateFloat4ForUniform;
  7436. private _updateMatrixForEffect;
  7437. private _updateMatrixForUniform;
  7438. private _updateVector3ForEffect;
  7439. private _updateVector3ForUniform;
  7440. private _updateVector4ForEffect;
  7441. private _updateVector4ForUniform;
  7442. private _updateColor3ForEffect;
  7443. private _updateColor3ForUniform;
  7444. private _updateColor4ForEffect;
  7445. private _updateColor4ForUniform;
  7446. /**
  7447. * Sets a sampler uniform on the effect.
  7448. * @param name Define the name of the sampler.
  7449. * @param texture Define the texture to set in the sampler
  7450. */
  7451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7452. /**
  7453. * Directly updates the value of the uniform in the cache AND on the GPU.
  7454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7455. * @param data Define the flattened data
  7456. */
  7457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7458. /**
  7459. * Binds this uniform buffer to an effect.
  7460. * @param effect Define the effect to bind the buffer to
  7461. * @param name Name of the uniform block in the shader.
  7462. */
  7463. bindToEffect(effect: Effect, name: string): void;
  7464. /**
  7465. * Disposes the uniform buffer.
  7466. */
  7467. dispose(): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Enum that determines the text-wrapping mode to use.
  7473. */
  7474. export enum InspectableType {
  7475. /**
  7476. * Checkbox for booleans
  7477. */
  7478. Checkbox = 0,
  7479. /**
  7480. * Sliders for numbers
  7481. */
  7482. Slider = 1,
  7483. /**
  7484. * Vector3
  7485. */
  7486. Vector3 = 2,
  7487. /**
  7488. * Quaternions
  7489. */
  7490. Quaternion = 3,
  7491. /**
  7492. * Color3
  7493. */
  7494. Color3 = 4,
  7495. /**
  7496. * String
  7497. */
  7498. String = 5
  7499. }
  7500. /**
  7501. * Interface used to define custom inspectable properties.
  7502. * This interface is used by the inspector to display custom property grids
  7503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7504. */
  7505. export interface IInspectable {
  7506. /**
  7507. * Gets the label to display
  7508. */
  7509. label: string;
  7510. /**
  7511. * Gets the name of the property to edit
  7512. */
  7513. propertyName: string;
  7514. /**
  7515. * Gets the type of the editor to use
  7516. */
  7517. type: InspectableType;
  7518. /**
  7519. * Gets the minimum value of the property when using in "slider" mode
  7520. */
  7521. min?: number;
  7522. /**
  7523. * Gets the maximum value of the property when using in "slider" mode
  7524. */
  7525. max?: number;
  7526. /**
  7527. * Gets the setp to use when using in "slider" mode
  7528. */
  7529. step?: number;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Class used to provide helper for timing
  7535. */
  7536. export class TimingTools {
  7537. /**
  7538. * Polyfill for setImmediate
  7539. * @param action defines the action to execute after the current execution block
  7540. */
  7541. static SetImmediate(action: () => void): void;
  7542. }
  7543. }
  7544. declare module BABYLON {
  7545. /**
  7546. * Class used to enable instatition of objects by class name
  7547. */
  7548. export class InstantiationTools {
  7549. /**
  7550. * Use this object to register external classes like custom textures or material
  7551. * to allow the laoders to instantiate them
  7552. */
  7553. static RegisteredExternalClasses: {
  7554. [key: string]: Object;
  7555. };
  7556. /**
  7557. * Tries to instantiate a new object from a given class name
  7558. * @param className defines the class name to instantiate
  7559. * @returns the new object or null if the system was not able to do the instantiation
  7560. */
  7561. static Instantiate(className: string): any;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Define options used to create a depth texture
  7567. */
  7568. export class DepthTextureCreationOptions {
  7569. /** Specifies whether or not a stencil should be allocated in the texture */
  7570. generateStencil?: boolean;
  7571. /** Specifies whether or not bilinear filtering is enable on the texture */
  7572. bilinearFiltering?: boolean;
  7573. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7574. comparisonFunction?: number;
  7575. /** Specifies if the created texture is a cube texture */
  7576. isCube?: boolean;
  7577. }
  7578. }
  7579. declare module BABYLON {
  7580. interface ThinEngine {
  7581. /**
  7582. * Creates a depth stencil cube texture.
  7583. * This is only available in WebGL 2.
  7584. * @param size The size of face edge in the cube texture.
  7585. * @param options The options defining the cube texture.
  7586. * @returns The cube texture
  7587. */
  7588. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7589. /**
  7590. * Creates a cube texture
  7591. * @param rootUrl defines the url where the files to load is located
  7592. * @param scene defines the current scene
  7593. * @param files defines the list of files to load (1 per face)
  7594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7595. * @param onLoad defines an optional callback raised when the texture is loaded
  7596. * @param onError defines an optional callback raised if there is an issue to load the texture
  7597. * @param format defines the format of the data
  7598. * @param forcedExtension defines the extension to use to pick the right loader
  7599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7603. * @returns the cube texture as an InternalTexture
  7604. */
  7605. 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>): InternalTexture;
  7606. /**
  7607. * Creates a cube texture
  7608. * @param rootUrl defines the url where the files to load is located
  7609. * @param scene defines the current scene
  7610. * @param files defines the list of files to load (1 per face)
  7611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7612. * @param onLoad defines an optional callback raised when the texture is loaded
  7613. * @param onError defines an optional callback raised if there is an issue to load the texture
  7614. * @param format defines the format of the data
  7615. * @param forcedExtension defines the extension to use to pick the right loader
  7616. * @returns the cube texture as an InternalTexture
  7617. */
  7618. 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;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @returns the cube texture as an InternalTexture
  7633. */
  7634. 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;
  7635. /** @hidden */
  7636. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7637. /** @hidden */
  7638. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7641. /** @hidden */
  7642. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /**
  7644. * @hidden
  7645. */
  7646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * Class for creating a cube texture
  7652. */
  7653. export class CubeTexture extends BaseTexture {
  7654. private _delayedOnLoad;
  7655. /**
  7656. * Observable triggered once the texture has been loaded.
  7657. */
  7658. onLoadObservable: Observable<CubeTexture>;
  7659. /**
  7660. * The url of the texture
  7661. */
  7662. url: string;
  7663. /**
  7664. * Gets or sets the center of the bounding box associated with the cube texture.
  7665. * It must define where the camera used to render the texture was set
  7666. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7667. */
  7668. boundingBoxPosition: Vector3;
  7669. private _boundingBoxSize;
  7670. /**
  7671. * Gets or sets the size of the bounding box associated with the cube texture
  7672. * When defined, the cubemap will switch to local mode
  7673. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7674. * @example https://www.babylonjs-playground.com/#RNASML
  7675. */
  7676. set boundingBoxSize(value: Vector3);
  7677. /**
  7678. * Returns the bounding box size
  7679. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7680. */
  7681. get boundingBoxSize(): Vector3;
  7682. protected _rotationY: number;
  7683. /**
  7684. * Sets texture matrix rotation angle around Y axis in radians.
  7685. */
  7686. set rotationY(value: number);
  7687. /**
  7688. * Gets texture matrix rotation angle around Y axis radians.
  7689. */
  7690. get rotationY(): number;
  7691. /**
  7692. * Are mip maps generated for this texture or not.
  7693. */
  7694. get noMipmap(): boolean;
  7695. private _noMipmap;
  7696. private _files;
  7697. protected _forcedExtension: Nullable<string>;
  7698. private _extensions;
  7699. private _textureMatrix;
  7700. private _format;
  7701. private _createPolynomials;
  7702. /** @hidden */
  7703. _prefiltered: boolean;
  7704. /**
  7705. * Creates a cube texture from an array of image urls
  7706. * @param files defines an array of image urls
  7707. * @param scene defines the hosting scene
  7708. * @param noMipmap specifies if mip maps are not used
  7709. * @returns a cube texture
  7710. */
  7711. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7712. /**
  7713. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7714. * @param url defines the url of the prefiltered texture
  7715. * @param scene defines the scene the texture is attached to
  7716. * @param forcedExtension defines the extension of the file if different from the url
  7717. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7718. * @return the prefiltered texture
  7719. */
  7720. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7721. /**
  7722. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7723. * as prefiltered data.
  7724. * @param rootUrl defines the url of the texture or the root name of the six images
  7725. * @param scene defines the scene the texture is attached to
  7726. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7727. * @param noMipmap defines if mipmaps should be created or not
  7728. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7729. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7730. * @param onError defines a callback triggered in case of error during load
  7731. * @param format defines the internal format to use for the texture once loaded
  7732. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7733. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7734. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7737. * @return the cube texture
  7738. */
  7739. 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);
  7740. /**
  7741. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7742. */
  7743. get isPrefiltered(): boolean;
  7744. /**
  7745. * Get the current class name of the texture useful for serialization or dynamic coding.
  7746. * @returns "CubeTexture"
  7747. */
  7748. getClassName(): string;
  7749. /**
  7750. * Update the url (and optional buffer) of this texture if url was null during construction.
  7751. * @param url the url of the texture
  7752. * @param forcedExtension defines the extension to use
  7753. * @param onLoad callback called when the texture is loaded (defaults to null)
  7754. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7755. */
  7756. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7757. /**
  7758. * Delays loading of the cube texture
  7759. * @param forcedExtension defines the extension to use
  7760. */
  7761. delayLoad(forcedExtension?: string): void;
  7762. /**
  7763. * Returns the reflection texture matrix
  7764. * @returns the reflection texture matrix
  7765. */
  7766. getReflectionTextureMatrix(): Matrix;
  7767. /**
  7768. * Sets the reflection texture matrix
  7769. * @param value Reflection texture matrix
  7770. */
  7771. setReflectionTextureMatrix(value: Matrix): void;
  7772. /**
  7773. * Parses text to create a cube texture
  7774. * @param parsedTexture define the serialized text to read from
  7775. * @param scene defines the hosting scene
  7776. * @param rootUrl defines the root url of the cube texture
  7777. * @returns a cube texture
  7778. */
  7779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7780. /**
  7781. * Makes a clone, or deep copy, of the cube texture
  7782. * @returns a new cube texture
  7783. */
  7784. clone(): CubeTexture;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Manages the defines for the Material
  7790. */
  7791. export class MaterialDefines {
  7792. /** @hidden */
  7793. protected _keys: string[];
  7794. private _isDirty;
  7795. /** @hidden */
  7796. _renderId: number;
  7797. /** @hidden */
  7798. _areLightsDirty: boolean;
  7799. /** @hidden */
  7800. _areLightsDisposed: boolean;
  7801. /** @hidden */
  7802. _areAttributesDirty: boolean;
  7803. /** @hidden */
  7804. _areTexturesDirty: boolean;
  7805. /** @hidden */
  7806. _areFresnelDirty: boolean;
  7807. /** @hidden */
  7808. _areMiscDirty: boolean;
  7809. /** @hidden */
  7810. _areImageProcessingDirty: boolean;
  7811. /** @hidden */
  7812. _normals: boolean;
  7813. /** @hidden */
  7814. _uvs: boolean;
  7815. /** @hidden */
  7816. _needNormals: boolean;
  7817. /** @hidden */
  7818. _needUVs: boolean;
  7819. [id: string]: any;
  7820. /**
  7821. * Specifies if the material needs to be re-calculated
  7822. */
  7823. get isDirty(): boolean;
  7824. /**
  7825. * Marks the material to indicate that it has been re-calculated
  7826. */
  7827. markAsProcessed(): void;
  7828. /**
  7829. * Marks the material to indicate that it needs to be re-calculated
  7830. */
  7831. markAsUnprocessed(): void;
  7832. /**
  7833. * Marks the material to indicate all of its defines need to be re-calculated
  7834. */
  7835. markAllAsDirty(): void;
  7836. /**
  7837. * Marks the material to indicate that image processing needs to be re-calculated
  7838. */
  7839. markAsImageProcessingDirty(): void;
  7840. /**
  7841. * Marks the material to indicate the lights need to be re-calculated
  7842. * @param disposed Defines whether the light is dirty due to dispose or not
  7843. */
  7844. markAsLightDirty(disposed?: boolean): void;
  7845. /**
  7846. * Marks the attribute state as changed
  7847. */
  7848. markAsAttributesDirty(): void;
  7849. /**
  7850. * Marks the texture state as changed
  7851. */
  7852. markAsTexturesDirty(): void;
  7853. /**
  7854. * Marks the fresnel state as changed
  7855. */
  7856. markAsFresnelDirty(): void;
  7857. /**
  7858. * Marks the misc state as changed
  7859. */
  7860. markAsMiscDirty(): void;
  7861. /**
  7862. * Rebuilds the material defines
  7863. */
  7864. rebuild(): void;
  7865. /**
  7866. * Specifies if two material defines are equal
  7867. * @param other - A material define instance to compare to
  7868. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7869. */
  7870. isEqual(other: MaterialDefines): boolean;
  7871. /**
  7872. * Clones this instance's defines to another instance
  7873. * @param other - material defines to clone values to
  7874. */
  7875. cloneTo(other: MaterialDefines): void;
  7876. /**
  7877. * Resets the material define values
  7878. */
  7879. reset(): void;
  7880. /**
  7881. * Converts the material define values to a string
  7882. * @returns - String of material define information
  7883. */
  7884. toString(): string;
  7885. }
  7886. }
  7887. declare module BABYLON {
  7888. /**
  7889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7891. * 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;
  7892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7893. */
  7894. export class ColorCurves {
  7895. private _dirty;
  7896. private _tempColor;
  7897. private _globalCurve;
  7898. private _highlightsCurve;
  7899. private _midtonesCurve;
  7900. private _shadowsCurve;
  7901. private _positiveCurve;
  7902. private _negativeCurve;
  7903. private _globalHue;
  7904. private _globalDensity;
  7905. private _globalSaturation;
  7906. private _globalExposure;
  7907. /**
  7908. * Gets the global Hue value.
  7909. * 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).
  7910. */
  7911. get globalHue(): number;
  7912. /**
  7913. * Sets the global Hue value.
  7914. * 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).
  7915. */
  7916. set globalHue(value: number);
  7917. /**
  7918. * Gets the global Density value.
  7919. * 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.
  7920. * Values less than zero provide a filter of opposite hue.
  7921. */
  7922. get globalDensity(): number;
  7923. /**
  7924. * Sets the global Density value.
  7925. * 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.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. set globalDensity(value: number);
  7929. /**
  7930. * Gets the global Saturation value.
  7931. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7932. */
  7933. get globalSaturation(): number;
  7934. /**
  7935. * Sets the global Saturation value.
  7936. * 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.
  7937. */
  7938. set globalSaturation(value: number);
  7939. /**
  7940. * Gets the global Exposure value.
  7941. * 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.
  7942. */
  7943. get globalExposure(): number;
  7944. /**
  7945. * Sets the global Exposure value.
  7946. * 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.
  7947. */
  7948. set globalExposure(value: number);
  7949. private _highlightsHue;
  7950. private _highlightsDensity;
  7951. private _highlightsSaturation;
  7952. private _highlightsExposure;
  7953. /**
  7954. * Gets the highlights Hue value.
  7955. * 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).
  7956. */
  7957. get highlightsHue(): number;
  7958. /**
  7959. * Sets the highlights Hue value.
  7960. * 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).
  7961. */
  7962. set highlightsHue(value: number);
  7963. /**
  7964. * Gets the highlights Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get highlightsDensity(): number;
  7969. /**
  7970. * Sets the highlights Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set highlightsDensity(value: number);
  7975. /**
  7976. * Gets the highlights Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. get highlightsSaturation(): number;
  7980. /**
  7981. * Sets the highlights Saturation value.
  7982. * 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.
  7983. */
  7984. set highlightsSaturation(value: number);
  7985. /**
  7986. * Gets the highlights Exposure value.
  7987. * 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.
  7988. */
  7989. get highlightsExposure(): number;
  7990. /**
  7991. * Sets the highlights Exposure value.
  7992. * 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.
  7993. */
  7994. set highlightsExposure(value: number);
  7995. private _midtonesHue;
  7996. private _midtonesDensity;
  7997. private _midtonesSaturation;
  7998. private _midtonesExposure;
  7999. /**
  8000. * Gets the midtones Hue value.
  8001. * 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).
  8002. */
  8003. get midtonesHue(): number;
  8004. /**
  8005. * Sets the midtones Hue value.
  8006. * 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).
  8007. */
  8008. set midtonesHue(value: number);
  8009. /**
  8010. * Gets the midtones Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get midtonesDensity(): number;
  8015. /**
  8016. * Sets the midtones Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set midtonesDensity(value: number);
  8021. /**
  8022. * Gets the midtones Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. get midtonesSaturation(): number;
  8026. /**
  8027. * Sets the midtones Saturation value.
  8028. * 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.
  8029. */
  8030. set midtonesSaturation(value: number);
  8031. /**
  8032. * Gets the midtones Exposure value.
  8033. * 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.
  8034. */
  8035. get midtonesExposure(): number;
  8036. /**
  8037. * Sets the midtones Exposure value.
  8038. * 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.
  8039. */
  8040. set midtonesExposure(value: number);
  8041. private _shadowsHue;
  8042. private _shadowsDensity;
  8043. private _shadowsSaturation;
  8044. private _shadowsExposure;
  8045. /**
  8046. * Gets the shadows Hue value.
  8047. * 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).
  8048. */
  8049. get shadowsHue(): number;
  8050. /**
  8051. * Sets the shadows Hue value.
  8052. * 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).
  8053. */
  8054. set shadowsHue(value: number);
  8055. /**
  8056. * Gets the shadows Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get shadowsDensity(): number;
  8061. /**
  8062. * Sets the shadows Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set shadowsDensity(value: number);
  8067. /**
  8068. * Gets the shadows Saturation value.
  8069. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8070. */
  8071. get shadowsSaturation(): number;
  8072. /**
  8073. * Sets the shadows Saturation value.
  8074. * 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.
  8075. */
  8076. set shadowsSaturation(value: number);
  8077. /**
  8078. * Gets the shadows Exposure value.
  8079. * 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.
  8080. */
  8081. get shadowsExposure(): number;
  8082. /**
  8083. * Sets the shadows Exposure value.
  8084. * 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.
  8085. */
  8086. set shadowsExposure(value: number);
  8087. /**
  8088. * Returns the class name
  8089. * @returns The class name
  8090. */
  8091. getClassName(): string;
  8092. /**
  8093. * Binds the color curves to the shader.
  8094. * @param colorCurves The color curve to bind
  8095. * @param effect The effect to bind to
  8096. * @param positiveUniform The positive uniform shader parameter
  8097. * @param neutralUniform The neutral uniform shader parameter
  8098. * @param negativeUniform The negative uniform shader parameter
  8099. */
  8100. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8101. /**
  8102. * Prepare the list of uniforms associated with the ColorCurves effects.
  8103. * @param uniformsList The list of uniforms used in the effect
  8104. */
  8105. static PrepareUniforms(uniformsList: string[]): void;
  8106. /**
  8107. * Returns color grading data based on a hue, density, saturation and exposure value.
  8108. * @param filterHue The hue of the color filter.
  8109. * @param filterDensity The density of the color filter.
  8110. * @param saturation The saturation.
  8111. * @param exposure The exposure.
  8112. * @param result The result data container.
  8113. */
  8114. private getColorGradingDataToRef;
  8115. /**
  8116. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8117. * @param value The input slider value in range [-100,100].
  8118. * @returns Adjusted value.
  8119. */
  8120. private static applyColorGradingSliderNonlinear;
  8121. /**
  8122. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8123. * @param hue The hue (H) input.
  8124. * @param saturation The saturation (S) input.
  8125. * @param brightness The brightness (B) input.
  8126. * @result An RGBA color represented as Vector4.
  8127. */
  8128. private static fromHSBToRef;
  8129. /**
  8130. * Returns a value clamped between min and max
  8131. * @param value The value to clamp
  8132. * @param min The minimum of value
  8133. * @param max The maximum of value
  8134. * @returns The clamped value.
  8135. */
  8136. private static clamp;
  8137. /**
  8138. * Clones the current color curve instance.
  8139. * @return The cloned curves
  8140. */
  8141. clone(): ColorCurves;
  8142. /**
  8143. * Serializes the current color curve instance to a json representation.
  8144. * @return a JSON representation
  8145. */
  8146. serialize(): any;
  8147. /**
  8148. * Parses the color curve from a json representation.
  8149. * @param source the JSON source to parse
  8150. * @return The parsed curves
  8151. */
  8152. static Parse(source: any): ColorCurves;
  8153. }
  8154. }
  8155. declare module BABYLON {
  8156. /**
  8157. * Interface to follow in your material defines to integrate easily the
  8158. * Image proccessing functions.
  8159. * @hidden
  8160. */
  8161. export interface IImageProcessingConfigurationDefines {
  8162. IMAGEPROCESSING: boolean;
  8163. VIGNETTE: boolean;
  8164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8165. VIGNETTEBLENDMODEOPAQUE: boolean;
  8166. TONEMAPPING: boolean;
  8167. TONEMAPPING_ACES: boolean;
  8168. CONTRAST: boolean;
  8169. EXPOSURE: boolean;
  8170. COLORCURVES: boolean;
  8171. COLORGRADING: boolean;
  8172. COLORGRADING3D: boolean;
  8173. SAMPLER3DGREENDEPTH: boolean;
  8174. SAMPLER3DBGRMAP: boolean;
  8175. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8176. }
  8177. /**
  8178. * @hidden
  8179. */
  8180. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. COLORCURVES: boolean;
  8189. COLORGRADING: boolean;
  8190. COLORGRADING3D: boolean;
  8191. SAMPLER3DGREENDEPTH: boolean;
  8192. SAMPLER3DBGRMAP: boolean;
  8193. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8194. EXPOSURE: boolean;
  8195. constructor();
  8196. }
  8197. /**
  8198. * This groups together the common properties used for image processing either in direct forward pass
  8199. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8200. * or not.
  8201. */
  8202. export class ImageProcessingConfiguration {
  8203. /**
  8204. * Default tone mapping applied in BabylonJS.
  8205. */
  8206. static readonly TONEMAPPING_STANDARD: number;
  8207. /**
  8208. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8209. * to other engines rendering to increase portability.
  8210. */
  8211. static readonly TONEMAPPING_ACES: number;
  8212. /**
  8213. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8214. */
  8215. colorCurves: Nullable<ColorCurves>;
  8216. private _colorCurvesEnabled;
  8217. /**
  8218. * Gets wether the color curves effect is enabled.
  8219. */
  8220. get colorCurvesEnabled(): boolean;
  8221. /**
  8222. * Sets wether the color curves effect is enabled.
  8223. */
  8224. set colorCurvesEnabled(value: boolean);
  8225. private _colorGradingTexture;
  8226. /**
  8227. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8228. */
  8229. get colorGradingTexture(): Nullable<BaseTexture>;
  8230. /**
  8231. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8232. */
  8233. set colorGradingTexture(value: Nullable<BaseTexture>);
  8234. private _colorGradingEnabled;
  8235. /**
  8236. * Gets wether the color grading effect is enabled.
  8237. */
  8238. get colorGradingEnabled(): boolean;
  8239. /**
  8240. * Sets wether the color grading effect is enabled.
  8241. */
  8242. set colorGradingEnabled(value: boolean);
  8243. private _colorGradingWithGreenDepth;
  8244. /**
  8245. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8246. */
  8247. get colorGradingWithGreenDepth(): boolean;
  8248. /**
  8249. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8250. */
  8251. set colorGradingWithGreenDepth(value: boolean);
  8252. private _colorGradingBGR;
  8253. /**
  8254. * Gets wether the color grading texture contains BGR values.
  8255. */
  8256. get colorGradingBGR(): boolean;
  8257. /**
  8258. * Sets wether the color grading texture contains BGR values.
  8259. */
  8260. set colorGradingBGR(value: boolean);
  8261. /** @hidden */
  8262. _exposure: number;
  8263. /**
  8264. * Gets the Exposure used in the effect.
  8265. */
  8266. get exposure(): number;
  8267. /**
  8268. * Sets the Exposure used in the effect.
  8269. */
  8270. set exposure(value: number);
  8271. private _toneMappingEnabled;
  8272. /**
  8273. * Gets wether the tone mapping effect is enabled.
  8274. */
  8275. get toneMappingEnabled(): boolean;
  8276. /**
  8277. * Sets wether the tone mapping effect is enabled.
  8278. */
  8279. set toneMappingEnabled(value: boolean);
  8280. private _toneMappingType;
  8281. /**
  8282. * Gets the type of tone mapping effect.
  8283. */
  8284. get toneMappingType(): number;
  8285. /**
  8286. * Sets the type of tone mapping effect used in BabylonJS.
  8287. */
  8288. set toneMappingType(value: number);
  8289. protected _contrast: number;
  8290. /**
  8291. * Gets the contrast used in the effect.
  8292. */
  8293. get contrast(): number;
  8294. /**
  8295. * Sets the contrast used in the effect.
  8296. */
  8297. set contrast(value: number);
  8298. /**
  8299. * Vignette stretch size.
  8300. */
  8301. vignetteStretch: number;
  8302. /**
  8303. * Vignette centre X Offset.
  8304. */
  8305. vignetteCentreX: number;
  8306. /**
  8307. * Vignette centre Y Offset.
  8308. */
  8309. vignetteCentreY: number;
  8310. /**
  8311. * Vignette weight or intensity of the vignette effect.
  8312. */
  8313. vignetteWeight: number;
  8314. /**
  8315. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8316. * if vignetteEnabled is set to true.
  8317. */
  8318. vignetteColor: Color4;
  8319. /**
  8320. * Camera field of view used by the Vignette effect.
  8321. */
  8322. vignetteCameraFov: number;
  8323. private _vignetteBlendMode;
  8324. /**
  8325. * Gets the vignette blend mode allowing different kind of effect.
  8326. */
  8327. get vignetteBlendMode(): number;
  8328. /**
  8329. * Sets the vignette blend mode allowing different kind of effect.
  8330. */
  8331. set vignetteBlendMode(value: number);
  8332. private _vignetteEnabled;
  8333. /**
  8334. * Gets wether the vignette effect is enabled.
  8335. */
  8336. get vignetteEnabled(): boolean;
  8337. /**
  8338. * Sets wether the vignette effect is enabled.
  8339. */
  8340. set vignetteEnabled(value: boolean);
  8341. private _applyByPostProcess;
  8342. /**
  8343. * Gets wether the image processing is applied through a post process or not.
  8344. */
  8345. get applyByPostProcess(): boolean;
  8346. /**
  8347. * Sets wether the image processing is applied through a post process or not.
  8348. */
  8349. set applyByPostProcess(value: boolean);
  8350. private _isEnabled;
  8351. /**
  8352. * Gets wether the image processing is enabled or not.
  8353. */
  8354. get isEnabled(): boolean;
  8355. /**
  8356. * Sets wether the image processing is enabled or not.
  8357. */
  8358. set isEnabled(value: boolean);
  8359. /**
  8360. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8361. */
  8362. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8363. /**
  8364. * Method called each time the image processing information changes requires to recompile the effect.
  8365. */
  8366. protected _updateParameters(): void;
  8367. /**
  8368. * Gets the current class name.
  8369. * @return "ImageProcessingConfiguration"
  8370. */
  8371. getClassName(): string;
  8372. /**
  8373. * Prepare the list of uniforms associated with the Image Processing effects.
  8374. * @param uniforms The list of uniforms used in the effect
  8375. * @param defines the list of defines currently in use
  8376. */
  8377. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8378. /**
  8379. * Prepare the list of samplers associated with the Image Processing effects.
  8380. * @param samplersList The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of defines associated to the shader.
  8386. * @param defines the list of defines to complete
  8387. * @param forPostProcess Define if we are currently in post process mode or not
  8388. */
  8389. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8390. /**
  8391. * Returns true if all the image processing information are ready.
  8392. * @returns True if ready, otherwise, false
  8393. */
  8394. isReady(): boolean;
  8395. /**
  8396. * Binds the image processing to the shader.
  8397. * @param effect The effect to bind to
  8398. * @param overrideAspectRatio Override the aspect ratio of the effect
  8399. */
  8400. bind(effect: Effect, overrideAspectRatio?: number): void;
  8401. /**
  8402. * Clones the current image processing instance.
  8403. * @return The cloned image processing
  8404. */
  8405. clone(): ImageProcessingConfiguration;
  8406. /**
  8407. * Serializes the current image processing instance to a json representation.
  8408. * @return a JSON representation
  8409. */
  8410. serialize(): any;
  8411. /**
  8412. * Parses the image processing from a json representation.
  8413. * @param source the JSON source to parse
  8414. * @return The parsed image processing
  8415. */
  8416. static Parse(source: any): ImageProcessingConfiguration;
  8417. private static _VIGNETTEMODE_MULTIPLY;
  8418. private static _VIGNETTEMODE_OPAQUE;
  8419. /**
  8420. * Used to apply the vignette as a mix with the pixel color.
  8421. */
  8422. static get VIGNETTEMODE_MULTIPLY(): number;
  8423. /**
  8424. * Used to apply the vignette as a replacement of the pixel color.
  8425. */
  8426. static get VIGNETTEMODE_OPAQUE(): number;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. /** @hidden */
  8431. export var postprocessVertexShader: {
  8432. name: string;
  8433. shader: string;
  8434. };
  8435. }
  8436. declare module BABYLON {
  8437. interface ThinEngine {
  8438. /**
  8439. * Creates a new render target texture
  8440. * @param size defines the size of the texture
  8441. * @param options defines the options used to create the texture
  8442. * @returns a new render target texture stored in an InternalTexture
  8443. */
  8444. createRenderTargetTexture(size: number | {
  8445. width: number;
  8446. height: number;
  8447. layers?: number;
  8448. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8449. /**
  8450. * Creates a depth stencil texture.
  8451. * This is only available in WebGL 2 or with the depth texture extension available.
  8452. * @param size The size of face edge in the texture.
  8453. * @param options The options defining the texture.
  8454. * @returns The texture
  8455. */
  8456. createDepthStencilTexture(size: number | {
  8457. width: number;
  8458. height: number;
  8459. layers?: number;
  8460. }, options: DepthTextureCreationOptions): InternalTexture;
  8461. /** @hidden */
  8462. _createDepthStencilTexture(size: number | {
  8463. width: number;
  8464. height: number;
  8465. layers?: number;
  8466. }, options: DepthTextureCreationOptions): InternalTexture;
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /** Defines supported spaces */
  8471. export enum Space {
  8472. /** Local (object) space */
  8473. LOCAL = 0,
  8474. /** World space */
  8475. WORLD = 1,
  8476. /** Bone space */
  8477. BONE = 2
  8478. }
  8479. /** Defines the 3 main axes */
  8480. export class Axis {
  8481. /** X axis */
  8482. static X: Vector3;
  8483. /** Y axis */
  8484. static Y: Vector3;
  8485. /** Z axis */
  8486. static Z: Vector3;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /**
  8491. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8492. * This is the base of the follow, arc rotate cameras and Free camera
  8493. * @see http://doc.babylonjs.com/features/cameras
  8494. */
  8495. export class TargetCamera extends Camera {
  8496. private static _RigCamTransformMatrix;
  8497. private static _TargetTransformMatrix;
  8498. private static _TargetFocalPoint;
  8499. /**
  8500. * Define the current direction the camera is moving to
  8501. */
  8502. cameraDirection: Vector3;
  8503. /**
  8504. * Define the current rotation the camera is rotating to
  8505. */
  8506. cameraRotation: Vector2;
  8507. /**
  8508. * When set, the up vector of the camera will be updated by the rotation of the camera
  8509. */
  8510. updateUpVectorFromRotation: boolean;
  8511. private _tmpQuaternion;
  8512. /**
  8513. * Define the current rotation of the camera
  8514. */
  8515. rotation: Vector3;
  8516. /**
  8517. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8518. */
  8519. rotationQuaternion: Quaternion;
  8520. /**
  8521. * Define the current speed of the camera
  8522. */
  8523. speed: number;
  8524. /**
  8525. * Add constraint to the camera to prevent it to move freely in all directions and
  8526. * around all axis.
  8527. */
  8528. noRotationConstraint: boolean;
  8529. /**
  8530. * Define the current target of the camera as an object or a position.
  8531. */
  8532. lockedTarget: any;
  8533. /** @hidden */
  8534. _currentTarget: Vector3;
  8535. /** @hidden */
  8536. _initialFocalDistance: number;
  8537. /** @hidden */
  8538. _viewMatrix: Matrix;
  8539. /** @hidden */
  8540. _camMatrix: Matrix;
  8541. /** @hidden */
  8542. _cameraTransformMatrix: Matrix;
  8543. /** @hidden */
  8544. _cameraRotationMatrix: Matrix;
  8545. /** @hidden */
  8546. _referencePoint: Vector3;
  8547. /** @hidden */
  8548. _transformedReferencePoint: Vector3;
  8549. protected _globalCurrentTarget: Vector3;
  8550. protected _globalCurrentUpVector: Vector3;
  8551. /** @hidden */
  8552. _reset: () => void;
  8553. private _defaultUp;
  8554. /**
  8555. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8556. * This is the base of the follow, arc rotate cameras and Free camera
  8557. * @see http://doc.babylonjs.com/features/cameras
  8558. * @param name Defines the name of the camera in the scene
  8559. * @param position Defines the start position of the camera in the scene
  8560. * @param scene Defines the scene the camera belongs to
  8561. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8562. */
  8563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8564. /**
  8565. * Gets the position in front of the camera at a given distance.
  8566. * @param distance The distance from the camera we want the position to be
  8567. * @returns the position
  8568. */
  8569. getFrontPosition(distance: number): Vector3;
  8570. /** @hidden */
  8571. _getLockedTargetPosition(): Nullable<Vector3>;
  8572. private _storedPosition;
  8573. private _storedRotation;
  8574. private _storedRotationQuaternion;
  8575. /**
  8576. * Store current camera state of the camera (fov, position, rotation, etc..)
  8577. * @returns the camera
  8578. */
  8579. storeState(): Camera;
  8580. /**
  8581. * Restored camera state. You must call storeState() first
  8582. * @returns whether it was successful or not
  8583. * @hidden
  8584. */
  8585. _restoreStateValues(): boolean;
  8586. /** @hidden */
  8587. _initCache(): void;
  8588. /** @hidden */
  8589. _updateCache(ignoreParentClass?: boolean): void;
  8590. /** @hidden */
  8591. _isSynchronizedViewMatrix(): boolean;
  8592. /** @hidden */
  8593. _computeLocalCameraSpeed(): number;
  8594. /**
  8595. * Defines the target the camera should look at.
  8596. * @param target Defines the new target as a Vector or a mesh
  8597. */
  8598. setTarget(target: Vector3): void;
  8599. /**
  8600. * Return the current target position of the camera. This value is expressed in local space.
  8601. * @returns the target position
  8602. */
  8603. getTarget(): Vector3;
  8604. /** @hidden */
  8605. _decideIfNeedsToMove(): boolean;
  8606. /** @hidden */
  8607. _updatePosition(): void;
  8608. /** @hidden */
  8609. _checkInputs(): void;
  8610. protected _updateCameraRotationMatrix(): void;
  8611. /**
  8612. * 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)
  8613. * @returns the current camera
  8614. */
  8615. private _rotateUpVectorWithCameraRotationMatrix;
  8616. private _cachedRotationZ;
  8617. private _cachedQuaternionRotationZ;
  8618. /** @hidden */
  8619. _getViewMatrix(): Matrix;
  8620. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8621. /**
  8622. * @hidden
  8623. */
  8624. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8625. /**
  8626. * @hidden
  8627. */
  8628. _updateRigCameras(): void;
  8629. private _getRigCamPositionAndTarget;
  8630. /**
  8631. * Gets the current object class name.
  8632. * @return the class name
  8633. */
  8634. getClassName(): string;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Gather the list of keyboard event types as constants.
  8640. */
  8641. export class KeyboardEventTypes {
  8642. /**
  8643. * The keydown event is fired when a key becomes active (pressed).
  8644. */
  8645. static readonly KEYDOWN: number;
  8646. /**
  8647. * The keyup event is fired when a key has been released.
  8648. */
  8649. static readonly KEYUP: number;
  8650. }
  8651. /**
  8652. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8653. */
  8654. export class KeyboardInfo {
  8655. /**
  8656. * Defines the type of event (KeyboardEventTypes)
  8657. */
  8658. type: number;
  8659. /**
  8660. * Defines the related dom event
  8661. */
  8662. event: KeyboardEvent;
  8663. /**
  8664. * Instantiates a new keyboard info.
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. * @param type Defines the type of event (KeyboardEventTypes)
  8667. * @param event Defines the related dom event
  8668. */
  8669. constructor(
  8670. /**
  8671. * Defines the type of event (KeyboardEventTypes)
  8672. */
  8673. type: number,
  8674. /**
  8675. * Defines the related dom event
  8676. */
  8677. event: KeyboardEvent);
  8678. }
  8679. /**
  8680. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8681. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8682. */
  8683. export class KeyboardInfoPre extends KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8694. */
  8695. skipOnPointerObservable: boolean;
  8696. /**
  8697. * Instantiates a new keyboard pre info.
  8698. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  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. }
  8713. declare module BABYLON {
  8714. /**
  8715. * Manage the keyboard inputs to control the movement of a free camera.
  8716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8717. */
  8718. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8719. /**
  8720. * Defines the camera the input is attached to.
  8721. */
  8722. camera: FreeCamera;
  8723. /**
  8724. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8725. */
  8726. keysUp: number[];
  8727. /**
  8728. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8729. */
  8730. keysDown: number[];
  8731. /**
  8732. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8733. */
  8734. keysLeft: number[];
  8735. /**
  8736. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8737. */
  8738. keysRight: number[];
  8739. private _keys;
  8740. private _onCanvasBlurObserver;
  8741. private _onKeyboardObserver;
  8742. private _engine;
  8743. private _scene;
  8744. /**
  8745. * Attach the input controls to a specific dom element to get the input from.
  8746. * @param element Defines the element the controls should be listened from
  8747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8748. */
  8749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8750. /**
  8751. * Detach the current controls from the specified dom element.
  8752. * @param element Defines the element to stop listening the inputs from
  8753. */
  8754. detachControl(element: Nullable<HTMLElement>): void;
  8755. /**
  8756. * Update the current camera state depending on the inputs that have been used this frame.
  8757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8758. */
  8759. checkInputs(): void;
  8760. /**
  8761. * Gets the class name of the current intput.
  8762. * @returns the class name
  8763. */
  8764. getClassName(): string;
  8765. /** @hidden */
  8766. _onLostFocus(): void;
  8767. /**
  8768. * Get the friendly name associated with the input class.
  8769. * @returns the input friendly name
  8770. */
  8771. getSimpleName(): string;
  8772. }
  8773. }
  8774. declare module BABYLON {
  8775. /**
  8776. * Interface describing all the common properties and methods a shadow light needs to implement.
  8777. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8778. * as well as binding the different shadow properties to the effects.
  8779. */
  8780. export interface IShadowLight extends Light {
  8781. /**
  8782. * The light id in the scene (used in scene.findLighById for instance)
  8783. */
  8784. id: string;
  8785. /**
  8786. * The position the shdow will be casted from.
  8787. */
  8788. position: Vector3;
  8789. /**
  8790. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8791. */
  8792. direction: Vector3;
  8793. /**
  8794. * The transformed position. Position of the light in world space taking parenting in account.
  8795. */
  8796. transformedPosition: Vector3;
  8797. /**
  8798. * The transformed direction. Direction of the light in world space taking parenting in account.
  8799. */
  8800. transformedDirection: Vector3;
  8801. /**
  8802. * The friendly name of the light in the scene.
  8803. */
  8804. name: string;
  8805. /**
  8806. * Defines the shadow projection clipping minimum z value.
  8807. */
  8808. shadowMinZ: number;
  8809. /**
  8810. * Defines the shadow projection clipping maximum z value.
  8811. */
  8812. shadowMaxZ: number;
  8813. /**
  8814. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8815. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8816. */
  8817. computeTransformedInformation(): boolean;
  8818. /**
  8819. * Gets the scene the light belongs to.
  8820. * @returns The scene
  8821. */
  8822. getScene(): Scene;
  8823. /**
  8824. * Callback defining a custom Projection Matrix Builder.
  8825. * This can be used to override the default projection matrix computation.
  8826. */
  8827. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8828. /**
  8829. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8830. * @param matrix The materix to updated with the projection information
  8831. * @param viewMatrix The transform matrix of the light
  8832. * @param renderList The list of mesh to render in the map
  8833. * @returns The current light
  8834. */
  8835. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8836. /**
  8837. * Gets the current depth scale used in ESM.
  8838. * @returns The scale
  8839. */
  8840. getDepthScale(): number;
  8841. /**
  8842. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8843. * @returns true if a cube texture needs to be use
  8844. */
  8845. needCube(): boolean;
  8846. /**
  8847. * Detects if the projection matrix requires to be recomputed this frame.
  8848. * @returns true if it requires to be recomputed otherwise, false.
  8849. */
  8850. needProjectionMatrixCompute(): boolean;
  8851. /**
  8852. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8853. */
  8854. forceProjectionMatrixCompute(): void;
  8855. /**
  8856. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8857. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8858. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8859. */
  8860. getShadowDirection(faceIndex?: number): Vector3;
  8861. /**
  8862. * Gets the minZ used for shadow according to both the scene and the light.
  8863. * @param activeCamera The camera we are returning the min for
  8864. * @returns the depth min z
  8865. */
  8866. getDepthMinZ(activeCamera: Camera): number;
  8867. /**
  8868. * Gets the maxZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the max for
  8870. * @returns the depth max z
  8871. */
  8872. getDepthMaxZ(activeCamera: Camera): number;
  8873. }
  8874. /**
  8875. * Base implementation IShadowLight
  8876. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8877. */
  8878. export abstract class ShadowLight extends Light implements IShadowLight {
  8879. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8880. protected _position: Vector3;
  8881. protected _setPosition(value: Vector3): void;
  8882. /**
  8883. * Sets the position the shadow will be casted from. Also use as the light position for both
  8884. * point and spot lights.
  8885. */
  8886. get position(): Vector3;
  8887. /**
  8888. * Sets the position the shadow will be casted from. Also use as the light position for both
  8889. * point and spot lights.
  8890. */
  8891. set position(value: Vector3);
  8892. protected _direction: Vector3;
  8893. protected _setDirection(value: Vector3): void;
  8894. /**
  8895. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8896. * Also use as the light direction on spot and directional lights.
  8897. */
  8898. get direction(): Vector3;
  8899. /**
  8900. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8901. * Also use as the light direction on spot and directional lights.
  8902. */
  8903. set direction(value: Vector3);
  8904. protected _shadowMinZ: number;
  8905. /**
  8906. * Gets the shadow projection clipping minimum z value.
  8907. */
  8908. get shadowMinZ(): number;
  8909. /**
  8910. * Sets the shadow projection clipping minimum z value.
  8911. */
  8912. set shadowMinZ(value: number);
  8913. protected _shadowMaxZ: number;
  8914. /**
  8915. * Sets the shadow projection clipping maximum z value.
  8916. */
  8917. get shadowMaxZ(): number;
  8918. /**
  8919. * Gets the shadow projection clipping maximum z value.
  8920. */
  8921. set shadowMaxZ(value: number);
  8922. /**
  8923. * Callback defining a custom Projection Matrix Builder.
  8924. * This can be used to override the default projection matrix computation.
  8925. */
  8926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8927. /**
  8928. * The transformed position. Position of the light in world space taking parenting in account.
  8929. */
  8930. transformedPosition: Vector3;
  8931. /**
  8932. * The transformed direction. Direction of the light in world space taking parenting in account.
  8933. */
  8934. transformedDirection: Vector3;
  8935. private _needProjectionMatrixCompute;
  8936. /**
  8937. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8938. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8939. */
  8940. computeTransformedInformation(): boolean;
  8941. /**
  8942. * Return the depth scale used for the shadow map.
  8943. * @returns the depth scale.
  8944. */
  8945. getDepthScale(): number;
  8946. /**
  8947. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8948. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8949. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8950. */
  8951. getShadowDirection(faceIndex?: number): Vector3;
  8952. /**
  8953. * Returns the ShadowLight absolute position in the World.
  8954. * @returns the position vector in world space
  8955. */
  8956. getAbsolutePosition(): Vector3;
  8957. /**
  8958. * Sets the ShadowLight direction toward the passed target.
  8959. * @param target The point to target in local space
  8960. * @returns the updated ShadowLight direction
  8961. */
  8962. setDirectionToTarget(target: Vector3): Vector3;
  8963. /**
  8964. * Returns the light rotation in euler definition.
  8965. * @returns the x y z rotation in local space.
  8966. */
  8967. getRotation(): Vector3;
  8968. /**
  8969. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8970. * @returns true if a cube texture needs to be use
  8971. */
  8972. needCube(): boolean;
  8973. /**
  8974. * Detects if the projection matrix requires to be recomputed this frame.
  8975. * @returns true if it requires to be recomputed otherwise, false.
  8976. */
  8977. needProjectionMatrixCompute(): boolean;
  8978. /**
  8979. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8980. */
  8981. forceProjectionMatrixCompute(): void;
  8982. /** @hidden */
  8983. _initCache(): void;
  8984. /** @hidden */
  8985. _isSynchronized(): boolean;
  8986. /**
  8987. * Computes the world matrix of the node
  8988. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8989. * @returns the world matrix
  8990. */
  8991. computeWorldMatrix(force?: boolean): Matrix;
  8992. /**
  8993. * Gets the minZ used for shadow according to both the scene and the light.
  8994. * @param activeCamera The camera we are returning the min for
  8995. * @returns the depth min z
  8996. */
  8997. getDepthMinZ(activeCamera: Camera): number;
  8998. /**
  8999. * Gets the maxZ used for shadow according to both the scene and the light.
  9000. * @param activeCamera The camera we are returning the max for
  9001. * @returns the depth max z
  9002. */
  9003. getDepthMaxZ(activeCamera: Camera): number;
  9004. /**
  9005. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9006. * @param matrix The materix to updated with the projection information
  9007. * @param viewMatrix The transform matrix of the light
  9008. * @param renderList The list of mesh to render in the map
  9009. * @returns The current light
  9010. */
  9011. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9012. }
  9013. }
  9014. declare module BABYLON {
  9015. /**
  9016. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9017. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9018. */
  9019. export class EffectFallbacks implements IEffectFallbacks {
  9020. private _defines;
  9021. private _currentRank;
  9022. private _maxRank;
  9023. private _mesh;
  9024. /**
  9025. * Removes the fallback from the bound mesh.
  9026. */
  9027. unBindMesh(): void;
  9028. /**
  9029. * Adds a fallback on the specified property.
  9030. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9031. * @param define The name of the define in the shader
  9032. */
  9033. addFallback(rank: number, define: string): void;
  9034. /**
  9035. * Sets the mesh to use CPU skinning when needing to fallback.
  9036. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9037. * @param mesh The mesh to use the fallbacks.
  9038. */
  9039. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9040. /**
  9041. * Checks to see if more fallbacks are still availible.
  9042. */
  9043. get hasMoreFallbacks(): boolean;
  9044. /**
  9045. * Removes the defines that should be removed when falling back.
  9046. * @param currentDefines defines the current define statements for the shader.
  9047. * @param effect defines the current effect we try to compile
  9048. * @returns The resulting defines with defines of the current rank removed.
  9049. */
  9050. reduce(currentDefines: string, effect: Effect): string;
  9051. }
  9052. }
  9053. declare module BABYLON {
  9054. /**
  9055. * "Static Class" containing the most commonly used helper while dealing with material for
  9056. * rendering purpose.
  9057. *
  9058. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9059. *
  9060. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9061. */
  9062. export class MaterialHelper {
  9063. /**
  9064. * Bind the current view position to an effect.
  9065. * @param effect The effect to be bound
  9066. * @param scene The scene the eyes position is used from
  9067. */
  9068. static BindEyePosition(effect: Effect, scene: Scene): void;
  9069. /**
  9070. * Helps preparing the defines values about the UVs in used in the effect.
  9071. * UVs are shared as much as we can accross channels in the shaders.
  9072. * @param texture The texture we are preparing the UVs for
  9073. * @param defines The defines to update
  9074. * @param key The channel key "diffuse", "specular"... used in the shader
  9075. */
  9076. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9077. /**
  9078. * Binds a texture matrix value to its corrsponding uniform
  9079. * @param texture The texture to bind the matrix for
  9080. * @param uniformBuffer The uniform buffer receivin the data
  9081. * @param key The channel key "diffuse", "specular"... used in the shader
  9082. */
  9083. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9084. /**
  9085. * Gets the current status of the fog (should it be enabled?)
  9086. * @param mesh defines the mesh to evaluate for fog support
  9087. * @param scene defines the hosting scene
  9088. * @returns true if fog must be enabled
  9089. */
  9090. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9091. /**
  9092. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9093. * @param mesh defines the current mesh
  9094. * @param scene defines the current scene
  9095. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9096. * @param pointsCloud defines if point cloud rendering has to be turned on
  9097. * @param fogEnabled defines if fog has to be turned on
  9098. * @param alphaTest defines if alpha testing has to be turned on
  9099. * @param defines defines the current list of defines
  9100. */
  9101. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9102. /**
  9103. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9104. * @param scene defines the current scene
  9105. * @param engine defines the current engine
  9106. * @param defines specifies the list of active defines
  9107. * @param useInstances defines if instances have to be turned on
  9108. * @param useClipPlane defines if clip plane have to be turned on
  9109. */
  9110. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9111. /**
  9112. * Prepares the defines for bones
  9113. * @param mesh The mesh containing the geometry data we will draw
  9114. * @param defines The defines to update
  9115. */
  9116. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9117. /**
  9118. * Prepares the defines for morph targets
  9119. * @param mesh The mesh containing the geometry data we will draw
  9120. * @param defines The defines to update
  9121. */
  9122. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9123. /**
  9124. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9125. * @param mesh The mesh containing the geometry data we will draw
  9126. * @param defines The defines to update
  9127. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9128. * @param useBones Precise whether bones should be used or not (override mesh info)
  9129. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9130. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9131. * @returns false if defines are considered not dirty and have not been checked
  9132. */
  9133. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9134. /**
  9135. * Prepares the defines related to multiview
  9136. * @param scene The scene we are intending to draw
  9137. * @param defines The defines to update
  9138. */
  9139. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9140. /**
  9141. * Prepares the defines related to the light information passed in parameter
  9142. * @param scene The scene we are intending to draw
  9143. * @param mesh The mesh the effect is compiling for
  9144. * @param light The light the effect is compiling for
  9145. * @param lightIndex The index of the light
  9146. * @param defines The defines to update
  9147. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9148. * @param state Defines the current state regarding what is needed (normals, etc...)
  9149. */
  9150. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9151. needNormals: boolean;
  9152. needRebuild: boolean;
  9153. shadowEnabled: boolean;
  9154. specularEnabled: boolean;
  9155. lightmapMode: boolean;
  9156. }): void;
  9157. /**
  9158. * Prepares the defines related to the light information passed in parameter
  9159. * @param scene The scene we are intending to draw
  9160. * @param mesh The mesh the effect is compiling for
  9161. * @param defines The defines to update
  9162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9163. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9164. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9165. * @returns true if normals will be required for the rest of the effect
  9166. */
  9167. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9170. * @param lightIndex defines the light index
  9171. * @param uniformsList The uniform list
  9172. * @param samplersList The sampler list
  9173. * @param projectedLightTexture defines if projected texture must be used
  9174. * @param uniformBuffersList defines an optional list of uniform buffers
  9175. */
  9176. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9177. /**
  9178. * Prepares the uniforms and samplers list to be used in the effect
  9179. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9180. * @param samplersList The sampler list
  9181. * @param defines The defines helping in the list generation
  9182. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9183. */
  9184. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9185. /**
  9186. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9187. * @param defines The defines to update while falling back
  9188. * @param fallbacks The authorized effect fallbacks
  9189. * @param maxSimultaneousLights The maximum number of lights allowed
  9190. * @param rank the current rank of the Effect
  9191. * @returns The newly affected rank
  9192. */
  9193. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9194. private static _TmpMorphInfluencers;
  9195. /**
  9196. * Prepares the list of attributes required for morph targets according to the effect defines.
  9197. * @param attribs The current list of supported attribs
  9198. * @param mesh The mesh to prepare the morph targets attributes for
  9199. * @param influencers The number of influencers
  9200. */
  9201. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9202. /**
  9203. * Prepares the list of attributes required for morph targets according to the effect defines.
  9204. * @param attribs The current list of supported attribs
  9205. * @param mesh The mesh to prepare the morph targets attributes for
  9206. * @param defines The current Defines of the effect
  9207. */
  9208. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9209. /**
  9210. * Prepares the list of attributes required for bones according to the effect defines.
  9211. * @param attribs The current list of supported attribs
  9212. * @param mesh The mesh to prepare the bones attributes for
  9213. * @param defines The current Defines of the effect
  9214. * @param fallbacks The current efffect fallback strategy
  9215. */
  9216. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9217. /**
  9218. * Check and prepare the list of attributes required for instances according to the effect defines.
  9219. * @param attribs The current list of supported attribs
  9220. * @param defines The current MaterialDefines of the effect
  9221. */
  9222. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9223. /**
  9224. * Add the list of attributes required for instances to the attribs array.
  9225. * @param attribs The current list of supported attribs
  9226. */
  9227. static PushAttributesForInstances(attribs: string[]): void;
  9228. /**
  9229. * Binds the light information to the effect.
  9230. * @param light The light containing the generator
  9231. * @param effect The effect we are binding the data to
  9232. * @param lightIndex The light index in the effect used to render
  9233. */
  9234. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9235. /**
  9236. * Binds the lights information from the scene to the effect for the given mesh.
  9237. * @param light Light to bind
  9238. * @param lightIndex Light index
  9239. * @param scene The scene where the light belongs to
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9243. */
  9244. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9245. /**
  9246. * Binds the lights information from the scene to the effect for the given mesh.
  9247. * @param scene The scene the lights belongs to
  9248. * @param mesh The mesh we are binding the information to render
  9249. * @param effect The effect we are binding the data to
  9250. * @param defines The generated defines for the effect
  9251. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9252. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9253. */
  9254. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9255. private static _tempFogColor;
  9256. /**
  9257. * Binds the fog information from the scene to the effect for the given mesh.
  9258. * @param scene The scene the lights belongs to
  9259. * @param mesh The mesh we are binding the information to render
  9260. * @param effect The effect we are binding the data to
  9261. * @param linearSpace Defines if the fog effect is applied in linear space
  9262. */
  9263. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9264. /**
  9265. * Binds the bones information from the mesh to the effect.
  9266. * @param mesh The mesh we are binding the information to render
  9267. * @param effect The effect we are binding the data to
  9268. */
  9269. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9270. /**
  9271. * Binds the morph targets information from the mesh to the effect.
  9272. * @param abstractMesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. */
  9275. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9276. /**
  9277. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9278. * @param defines The generated defines used in the effect
  9279. * @param effect The effect we are binding the data to
  9280. * @param scene The scene we are willing to render with logarithmic scale for
  9281. */
  9282. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9283. /**
  9284. * Binds the clip plane information from the scene to the effect.
  9285. * @param scene The scene the clip plane information are extracted from
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindClipPlane(effect: Effect, scene: Scene): void;
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var packingFunctions: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var clipPlaneFragmentDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var clipPlaneFragment: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var shadowMapPixelShader: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var bonesDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var morphTargetsVertexGlobalDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertexDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var helperFunctions: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneVertexDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var morphTargetsVertex: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var instancesVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var bonesVertex: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var clipPlaneVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapVertexShader: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var depthBoxBlurPixelShader: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /**
  9405. * Class representing a ray with position and direction
  9406. */
  9407. export class Ray {
  9408. /** origin point */
  9409. origin: Vector3;
  9410. /** direction */
  9411. direction: Vector3;
  9412. /** length of the ray */
  9413. length: number;
  9414. private static readonly TmpVector3;
  9415. private _tmpRay;
  9416. /**
  9417. * Creates a new ray
  9418. * @param origin origin point
  9419. * @param direction direction
  9420. * @param length length of the ray
  9421. */
  9422. constructor(
  9423. /** origin point */
  9424. origin: Vector3,
  9425. /** direction */
  9426. direction: Vector3,
  9427. /** length of the ray */
  9428. length?: number);
  9429. /**
  9430. * Checks if the ray intersects a box
  9431. * @param minimum bound of the box
  9432. * @param maximum bound of the box
  9433. * @param intersectionTreshold extra extend to be added to the box in all direction
  9434. * @returns if the box was hit
  9435. */
  9436. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9437. /**
  9438. * Checks if the ray intersects a box
  9439. * @param box the bounding box to check
  9440. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9441. * @returns if the box was hit
  9442. */
  9443. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9444. /**
  9445. * If the ray hits a sphere
  9446. * @param sphere the bounding sphere to check
  9447. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9448. * @returns true if it hits the sphere
  9449. */
  9450. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9451. /**
  9452. * If the ray hits a triange
  9453. * @param vertex0 triangle vertex
  9454. * @param vertex1 triangle vertex
  9455. * @param vertex2 triangle vertex
  9456. * @returns intersection information if hit
  9457. */
  9458. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9459. /**
  9460. * Checks if ray intersects a plane
  9461. * @param plane the plane to check
  9462. * @returns the distance away it was hit
  9463. */
  9464. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9465. /**
  9466. * Calculate the intercept of a ray on a given axis
  9467. * @param axis to check 'x' | 'y' | 'z'
  9468. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9469. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9470. */
  9471. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9472. /**
  9473. * Checks if ray intersects a mesh
  9474. * @param mesh the mesh to check
  9475. * @param fastCheck if only the bounding box should checked
  9476. * @returns picking info of the intersecton
  9477. */
  9478. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9479. /**
  9480. * Checks if ray intersects a mesh
  9481. * @param meshes the meshes to check
  9482. * @param fastCheck if only the bounding box should checked
  9483. * @param results array to store result in
  9484. * @returns Array of picking infos
  9485. */
  9486. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9487. private _comparePickingInfo;
  9488. private static smallnum;
  9489. private static rayl;
  9490. /**
  9491. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9492. * @param sega the first point of the segment to test the intersection against
  9493. * @param segb the second point of the segment to test the intersection against
  9494. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9495. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9496. */
  9497. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9498. /**
  9499. * Update the ray from viewport position
  9500. * @param x position
  9501. * @param y y position
  9502. * @param viewportWidth viewport width
  9503. * @param viewportHeight viewport height
  9504. * @param world world matrix
  9505. * @param view view matrix
  9506. * @param projection projection matrix
  9507. * @returns this ray updated
  9508. */
  9509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9510. /**
  9511. * Creates a ray with origin and direction of 0,0,0
  9512. * @returns the new ray
  9513. */
  9514. static Zero(): Ray;
  9515. /**
  9516. * Creates a new ray from screen space and viewport
  9517. * @param x position
  9518. * @param y y position
  9519. * @param viewportWidth viewport width
  9520. * @param viewportHeight viewport height
  9521. * @param world world matrix
  9522. * @param view view matrix
  9523. * @param projection projection matrix
  9524. * @returns new ray
  9525. */
  9526. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9527. /**
  9528. * 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
  9529. * transformed to the given world matrix.
  9530. * @param origin The origin point
  9531. * @param end The end point
  9532. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9533. * @returns the new ray
  9534. */
  9535. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9536. /**
  9537. * Transforms a ray by a matrix
  9538. * @param ray ray to transform
  9539. * @param matrix matrix to apply
  9540. * @returns the resulting new ray
  9541. */
  9542. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9543. /**
  9544. * Transforms a ray by a matrix
  9545. * @param ray ray to transform
  9546. * @param matrix matrix to apply
  9547. * @param result ray to store result in
  9548. */
  9549. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9550. /**
  9551. * Unproject a ray from screen space to object space
  9552. * @param sourceX defines the screen space x coordinate to use
  9553. * @param sourceY defines the screen space y coordinate to use
  9554. * @param viewportWidth defines the current width of the viewport
  9555. * @param viewportHeight defines the current height of the viewport
  9556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9557. * @param view defines the view matrix to use
  9558. * @param projection defines the projection matrix to use
  9559. */
  9560. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9561. }
  9562. /**
  9563. * Type used to define predicate used to select faces when a mesh intersection is detected
  9564. */
  9565. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9566. interface Scene {
  9567. /** @hidden */
  9568. _tempPickingRay: Nullable<Ray>;
  9569. /** @hidden */
  9570. _cachedRayForTransform: Ray;
  9571. /** @hidden */
  9572. _pickWithRayInverseMatrix: Matrix;
  9573. /** @hidden */
  9574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9575. /** @hidden */
  9576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9577. }
  9578. }
  9579. declare module BABYLON {
  9580. /**
  9581. * Groups all the scene component constants in one place to ease maintenance.
  9582. * @hidden
  9583. */
  9584. export class SceneComponentConstants {
  9585. static readonly NAME_EFFECTLAYER: string;
  9586. static readonly NAME_LAYER: string;
  9587. static readonly NAME_LENSFLARESYSTEM: string;
  9588. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9589. static readonly NAME_PARTICLESYSTEM: string;
  9590. static readonly NAME_GAMEPAD: string;
  9591. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9592. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9593. static readonly NAME_DEPTHRENDERER: string;
  9594. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9595. static readonly NAME_SPRITE: string;
  9596. static readonly NAME_OUTLINERENDERER: string;
  9597. static readonly NAME_PROCEDURALTEXTURE: string;
  9598. static readonly NAME_SHADOWGENERATOR: string;
  9599. static readonly NAME_OCTREE: string;
  9600. static readonly NAME_PHYSICSENGINE: string;
  9601. static readonly NAME_AUDIO: string;
  9602. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9603. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9604. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9605. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9606. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9607. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9608. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9609. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9610. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9611. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9612. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9613. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9614. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9615. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9616. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9617. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9618. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9619. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9620. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9621. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9622. static readonly STEP_AFTERRENDER_AUDIO: number;
  9623. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9624. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9625. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9626. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9627. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9628. static readonly STEP_POINTERMOVE_SPRITE: number;
  9629. static readonly STEP_POINTERDOWN_SPRITE: number;
  9630. static readonly STEP_POINTERUP_SPRITE: number;
  9631. }
  9632. /**
  9633. * This represents a scene component.
  9634. *
  9635. * This is used to decouple the dependency the scene is having on the different workloads like
  9636. * layers, post processes...
  9637. */
  9638. export interface ISceneComponent {
  9639. /**
  9640. * The name of the component. Each component must have a unique name.
  9641. */
  9642. name: string;
  9643. /**
  9644. * The scene the component belongs to.
  9645. */
  9646. scene: Scene;
  9647. /**
  9648. * Register the component to one instance of a scene.
  9649. */
  9650. register(): void;
  9651. /**
  9652. * Rebuilds the elements related to this component in case of
  9653. * context lost for instance.
  9654. */
  9655. rebuild(): void;
  9656. /**
  9657. * Disposes the component and the associated ressources.
  9658. */
  9659. dispose(): void;
  9660. }
  9661. /**
  9662. * This represents a SERIALIZABLE scene component.
  9663. *
  9664. * This extends Scene Component to add Serialization methods on top.
  9665. */
  9666. export interface ISceneSerializableComponent extends ISceneComponent {
  9667. /**
  9668. * Adds all the elements from the container to the scene
  9669. * @param container the container holding the elements
  9670. */
  9671. addFromContainer(container: AbstractScene): void;
  9672. /**
  9673. * Removes all the elements in the container from the scene
  9674. * @param container contains the elements to remove
  9675. * @param dispose if the removed element should be disposed (default: false)
  9676. */
  9677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9678. /**
  9679. * Serializes the component data to the specified json object
  9680. * @param serializationObject The object to serialize to
  9681. */
  9682. serialize(serializationObject: any): void;
  9683. }
  9684. /**
  9685. * Strong typing of a Mesh related stage step action
  9686. */
  9687. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9688. /**
  9689. * Strong typing of a Evaluate Sub Mesh related stage step action
  9690. */
  9691. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9692. /**
  9693. * Strong typing of a Active Mesh related stage step action
  9694. */
  9695. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9696. /**
  9697. * Strong typing of a Camera related stage step action
  9698. */
  9699. export type CameraStageAction = (camera: Camera) => void;
  9700. /**
  9701. * Strong typing of a Camera Frame buffer related stage step action
  9702. */
  9703. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9704. /**
  9705. * Strong typing of a Render Target related stage step action
  9706. */
  9707. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9708. /**
  9709. * Strong typing of a RenderingGroup related stage step action
  9710. */
  9711. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9712. /**
  9713. * Strong typing of a Mesh Render related stage step action
  9714. */
  9715. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9716. /**
  9717. * Strong typing of a simple stage step action
  9718. */
  9719. export type SimpleStageAction = () => void;
  9720. /**
  9721. * Strong typing of a render target action.
  9722. */
  9723. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9724. /**
  9725. * Strong typing of a pointer move action.
  9726. */
  9727. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9728. /**
  9729. * Strong typing of a pointer up/down action.
  9730. */
  9731. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9732. /**
  9733. * Representation of a stage in the scene (Basically a list of ordered steps)
  9734. * @hidden
  9735. */
  9736. export class Stage<T extends Function> extends Array<{
  9737. index: number;
  9738. component: ISceneComponent;
  9739. action: T;
  9740. }> {
  9741. /**
  9742. * Hide ctor from the rest of the world.
  9743. * @param items The items to add.
  9744. */
  9745. private constructor();
  9746. /**
  9747. * Creates a new Stage.
  9748. * @returns A new instance of a Stage
  9749. */
  9750. static Create<T extends Function>(): Stage<T>;
  9751. /**
  9752. * Registers a step in an ordered way in the targeted stage.
  9753. * @param index Defines the position to register the step in
  9754. * @param component Defines the component attached to the step
  9755. * @param action Defines the action to launch during the step
  9756. */
  9757. registerStep(index: number, component: ISceneComponent, action: T): void;
  9758. /**
  9759. * Clears all the steps from the stage.
  9760. */
  9761. clear(): void;
  9762. }
  9763. }
  9764. declare module BABYLON {
  9765. interface Scene {
  9766. /** @hidden */
  9767. _pointerOverSprite: Nullable<Sprite>;
  9768. /** @hidden */
  9769. _pickedDownSprite: Nullable<Sprite>;
  9770. /** @hidden */
  9771. _tempSpritePickingRay: Nullable<Ray>;
  9772. /**
  9773. * All of the sprite managers added to this scene
  9774. * @see http://doc.babylonjs.com/babylon101/sprites
  9775. */
  9776. spriteManagers: Array<ISpriteManager>;
  9777. /**
  9778. * An event triggered when sprites rendering is about to start
  9779. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9780. */
  9781. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9782. /**
  9783. * An event triggered when sprites rendering is done
  9784. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9785. */
  9786. onAfterSpritesRenderingObservable: Observable<Scene>;
  9787. /** @hidden */
  9788. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9789. /** Launch a ray to try to pick a sprite in the scene
  9790. * @param x position on screen
  9791. * @param y position on screen
  9792. * @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
  9793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9794. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9795. * @returns a PickingInfo
  9796. */
  9797. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9798. /** Use the given ray to pick a sprite in the scene
  9799. * @param ray The ray (in world space) to use to pick meshes
  9800. * @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
  9801. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9802. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9803. * @returns a PickingInfo
  9804. */
  9805. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9806. /** @hidden */
  9807. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9808. /** Launch a ray to try to pick sprites 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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9813. * @returns a PickingInfo array
  9814. */
  9815. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9816. /** Use the given ray to pick sprites in the scene
  9817. * @param ray The ray (in world space) to use to pick meshes
  9818. * @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
  9819. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9820. * @returns a PickingInfo array
  9821. */
  9822. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9823. /**
  9824. * Force the sprite under the pointer
  9825. * @param sprite defines the sprite to use
  9826. */
  9827. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9828. /**
  9829. * Gets the sprite under the pointer
  9830. * @returns a Sprite or null if no sprite is under the pointer
  9831. */
  9832. getPointerOverSprite(): Nullable<Sprite>;
  9833. }
  9834. /**
  9835. * Defines the sprite scene component responsible to manage sprites
  9836. * in a given scene.
  9837. */
  9838. export class SpriteSceneComponent implements ISceneComponent {
  9839. /**
  9840. * The component name helpfull to identify the component in the list of scene components.
  9841. */
  9842. readonly name: string;
  9843. /**
  9844. * The scene the component belongs to.
  9845. */
  9846. scene: Scene;
  9847. /** @hidden */
  9848. private _spritePredicate;
  9849. /**
  9850. * Creates a new instance of the component for the given scene
  9851. * @param scene Defines the scene to register the component in
  9852. */
  9853. constructor(scene: Scene);
  9854. /**
  9855. * Registers the component in a given scene
  9856. */
  9857. register(): void;
  9858. /**
  9859. * Rebuilds the elements related to this component in case of
  9860. * context lost for instance.
  9861. */
  9862. rebuild(): void;
  9863. /**
  9864. * Disposes the component and the associated ressources.
  9865. */
  9866. dispose(): void;
  9867. private _pickSpriteButKeepRay;
  9868. private _pointerMove;
  9869. private _pointerDown;
  9870. private _pointerUp;
  9871. }
  9872. }
  9873. declare module BABYLON {
  9874. /** @hidden */
  9875. export var fogFragmentDeclaration: {
  9876. name: string;
  9877. shader: string;
  9878. };
  9879. }
  9880. declare module BABYLON {
  9881. /** @hidden */
  9882. export var fogFragment: {
  9883. name: string;
  9884. shader: string;
  9885. };
  9886. }
  9887. declare module BABYLON {
  9888. /** @hidden */
  9889. export var spritesPixelShader: {
  9890. name: string;
  9891. shader: string;
  9892. };
  9893. }
  9894. declare module BABYLON {
  9895. /** @hidden */
  9896. export var fogVertexDeclaration: {
  9897. name: string;
  9898. shader: string;
  9899. };
  9900. }
  9901. declare module BABYLON {
  9902. /** @hidden */
  9903. export var spritesVertexShader: {
  9904. name: string;
  9905. shader: string;
  9906. };
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9911. */
  9912. export interface ISpriteManager extends IDisposable {
  9913. /**
  9914. * Restricts the camera to viewing objects with the same layerMask.
  9915. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9916. */
  9917. layerMask: number;
  9918. /**
  9919. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9920. */
  9921. isPickable: boolean;
  9922. /**
  9923. * Specifies the rendering group id for this mesh (0 by default)
  9924. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9925. */
  9926. renderingGroupId: number;
  9927. /**
  9928. * Defines the list of sprites managed by the manager.
  9929. */
  9930. sprites: Array<Sprite>;
  9931. /**
  9932. * Tests the intersection of a sprite with a specific ray.
  9933. * @param ray The ray we are sending to test the collision
  9934. * @param camera The camera space we are sending rays in
  9935. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9936. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9937. * @returns picking info or null.
  9938. */
  9939. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9940. /**
  9941. * Intersects the sprites with a ray
  9942. * @param ray defines the ray to intersect with
  9943. * @param camera defines the current active camera
  9944. * @param predicate defines a predicate used to select candidate sprites
  9945. * @returns null if no hit or a PickingInfo array
  9946. */
  9947. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9948. /**
  9949. * Renders the list of sprites on screen.
  9950. */
  9951. render(): void;
  9952. }
  9953. /**
  9954. * Class used to manage multiple sprites on the same spritesheet
  9955. * @see http://doc.babylonjs.com/babylon101/sprites
  9956. */
  9957. export class SpriteManager implements ISpriteManager {
  9958. /** defines the manager's name */
  9959. name: string;
  9960. /** Gets the list of sprites */
  9961. sprites: Sprite[];
  9962. /** Gets or sets the rendering group id (0 by default) */
  9963. renderingGroupId: number;
  9964. /** Gets or sets camera layer mask */
  9965. layerMask: number;
  9966. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9967. fogEnabled: boolean;
  9968. /** Gets or sets a boolean indicating if the sprites are pickable */
  9969. isPickable: boolean;
  9970. /** Defines the default width of a cell in the spritesheet */
  9971. cellWidth: number;
  9972. /** Defines the default height of a cell in the spritesheet */
  9973. cellHeight: number;
  9974. /** Associative array from JSON sprite data file */
  9975. private _cellData;
  9976. /** Array of sprite names from JSON sprite data file */
  9977. private _spriteMap;
  9978. /** True when packed cell data from JSON file is ready*/
  9979. private _packedAndReady;
  9980. /**
  9981. * An event triggered when the manager is disposed.
  9982. */
  9983. onDisposeObservable: Observable<SpriteManager>;
  9984. private _onDisposeObserver;
  9985. /**
  9986. * Callback called when the manager is disposed
  9987. */
  9988. set onDispose(callback: () => void);
  9989. private _capacity;
  9990. private _fromPacked;
  9991. private _spriteTexture;
  9992. private _epsilon;
  9993. private _scene;
  9994. private _vertexData;
  9995. private _buffer;
  9996. private _vertexBuffers;
  9997. private _indexBuffer;
  9998. private _effectBase;
  9999. private _effectFog;
  10000. /**
  10001. * Gets or sets the spritesheet texture
  10002. */
  10003. get texture(): Texture;
  10004. set texture(value: Texture);
  10005. private _blendMode;
  10006. /**
  10007. * Blend mode use to render the particle, it can be any of
  10008. * the static Constants.ALPHA_x properties provided in this class.
  10009. * Default value is Constants.ALPHA_COMBINE
  10010. */
  10011. get blendMode(): number;
  10012. set blendMode(blendMode: number);
  10013. /** Disables writing to the depth buffer when rendering the sprites.
  10014. * It can be handy to disable depth writing when using textures without alpha channel
  10015. * and setting some specific blend modes.
  10016. */
  10017. disableDepthWrite: boolean;
  10018. /**
  10019. * Creates a new sprite manager
  10020. * @param name defines the manager's name
  10021. * @param imgUrl defines the sprite sheet url
  10022. * @param capacity defines the maximum allowed number of sprites
  10023. * @param cellSize defines the size of a sprite cell
  10024. * @param scene defines the hosting scene
  10025. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10026. * @param samplingMode defines the smapling mode to use with spritesheet
  10027. * @param fromPacked set to false; do not alter
  10028. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10029. */
  10030. constructor(
  10031. /** defines the manager's name */
  10032. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10033. private _makePacked;
  10034. private _appendSpriteVertex;
  10035. /**
  10036. * Intersects the sprites with a ray
  10037. * @param ray defines the ray to intersect with
  10038. * @param camera defines the current active camera
  10039. * @param predicate defines a predicate used to select candidate sprites
  10040. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10041. * @returns null if no hit or a PickingInfo
  10042. */
  10043. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10044. /**
  10045. * Intersects the sprites with a ray
  10046. * @param ray defines the ray to intersect with
  10047. * @param camera defines the current active camera
  10048. * @param predicate defines a predicate used to select candidate sprites
  10049. * @returns null if no hit or a PickingInfo array
  10050. */
  10051. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10052. /**
  10053. * Render all child sprites
  10054. */
  10055. render(): void;
  10056. /**
  10057. * Release associated resources
  10058. */
  10059. dispose(): void;
  10060. }
  10061. }
  10062. declare module BABYLON {
  10063. /** Interface used by value gradients (color, factor, ...) */
  10064. export interface IValueGradient {
  10065. /**
  10066. * Gets or sets the gradient value (between 0 and 1)
  10067. */
  10068. gradient: number;
  10069. }
  10070. /** Class used to store color4 gradient */
  10071. export class ColorGradient implements IValueGradient {
  10072. /**
  10073. * Gets or sets the gradient value (between 0 and 1)
  10074. */
  10075. gradient: number;
  10076. /**
  10077. * Gets or sets first associated color
  10078. */
  10079. color1: Color4;
  10080. /**
  10081. * Gets or sets second associated color
  10082. */
  10083. color2?: Color4;
  10084. /**
  10085. * Will get a color picked randomly between color1 and color2.
  10086. * If color2 is undefined then color1 will be used
  10087. * @param result defines the target Color4 to store the result in
  10088. */
  10089. getColorToRef(result: Color4): void;
  10090. }
  10091. /** Class used to store color 3 gradient */
  10092. export class Color3Gradient implements IValueGradient {
  10093. /**
  10094. * Gets or sets the gradient value (between 0 and 1)
  10095. */
  10096. gradient: number;
  10097. /**
  10098. * Gets or sets the associated color
  10099. */
  10100. color: Color3;
  10101. }
  10102. /** Class used to store factor gradient */
  10103. export class FactorGradient implements IValueGradient {
  10104. /**
  10105. * Gets or sets the gradient value (between 0 and 1)
  10106. */
  10107. gradient: number;
  10108. /**
  10109. * Gets or sets first associated factor
  10110. */
  10111. factor1: number;
  10112. /**
  10113. * Gets or sets second associated factor
  10114. */
  10115. factor2?: number;
  10116. /**
  10117. * Will get a number picked randomly between factor1 and factor2.
  10118. * If factor2 is undefined then factor1 will be used
  10119. * @returns the picked number
  10120. */
  10121. getFactor(): number;
  10122. }
  10123. /**
  10124. * Helper used to simplify some generic gradient tasks
  10125. */
  10126. export class GradientHelper {
  10127. /**
  10128. * Gets the current gradient from an array of IValueGradient
  10129. * @param ratio defines the current ratio to get
  10130. * @param gradients defines the array of IValueGradient
  10131. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10132. */
  10133. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10134. }
  10135. }
  10136. declare module BABYLON {
  10137. /**
  10138. * Interface for the size containing width and height
  10139. */
  10140. export interface ISize {
  10141. /**
  10142. * Width
  10143. */
  10144. width: number;
  10145. /**
  10146. * Heighht
  10147. */
  10148. height: number;
  10149. }
  10150. /**
  10151. * Size containing widht and height
  10152. */
  10153. export class Size implements ISize {
  10154. /**
  10155. * Width
  10156. */
  10157. width: number;
  10158. /**
  10159. * Height
  10160. */
  10161. height: number;
  10162. /**
  10163. * Creates a Size object from the given width and height (floats).
  10164. * @param width width of the new size
  10165. * @param height height of the new size
  10166. */
  10167. constructor(width: number, height: number);
  10168. /**
  10169. * Returns a string with the Size width and height
  10170. * @returns a string with the Size width and height
  10171. */
  10172. toString(): string;
  10173. /**
  10174. * "Size"
  10175. * @returns the string "Size"
  10176. */
  10177. getClassName(): string;
  10178. /**
  10179. * Returns the Size hash code.
  10180. * @returns a hash code for a unique width and height
  10181. */
  10182. getHashCode(): number;
  10183. /**
  10184. * Updates the current size from the given one.
  10185. * @param src the given size
  10186. */
  10187. copyFrom(src: Size): void;
  10188. /**
  10189. * Updates in place the current Size from the given floats.
  10190. * @param width width of the new size
  10191. * @param height height of the new size
  10192. * @returns the updated Size.
  10193. */
  10194. copyFromFloats(width: number, height: number): Size;
  10195. /**
  10196. * Updates in place the current Size from the given floats.
  10197. * @param width width to set
  10198. * @param height height to set
  10199. * @returns the updated Size.
  10200. */
  10201. set(width: number, height: number): Size;
  10202. /**
  10203. * Multiplies the width and height by numbers
  10204. * @param w factor to multiple the width by
  10205. * @param h factor to multiple the height by
  10206. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10207. */
  10208. multiplyByFloats(w: number, h: number): Size;
  10209. /**
  10210. * Clones the size
  10211. * @returns a new Size copied from the given one.
  10212. */
  10213. clone(): Size;
  10214. /**
  10215. * True if the current Size and the given one width and height are strictly equal.
  10216. * @param other the other size to compare against
  10217. * @returns True if the current Size and the given one width and height are strictly equal.
  10218. */
  10219. equals(other: Size): boolean;
  10220. /**
  10221. * The surface of the Size : width * height (float).
  10222. */
  10223. get surface(): number;
  10224. /**
  10225. * Create a new size of zero
  10226. * @returns a new Size set to (0.0, 0.0)
  10227. */
  10228. static Zero(): Size;
  10229. /**
  10230. * Sums the width and height of two sizes
  10231. * @param otherSize size to add to this size
  10232. * @returns a new Size set as the addition result of the current Size and the given one.
  10233. */
  10234. add(otherSize: Size): Size;
  10235. /**
  10236. * Subtracts the width and height of two
  10237. * @param otherSize size to subtract to this size
  10238. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10239. */
  10240. subtract(otherSize: Size): Size;
  10241. /**
  10242. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10243. * @param start starting size to lerp between
  10244. * @param end end size to lerp between
  10245. * @param amount amount to lerp between the start and end values
  10246. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10247. */
  10248. static Lerp(start: Size, end: Size, amount: number): Size;
  10249. }
  10250. }
  10251. declare module BABYLON {
  10252. interface ThinEngine {
  10253. /**
  10254. * Creates a dynamic texture
  10255. * @param width defines the width of the texture
  10256. * @param height defines the height of the texture
  10257. * @param generateMipMaps defines if the engine should generate the mip levels
  10258. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10259. * @returns the dynamic texture inside an InternalTexture
  10260. */
  10261. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10262. /**
  10263. * Update the content of a dynamic texture
  10264. * @param texture defines the texture to update
  10265. * @param canvas defines the canvas containing the source
  10266. * @param invertY defines if data must be stored with Y axis inverted
  10267. * @param premulAlpha defines if alpha is stored as premultiplied
  10268. * @param format defines the format of the data
  10269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10270. */
  10271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Helper class used to generate a canvas to manipulate images
  10277. */
  10278. export class CanvasGenerator {
  10279. /**
  10280. * Create a new canvas (or offscreen canvas depending on the context)
  10281. * @param width defines the expected width
  10282. * @param height defines the expected height
  10283. * @return a new canvas or offscreen canvas
  10284. */
  10285. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. /**
  10290. * A class extending Texture allowing drawing on a texture
  10291. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10292. */
  10293. export class DynamicTexture extends Texture {
  10294. private _generateMipMaps;
  10295. private _canvas;
  10296. private _context;
  10297. private _engine;
  10298. /**
  10299. * Creates a DynamicTexture
  10300. * @param name defines the name of the texture
  10301. * @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
  10302. * @param scene defines the scene where you want the texture
  10303. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10305. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10306. */
  10307. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10308. /**
  10309. * Get the current class name of the texture useful for serialization or dynamic coding.
  10310. * @returns "DynamicTexture"
  10311. */
  10312. getClassName(): string;
  10313. /**
  10314. * Gets the current state of canRescale
  10315. */
  10316. get canRescale(): boolean;
  10317. private _recreate;
  10318. /**
  10319. * Scales the texture
  10320. * @param ratio the scale factor to apply to both width and height
  10321. */
  10322. scale(ratio: number): void;
  10323. /**
  10324. * Resizes the texture
  10325. * @param width the new width
  10326. * @param height the new height
  10327. */
  10328. scaleTo(width: number, height: number): void;
  10329. /**
  10330. * Gets the context of the canvas used by the texture
  10331. * @returns the canvas context of the dynamic texture
  10332. */
  10333. getContext(): CanvasRenderingContext2D;
  10334. /**
  10335. * Clears the texture
  10336. */
  10337. clear(): void;
  10338. /**
  10339. * Updates the texture
  10340. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10341. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10342. */
  10343. update(invertY?: boolean, premulAlpha?: boolean): void;
  10344. /**
  10345. * Draws text onto the texture
  10346. * @param text defines the text to be drawn
  10347. * @param x defines the placement of the text from the left
  10348. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10349. * @param font defines the font to be used with font-style, font-size, font-name
  10350. * @param color defines the color used for the text
  10351. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10352. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10353. * @param update defines whether texture is immediately update (default is true)
  10354. */
  10355. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10356. /**
  10357. * Clones the texture
  10358. * @returns the clone of the texture.
  10359. */
  10360. clone(): DynamicTexture;
  10361. /**
  10362. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10363. * @returns a serialized dynamic texture object
  10364. */
  10365. serialize(): any;
  10366. /** @hidden */
  10367. _rebuild(): void;
  10368. }
  10369. }
  10370. declare module BABYLON {
  10371. interface Engine {
  10372. /**
  10373. * Creates a raw texture
  10374. * @param data defines the data to store in the texture
  10375. * @param width defines the width of the texture
  10376. * @param height defines the height of the texture
  10377. * @param format defines the format of the data
  10378. * @param generateMipMaps defines if the engine should generate the mip levels
  10379. * @param invertY defines if data must be stored with Y axis inverted
  10380. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10381. * @param compression defines the compression used (null by default)
  10382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10383. * @returns the raw texture inside an InternalTexture
  10384. */
  10385. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10386. /**
  10387. * Update a raw texture
  10388. * @param texture defines the texture to update
  10389. * @param data defines the data to store in the texture
  10390. * @param format defines the format of the data
  10391. * @param invertY defines if data must be stored with Y axis inverted
  10392. */
  10393. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10394. /**
  10395. * Update a raw texture
  10396. * @param texture defines the texture to update
  10397. * @param data defines the data to store in the texture
  10398. * @param format defines the format of the data
  10399. * @param invertY defines if data must be stored with Y axis inverted
  10400. * @param compression defines the compression used (null by default)
  10401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10402. */
  10403. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10404. /**
  10405. * Creates a new raw cube texture
  10406. * @param data defines the array of data to use to create each face
  10407. * @param size defines the size of the textures
  10408. * @param format defines the format of the data
  10409. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10410. * @param generateMipMaps defines if the engine should generate the mip levels
  10411. * @param invertY defines if data must be stored with Y axis inverted
  10412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10413. * @param compression defines the compression used (null by default)
  10414. * @returns the cube texture as an InternalTexture
  10415. */
  10416. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10417. /**
  10418. * Update a raw cube texture
  10419. * @param texture defines the texture to udpdate
  10420. * @param data defines the data to store
  10421. * @param format defines the data format
  10422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10423. * @param invertY defines if data must be stored with Y axis inverted
  10424. */
  10425. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10426. /**
  10427. * Update a raw cube texture
  10428. * @param texture defines the texture to udpdate
  10429. * @param data defines the data to store
  10430. * @param format defines the data format
  10431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10432. * @param invertY defines if data must be stored with Y axis inverted
  10433. * @param compression defines the compression used (null by default)
  10434. */
  10435. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10436. /**
  10437. * Update a raw cube texture
  10438. * @param texture defines the texture to udpdate
  10439. * @param data defines the data to store
  10440. * @param format defines the data format
  10441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10442. * @param invertY defines if data must be stored with Y axis inverted
  10443. * @param compression defines the compression used (null by default)
  10444. * @param level defines which level of the texture to update
  10445. */
  10446. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10447. /**
  10448. * Creates a new raw cube texture from a specified url
  10449. * @param url defines the url where the data is located
  10450. * @param scene defines the current scene
  10451. * @param size defines the size of the textures
  10452. * @param format defines the format of the data
  10453. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10454. * @param noMipmap defines if the engine should avoid generating the mip levels
  10455. * @param callback defines a callback used to extract texture data from loaded data
  10456. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10457. * @param onLoad defines a callback called when texture is loaded
  10458. * @param onError defines a callback called if there is an error
  10459. * @returns the cube texture as an InternalTexture
  10460. */
  10461. 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;
  10462. /**
  10463. * Creates a new raw cube texture from a specified url
  10464. * @param url defines the url where the data is located
  10465. * @param scene defines the current scene
  10466. * @param size defines the size of the textures
  10467. * @param format defines the format of the data
  10468. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10469. * @param noMipmap defines if the engine should avoid generating the mip levels
  10470. * @param callback defines a callback used to extract texture data from loaded data
  10471. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10472. * @param onLoad defines a callback called when texture is loaded
  10473. * @param onError defines a callback called if there is an error
  10474. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10475. * @param invertY defines if data must be stored with Y axis inverted
  10476. * @returns the cube texture as an InternalTexture
  10477. */
  10478. 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;
  10479. /**
  10480. * Creates a new raw 3D texture
  10481. * @param data defines the data used to create the texture
  10482. * @param width defines the width of the texture
  10483. * @param height defines the height of the texture
  10484. * @param depth defines the depth of the texture
  10485. * @param format defines the format of the texture
  10486. * @param generateMipMaps defines if the engine must generate mip levels
  10487. * @param invertY defines if data must be stored with Y axis inverted
  10488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10489. * @param compression defines the compressed used (can be null)
  10490. * @param textureType defines the compressed used (can be null)
  10491. * @returns a new raw 3D texture (stored in an InternalTexture)
  10492. */
  10493. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10494. /**
  10495. * Update a raw 3D texture
  10496. * @param texture defines the texture to update
  10497. * @param data defines the data to store
  10498. * @param format defines the data format
  10499. * @param invertY defines if data must be stored with Y axis inverted
  10500. */
  10501. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10502. /**
  10503. * Update a raw 3D texture
  10504. * @param texture defines the texture to update
  10505. * @param data defines the data to store
  10506. * @param format defines the data format
  10507. * @param invertY defines if data must be stored with Y axis inverted
  10508. * @param compression defines the used compression (can be null)
  10509. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10510. */
  10511. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10512. /**
  10513. * Creates a new raw 2D array texture
  10514. * @param data defines the data used to create the texture
  10515. * @param width defines the width of the texture
  10516. * @param height defines the height of the texture
  10517. * @param depth defines the number of layers of the texture
  10518. * @param format defines the format of the texture
  10519. * @param generateMipMaps defines if the engine must generate mip levels
  10520. * @param invertY defines if data must be stored with Y axis inverted
  10521. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10522. * @param compression defines the compressed used (can be null)
  10523. * @param textureType defines the compressed used (can be null)
  10524. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10525. */
  10526. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10527. /**
  10528. * Update a raw 2D array texture
  10529. * @param texture defines the texture to update
  10530. * @param data defines the data to store
  10531. * @param format defines the data format
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. */
  10534. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10535. /**
  10536. * Update a raw 2D array texture
  10537. * @param texture defines the texture to update
  10538. * @param data defines the data to store
  10539. * @param format defines the data format
  10540. * @param invertY defines if data must be stored with Y axis inverted
  10541. * @param compression defines the used compression (can be null)
  10542. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10543. */
  10544. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10545. }
  10546. }
  10547. declare module BABYLON {
  10548. /**
  10549. * Raw texture can help creating a texture directly from an array of data.
  10550. * This can be super useful if you either get the data from an uncompressed source or
  10551. * if you wish to create your texture pixel by pixel.
  10552. */
  10553. export class RawTexture extends Texture {
  10554. /**
  10555. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10556. */
  10557. format: number;
  10558. private _engine;
  10559. /**
  10560. * Instantiates a new RawTexture.
  10561. * Raw texture can help creating a texture directly from an array of data.
  10562. * This can be super useful if you either get the data from an uncompressed source or
  10563. * if you wish to create your texture pixel by pixel.
  10564. * @param data define the array of data to use to create the texture
  10565. * @param width define the width of the texture
  10566. * @param height define the height of the texture
  10567. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10568. * @param scene define the scene the texture belongs to
  10569. * @param generateMipMaps define whether mip maps should be generated or not
  10570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10573. */
  10574. constructor(data: ArrayBufferView, width: number, height: number,
  10575. /**
  10576. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10577. */
  10578. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10579. /**
  10580. * Updates the texture underlying data.
  10581. * @param data Define the new data of the texture
  10582. */
  10583. update(data: ArrayBufferView): void;
  10584. /**
  10585. * Creates a luminance texture from some data.
  10586. * @param data Define the texture data
  10587. * @param width Define the width of the texture
  10588. * @param height Define the height of the texture
  10589. * @param scene Define the scene the texture belongs to
  10590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10593. * @returns the luminance texture
  10594. */
  10595. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10596. /**
  10597. * Creates a luminance alpha texture from some data.
  10598. * @param data Define the texture data
  10599. * @param width Define the width of the texture
  10600. * @param height Define the height of the texture
  10601. * @param scene Define the scene the texture belongs to
  10602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10605. * @returns the luminance alpha texture
  10606. */
  10607. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10608. /**
  10609. * Creates an alpha texture from some data.
  10610. * @param data Define the texture data
  10611. * @param width Define the width of the texture
  10612. * @param height Define the height of the texture
  10613. * @param scene Define the scene the texture belongs to
  10614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10617. * @returns the alpha texture
  10618. */
  10619. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10620. /**
  10621. * Creates a RGB texture from some data.
  10622. * @param data Define the texture data
  10623. * @param width Define the width of the texture
  10624. * @param height Define the height of the texture
  10625. * @param scene Define the scene the texture belongs to
  10626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10630. * @returns the RGB alpha texture
  10631. */
  10632. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10633. /**
  10634. * Creates a RGBA texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10643. * @returns the RGBA texture
  10644. */
  10645. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10646. /**
  10647. * Creates a R texture from some data.
  10648. * @param data Define the texture data
  10649. * @param width Define the width of the texture
  10650. * @param height Define the height of the texture
  10651. * @param scene Define the scene the texture belongs to
  10652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10656. * @returns the R texture
  10657. */
  10658. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10659. }
  10660. }
  10661. declare module BABYLON {
  10662. interface AbstractScene {
  10663. /**
  10664. * The list of procedural textures added to the scene
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10666. */
  10667. proceduralTextures: Array<ProceduralTexture>;
  10668. }
  10669. /**
  10670. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10671. * in a given scene.
  10672. */
  10673. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10674. /**
  10675. * The component name helpfull to identify the component in the list of scene components.
  10676. */
  10677. readonly name: string;
  10678. /**
  10679. * The scene the component belongs to.
  10680. */
  10681. scene: Scene;
  10682. /**
  10683. * Creates a new instance of the component for the given scene
  10684. * @param scene Defines the scene to register the component in
  10685. */
  10686. constructor(scene: Scene);
  10687. /**
  10688. * Registers the component in a given scene
  10689. */
  10690. register(): void;
  10691. /**
  10692. * Rebuilds the elements related to this component in case of
  10693. * context lost for instance.
  10694. */
  10695. rebuild(): void;
  10696. /**
  10697. * Disposes the component and the associated ressources.
  10698. */
  10699. dispose(): void;
  10700. private _beforeClear;
  10701. }
  10702. }
  10703. declare module BABYLON {
  10704. interface ThinEngine {
  10705. /**
  10706. * Creates a new render target cube texture
  10707. * @param size defines the size of the texture
  10708. * @param options defines the options used to create the texture
  10709. * @returns a new render target cube texture stored in an InternalTexture
  10710. */
  10711. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10712. }
  10713. }
  10714. declare module BABYLON {
  10715. /** @hidden */
  10716. export var proceduralVertexShader: {
  10717. name: string;
  10718. shader: string;
  10719. };
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * 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.
  10724. * This is the base class of any Procedural texture and contains most of the shareable code.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10726. */
  10727. export class ProceduralTexture extends Texture {
  10728. isCube: boolean;
  10729. /**
  10730. * Define if the texture is enabled or not (disabled texture will not render)
  10731. */
  10732. isEnabled: boolean;
  10733. /**
  10734. * Define if the texture must be cleared before rendering (default is true)
  10735. */
  10736. autoClear: boolean;
  10737. /**
  10738. * Callback called when the texture is generated
  10739. */
  10740. onGenerated: () => void;
  10741. /**
  10742. * Event raised when the texture is generated
  10743. */
  10744. onGeneratedObservable: Observable<ProceduralTexture>;
  10745. /** @hidden */
  10746. _generateMipMaps: boolean;
  10747. /** @hidden **/
  10748. _effect: Effect;
  10749. /** @hidden */
  10750. _textures: {
  10751. [key: string]: Texture;
  10752. };
  10753. private _size;
  10754. private _currentRefreshId;
  10755. private _frameId;
  10756. private _refreshRate;
  10757. private _vertexBuffers;
  10758. private _indexBuffer;
  10759. private _uniforms;
  10760. private _samplers;
  10761. private _fragment;
  10762. private _floats;
  10763. private _ints;
  10764. private _floatsArrays;
  10765. private _colors3;
  10766. private _colors4;
  10767. private _vectors2;
  10768. private _vectors3;
  10769. private _matrices;
  10770. private _fallbackTexture;
  10771. private _fallbackTextureUsed;
  10772. private _engine;
  10773. private _cachedDefines;
  10774. private _contentUpdateId;
  10775. private _contentData;
  10776. /**
  10777. * Instantiates a new procedural texture.
  10778. * 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.
  10779. * This is the base class of any Procedural texture and contains most of the shareable code.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10781. * @param name Define the name of the texture
  10782. * @param size Define the size of the texture to create
  10783. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10784. * @param scene Define the scene the texture belongs to
  10785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10786. * @param generateMipMaps Define if the texture should creates mip maps or not
  10787. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10788. */
  10789. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10790. /**
  10791. * The effect that is created when initializing the post process.
  10792. * @returns The created effect corresponding the the postprocess.
  10793. */
  10794. getEffect(): Effect;
  10795. /**
  10796. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10797. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10798. */
  10799. getContent(): Nullable<ArrayBufferView>;
  10800. private _createIndexBuffer;
  10801. /** @hidden */
  10802. _rebuild(): void;
  10803. /**
  10804. * Resets the texture in order to recreate its associated resources.
  10805. * This can be called in case of context loss
  10806. */
  10807. reset(): void;
  10808. protected _getDefines(): string;
  10809. /**
  10810. * Is the texture ready to be used ? (rendered at least once)
  10811. * @returns true if ready, otherwise, false.
  10812. */
  10813. isReady(): boolean;
  10814. /**
  10815. * Resets the refresh counter of the texture and start bak from scratch.
  10816. * Could be useful to regenerate the texture if it is setup to render only once.
  10817. */
  10818. resetRefreshCounter(): void;
  10819. /**
  10820. * Set the fragment shader to use in order to render the texture.
  10821. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10822. */
  10823. setFragment(fragment: any): void;
  10824. /**
  10825. * Define the refresh rate of the texture or the rendering frequency.
  10826. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10827. */
  10828. get refreshRate(): number;
  10829. set refreshRate(value: number);
  10830. /** @hidden */
  10831. _shouldRender(): boolean;
  10832. /**
  10833. * Get the size the texture is rendering at.
  10834. * @returns the size (texture is always squared)
  10835. */
  10836. getRenderSize(): number;
  10837. /**
  10838. * Resize the texture to new value.
  10839. * @param size Define the new size the texture should have
  10840. * @param generateMipMaps Define whether the new texture should create mip maps
  10841. */
  10842. resize(size: number, generateMipMaps: boolean): void;
  10843. private _checkUniform;
  10844. /**
  10845. * Set a texture in the shader program used to render.
  10846. * @param name Define the name of the uniform samplers as defined in the shader
  10847. * @param texture Define the texture to bind to this sampler
  10848. * @return the texture itself allowing "fluent" like uniform updates
  10849. */
  10850. setTexture(name: string, texture: Texture): ProceduralTexture;
  10851. /**
  10852. * Set a float in the shader.
  10853. * @param name Define the name of the uniform as defined in the shader
  10854. * @param value Define the value to give to the uniform
  10855. * @return the texture itself allowing "fluent" like uniform updates
  10856. */
  10857. setFloat(name: string, value: number): ProceduralTexture;
  10858. /**
  10859. * Set a int in the shader.
  10860. * @param name Define the name of the uniform as defined in the shader
  10861. * @param value Define the value to give to the uniform
  10862. * @return the texture itself allowing "fluent" like uniform updates
  10863. */
  10864. setInt(name: string, value: number): ProceduralTexture;
  10865. /**
  10866. * Set an array of floats in the shader.
  10867. * @param name Define the name of the uniform as defined in the shader
  10868. * @param value Define the value to give to the uniform
  10869. * @return the texture itself allowing "fluent" like uniform updates
  10870. */
  10871. setFloats(name: string, value: number[]): ProceduralTexture;
  10872. /**
  10873. * Set a vec3 in the shader from a Color3.
  10874. * @param name Define the name of the uniform as defined in the shader
  10875. * @param value Define the value to give to the uniform
  10876. * @return the texture itself allowing "fluent" like uniform updates
  10877. */
  10878. setColor3(name: string, value: Color3): ProceduralTexture;
  10879. /**
  10880. * Set a vec4 in the shader from a Color4.
  10881. * @param name Define the name of the uniform as defined in the shader
  10882. * @param value Define the value to give to the uniform
  10883. * @return the texture itself allowing "fluent" like uniform updates
  10884. */
  10885. setColor4(name: string, value: Color4): ProceduralTexture;
  10886. /**
  10887. * Set a vec2 in the shader from a Vector2.
  10888. * @param name Define the name of the uniform as defined in the shader
  10889. * @param value Define the value to give to the uniform
  10890. * @return the texture itself allowing "fluent" like uniform updates
  10891. */
  10892. setVector2(name: string, value: Vector2): ProceduralTexture;
  10893. /**
  10894. * Set a vec3 in the shader from a Vector3.
  10895. * @param name Define the name of the uniform as defined in the shader
  10896. * @param value Define the value to give to the uniform
  10897. * @return the texture itself allowing "fluent" like uniform updates
  10898. */
  10899. setVector3(name: string, value: Vector3): ProceduralTexture;
  10900. /**
  10901. * Set a mat4 in the shader from a MAtrix.
  10902. * @param name Define the name of the uniform as defined in the shader
  10903. * @param value Define the value to give to the uniform
  10904. * @return the texture itself allowing "fluent" like uniform updates
  10905. */
  10906. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10907. /**
  10908. * Render the texture to its associated render target.
  10909. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10910. */
  10911. render(useCameraPostProcess?: boolean): void;
  10912. /**
  10913. * Clone the texture.
  10914. * @returns the cloned texture
  10915. */
  10916. clone(): ProceduralTexture;
  10917. /**
  10918. * Dispose the texture and release its asoociated resources.
  10919. */
  10920. dispose(): void;
  10921. }
  10922. }
  10923. declare module BABYLON {
  10924. /**
  10925. * This represents the base class for particle system in Babylon.
  10926. * 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.
  10927. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10928. * @example https://doc.babylonjs.com/babylon101/particles
  10929. */
  10930. export class BaseParticleSystem {
  10931. /**
  10932. * Source color is added to the destination color without alpha affecting the result
  10933. */
  10934. static BLENDMODE_ONEONE: number;
  10935. /**
  10936. * Blend current color and particle color using particle’s alpha
  10937. */
  10938. static BLENDMODE_STANDARD: number;
  10939. /**
  10940. * Add current color and particle color multiplied by particle’s alpha
  10941. */
  10942. static BLENDMODE_ADD: number;
  10943. /**
  10944. * Multiply current color with particle color
  10945. */
  10946. static BLENDMODE_MULTIPLY: number;
  10947. /**
  10948. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10949. */
  10950. static BLENDMODE_MULTIPLYADD: number;
  10951. /**
  10952. * List of animations used by the particle system.
  10953. */
  10954. animations: Animation[];
  10955. /**
  10956. * The id of the Particle system.
  10957. */
  10958. id: string;
  10959. /**
  10960. * The friendly name of the Particle system.
  10961. */
  10962. name: string;
  10963. /**
  10964. * The rendering group used by the Particle system to chose when to render.
  10965. */
  10966. renderingGroupId: number;
  10967. /**
  10968. * The emitter represents the Mesh or position we are attaching the particle system to.
  10969. */
  10970. emitter: Nullable<AbstractMesh | Vector3>;
  10971. /**
  10972. * The maximum number of particles to emit per frame
  10973. */
  10974. emitRate: number;
  10975. /**
  10976. * If you want to launch only a few particles at once, that can be done, as well.
  10977. */
  10978. manualEmitCount: number;
  10979. /**
  10980. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10981. */
  10982. updateSpeed: number;
  10983. /**
  10984. * The amount of time the particle system is running (depends of the overall update speed).
  10985. */
  10986. targetStopDuration: number;
  10987. /**
  10988. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10989. */
  10990. disposeOnStop: boolean;
  10991. /**
  10992. * Minimum power of emitting particles.
  10993. */
  10994. minEmitPower: number;
  10995. /**
  10996. * Maximum power of emitting particles.
  10997. */
  10998. maxEmitPower: number;
  10999. /**
  11000. * Minimum life time of emitting particles.
  11001. */
  11002. minLifeTime: number;
  11003. /**
  11004. * Maximum life time of emitting particles.
  11005. */
  11006. maxLifeTime: number;
  11007. /**
  11008. * Minimum Size of emitting particles.
  11009. */
  11010. minSize: number;
  11011. /**
  11012. * Maximum Size of emitting particles.
  11013. */
  11014. maxSize: number;
  11015. /**
  11016. * Minimum scale of emitting particles on X axis.
  11017. */
  11018. minScaleX: number;
  11019. /**
  11020. * Maximum scale of emitting particles on X axis.
  11021. */
  11022. maxScaleX: number;
  11023. /**
  11024. * Minimum scale of emitting particles on Y axis.
  11025. */
  11026. minScaleY: number;
  11027. /**
  11028. * Maximum scale of emitting particles on Y axis.
  11029. */
  11030. maxScaleY: number;
  11031. /**
  11032. * Gets or sets the minimal initial rotation in radians.
  11033. */
  11034. minInitialRotation: number;
  11035. /**
  11036. * Gets or sets the maximal initial rotation in radians.
  11037. */
  11038. maxInitialRotation: number;
  11039. /**
  11040. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11041. */
  11042. minAngularSpeed: number;
  11043. /**
  11044. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11045. */
  11046. maxAngularSpeed: number;
  11047. /**
  11048. * The texture used to render each particle. (this can be a spritesheet)
  11049. */
  11050. particleTexture: Nullable<Texture>;
  11051. /**
  11052. * The layer mask we are rendering the particles through.
  11053. */
  11054. layerMask: number;
  11055. /**
  11056. * This can help using your own shader to render the particle system.
  11057. * The according effect will be created
  11058. */
  11059. customShader: any;
  11060. /**
  11061. * By default particle system starts as soon as they are created. This prevents the
  11062. * automatic start to happen and let you decide when to start emitting particles.
  11063. */
  11064. preventAutoStart: boolean;
  11065. private _noiseTexture;
  11066. /**
  11067. * Gets or sets a texture used to add random noise to particle positions
  11068. */
  11069. get noiseTexture(): Nullable<ProceduralTexture>;
  11070. set noiseTexture(value: Nullable<ProceduralTexture>);
  11071. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11072. noiseStrength: Vector3;
  11073. /**
  11074. * Callback triggered when the particle animation is ending.
  11075. */
  11076. onAnimationEnd: Nullable<() => void>;
  11077. /**
  11078. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11079. */
  11080. blendMode: number;
  11081. /**
  11082. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11083. * to override the particles.
  11084. */
  11085. forceDepthWrite: boolean;
  11086. /** 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 */
  11087. preWarmCycles: number;
  11088. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11089. preWarmStepOffset: number;
  11090. /**
  11091. * 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)
  11092. */
  11093. spriteCellChangeSpeed: number;
  11094. /**
  11095. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11096. */
  11097. startSpriteCellID: number;
  11098. /**
  11099. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11100. */
  11101. endSpriteCellID: number;
  11102. /**
  11103. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11104. */
  11105. spriteCellWidth: number;
  11106. /**
  11107. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11108. */
  11109. spriteCellHeight: number;
  11110. /**
  11111. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11112. */
  11113. spriteRandomStartCell: boolean;
  11114. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11115. translationPivot: Vector2;
  11116. /** @hidden */
  11117. protected _isAnimationSheetEnabled: boolean;
  11118. /**
  11119. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11120. */
  11121. beginAnimationOnStart: boolean;
  11122. /**
  11123. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11124. */
  11125. beginAnimationFrom: number;
  11126. /**
  11127. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11128. */
  11129. beginAnimationTo: number;
  11130. /**
  11131. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11132. */
  11133. beginAnimationLoop: boolean;
  11134. /**
  11135. * Gets or sets a world offset applied to all particles
  11136. */
  11137. worldOffset: Vector3;
  11138. /**
  11139. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11140. */
  11141. get isAnimationSheetEnabled(): boolean;
  11142. set isAnimationSheetEnabled(value: boolean);
  11143. /**
  11144. * Get hosting scene
  11145. * @returns the scene
  11146. */
  11147. getScene(): Scene;
  11148. /**
  11149. * You can use gravity if you want to give an orientation to your particles.
  11150. */
  11151. gravity: Vector3;
  11152. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11153. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11154. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11155. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11156. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11157. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11158. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11159. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11160. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11162. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11163. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11164. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11165. /**
  11166. * Defines the delay in milliseconds before starting the system (0 by default)
  11167. */
  11168. startDelay: number;
  11169. /**
  11170. * Gets the current list of drag gradients.
  11171. * You must use addDragGradient and removeDragGradient to udpate this list
  11172. * @returns the list of drag gradients
  11173. */
  11174. getDragGradients(): Nullable<Array<FactorGradient>>;
  11175. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11176. limitVelocityDamping: number;
  11177. /**
  11178. * Gets the current list of limit velocity gradients.
  11179. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11180. * @returns the list of limit velocity gradients
  11181. */
  11182. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11183. /**
  11184. * Gets the current list of color gradients.
  11185. * You must use addColorGradient and removeColorGradient to udpate this list
  11186. * @returns the list of color gradients
  11187. */
  11188. getColorGradients(): Nullable<Array<ColorGradient>>;
  11189. /**
  11190. * Gets the current list of size gradients.
  11191. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11192. * @returns the list of size gradients
  11193. */
  11194. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11195. /**
  11196. * Gets the current list of color remap gradients.
  11197. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11198. * @returns the list of color remap gradients
  11199. */
  11200. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of alpha remap gradients.
  11203. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11204. * @returns the list of alpha remap gradients
  11205. */
  11206. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of life time gradients.
  11209. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11210. * @returns the list of life time gradients
  11211. */
  11212. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of angular speed gradients.
  11215. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11216. * @returns the list of angular speed gradients
  11217. */
  11218. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of velocity gradients.
  11221. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11222. * @returns the list of velocity gradients
  11223. */
  11224. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of start size gradients.
  11227. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11228. * @returns the list of start size gradients
  11229. */
  11230. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of emit rate gradients.
  11233. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11234. * @returns the list of emit rate gradients
  11235. */
  11236. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11239. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11240. */
  11241. get direction1(): Vector3;
  11242. set direction1(value: Vector3);
  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 direction2(): Vector3;
  11248. set direction2(value: Vector3);
  11249. /**
  11250. * 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.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get minEmitBox(): Vector3;
  11254. set minEmitBox(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get maxEmitBox(): Vector3;
  11260. set maxEmitBox(value: Vector3);
  11261. /**
  11262. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11263. */
  11264. color1: Color4;
  11265. /**
  11266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11267. */
  11268. color2: Color4;
  11269. /**
  11270. * Color the particle will have at the end of its lifetime
  11271. */
  11272. colorDead: Color4;
  11273. /**
  11274. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11275. */
  11276. textureMask: Color4;
  11277. /**
  11278. * The particle emitter type defines the emitter used by the particle system.
  11279. * It can be for example box, sphere, or cone...
  11280. */
  11281. particleEmitterType: IParticleEmitterType;
  11282. /** @hidden */
  11283. _isSubEmitter: boolean;
  11284. /**
  11285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11287. */
  11288. billboardMode: number;
  11289. protected _isBillboardBased: boolean;
  11290. /**
  11291. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11292. */
  11293. get isBillboardBased(): boolean;
  11294. set isBillboardBased(value: boolean);
  11295. /**
  11296. * The scene the particle system belongs to.
  11297. */
  11298. protected _scene: Scene;
  11299. /**
  11300. * Local cache of defines for image processing.
  11301. */
  11302. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11303. /**
  11304. * Default configuration related to image processing available in the standard Material.
  11305. */
  11306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11307. /**
  11308. * Gets the image processing configuration used either in this material.
  11309. */
  11310. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11311. /**
  11312. * Sets the Default image processing configuration used either in the this material.
  11313. *
  11314. * If sets to null, the scene one is in use.
  11315. */
  11316. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11317. /**
  11318. * Attaches a new image processing configuration to the Standard Material.
  11319. * @param configuration
  11320. */
  11321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11322. /** @hidden */
  11323. protected _reset(): void;
  11324. /** @hidden */
  11325. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11326. /**
  11327. * Instantiates a particle system.
  11328. * 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.
  11329. * @param name The name of the particle system
  11330. */
  11331. constructor(name: string);
  11332. /**
  11333. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11334. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11335. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11336. * @returns the emitter
  11337. */
  11338. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11339. /**
  11340. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11341. * @param radius The radius of the hemisphere to emit from
  11342. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11343. * @returns the emitter
  11344. */
  11345. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11346. /**
  11347. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11348. * @param radius The radius of the sphere to emit from
  11349. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11350. * @returns the emitter
  11351. */
  11352. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11353. /**
  11354. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11355. * @param radius The radius of the sphere to emit from
  11356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11358. * @returns the emitter
  11359. */
  11360. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11361. /**
  11362. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11363. * @param radius The radius of the emission cylinder
  11364. * @param height The height of the emission cylinder
  11365. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11366. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11367. * @returns the emitter
  11368. */
  11369. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11370. /**
  11371. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11372. * @param radius The radius of the cylinder to emit from
  11373. * @param height The height of the emission cylinder
  11374. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11375. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11376. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11377. * @returns the emitter
  11378. */
  11379. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11380. /**
  11381. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11382. * @param radius The radius of the cone to emit from
  11383. * @param angle The base angle of the cone
  11384. * @returns the emitter
  11385. */
  11386. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11387. /**
  11388. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11391. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11392. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11393. * @returns the emitter
  11394. */
  11395. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11396. }
  11397. }
  11398. declare module BABYLON {
  11399. /**
  11400. * Type of sub emitter
  11401. */
  11402. export enum SubEmitterType {
  11403. /**
  11404. * Attached to the particle over it's lifetime
  11405. */
  11406. ATTACHED = 0,
  11407. /**
  11408. * Created when the particle dies
  11409. */
  11410. END = 1
  11411. }
  11412. /**
  11413. * Sub emitter class used to emit particles from an existing particle
  11414. */
  11415. export class SubEmitter {
  11416. /**
  11417. * the particle system to be used by the sub emitter
  11418. */
  11419. particleSystem: ParticleSystem;
  11420. /**
  11421. * Type of the submitter (Default: END)
  11422. */
  11423. type: SubEmitterType;
  11424. /**
  11425. * 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)
  11426. * Note: This only is supported when using an emitter of type Mesh
  11427. */
  11428. inheritDirection: boolean;
  11429. /**
  11430. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11431. */
  11432. inheritedVelocityAmount: number;
  11433. /**
  11434. * Creates a sub emitter
  11435. * @param particleSystem the particle system to be used by the sub emitter
  11436. */
  11437. constructor(
  11438. /**
  11439. * the particle system to be used by the sub emitter
  11440. */
  11441. particleSystem: ParticleSystem);
  11442. /**
  11443. * Clones the sub emitter
  11444. * @returns the cloned sub emitter
  11445. */
  11446. clone(): SubEmitter;
  11447. /**
  11448. * Serialize current object to a JSON object
  11449. * @returns the serialized object
  11450. */
  11451. serialize(): any;
  11452. /** @hidden */
  11453. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11454. /**
  11455. * Creates a new SubEmitter from a serialized JSON version
  11456. * @param serializationObject defines the JSON object to read from
  11457. * @param scene defines the hosting scene
  11458. * @param rootUrl defines the rootUrl for data loading
  11459. * @returns a new SubEmitter
  11460. */
  11461. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11462. /** Release associated resources */
  11463. dispose(): void;
  11464. }
  11465. }
  11466. declare module BABYLON {
  11467. /** @hidden */
  11468. export var imageProcessingDeclaration: {
  11469. name: string;
  11470. shader: string;
  11471. };
  11472. }
  11473. declare module BABYLON {
  11474. /** @hidden */
  11475. export var imageProcessingFunctions: {
  11476. name: string;
  11477. shader: string;
  11478. };
  11479. }
  11480. declare module BABYLON {
  11481. /** @hidden */
  11482. export var particlesPixelShader: {
  11483. name: string;
  11484. shader: string;
  11485. };
  11486. }
  11487. declare module BABYLON {
  11488. /** @hidden */
  11489. export var particlesVertexShader: {
  11490. name: string;
  11491. shader: string;
  11492. };
  11493. }
  11494. declare module BABYLON {
  11495. /**
  11496. * This represents a particle system in Babylon.
  11497. * 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.
  11498. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11499. * @example https://doc.babylonjs.com/babylon101/particles
  11500. */
  11501. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11502. /**
  11503. * Billboard mode will only apply to Y axis
  11504. */
  11505. static readonly BILLBOARDMODE_Y: number;
  11506. /**
  11507. * Billboard mode will apply to all axes
  11508. */
  11509. static readonly BILLBOARDMODE_ALL: number;
  11510. /**
  11511. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11512. */
  11513. static readonly BILLBOARDMODE_STRETCHED: number;
  11514. /**
  11515. * This function can be defined to provide custom update for active particles.
  11516. * This function will be called instead of regular update (age, position, color, etc.).
  11517. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11518. */
  11519. updateFunction: (particles: Particle[]) => void;
  11520. private _emitterWorldMatrix;
  11521. /**
  11522. * This function can be defined to specify initial direction for every new particle.
  11523. * It by default use the emitterType defined function
  11524. */
  11525. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11526. /**
  11527. * This function can be defined to specify initial position for every new particle.
  11528. * It by default use the emitterType defined function
  11529. */
  11530. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11531. /**
  11532. * @hidden
  11533. */
  11534. _inheritedVelocityOffset: Vector3;
  11535. /**
  11536. * An event triggered when the system is disposed
  11537. */
  11538. onDisposeObservable: Observable<ParticleSystem>;
  11539. private _onDisposeObserver;
  11540. /**
  11541. * Sets a callback that will be triggered when the system is disposed
  11542. */
  11543. set onDispose(callback: () => void);
  11544. private _particles;
  11545. private _epsilon;
  11546. private _capacity;
  11547. private _stockParticles;
  11548. private _newPartsExcess;
  11549. private _vertexData;
  11550. private _vertexBuffer;
  11551. private _vertexBuffers;
  11552. private _spriteBuffer;
  11553. private _indexBuffer;
  11554. private _effect;
  11555. private _customEffect;
  11556. private _cachedDefines;
  11557. private _scaledColorStep;
  11558. private _colorDiff;
  11559. private _scaledDirection;
  11560. private _scaledGravity;
  11561. private _currentRenderId;
  11562. private _alive;
  11563. private _useInstancing;
  11564. private _started;
  11565. private _stopped;
  11566. private _actualFrame;
  11567. private _scaledUpdateSpeed;
  11568. private _vertexBufferSize;
  11569. /** @hidden */
  11570. _currentEmitRateGradient: Nullable<FactorGradient>;
  11571. /** @hidden */
  11572. _currentEmitRate1: number;
  11573. /** @hidden */
  11574. _currentEmitRate2: number;
  11575. /** @hidden */
  11576. _currentStartSizeGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentStartSize1: number;
  11579. /** @hidden */
  11580. _currentStartSize2: number;
  11581. private readonly _rawTextureWidth;
  11582. private _rampGradientsTexture;
  11583. private _useRampGradients;
  11584. /** Gets or sets a boolean indicating that ramp gradients must be used
  11585. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11586. */
  11587. get useRampGradients(): boolean;
  11588. set useRampGradients(value: boolean);
  11589. /**
  11590. * 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.
  11591. * 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: [])
  11592. */
  11593. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11594. private _subEmitters;
  11595. /**
  11596. * @hidden
  11597. * If the particle systems emitter should be disposed when the particle system is disposed
  11598. */
  11599. _disposeEmitterOnDispose: boolean;
  11600. /**
  11601. * The current active Sub-systems, this property is used by the root particle system only.
  11602. */
  11603. activeSubSystems: Array<ParticleSystem>;
  11604. /**
  11605. * Specifies if the particles are updated in emitter local space or world space
  11606. */
  11607. isLocal: boolean;
  11608. private _rootParticleSystem;
  11609. /**
  11610. * Gets the current list of active particles
  11611. */
  11612. get particles(): Particle[];
  11613. /**
  11614. * Returns the string "ParticleSystem"
  11615. * @returns a string containing the class name
  11616. */
  11617. getClassName(): string;
  11618. /**
  11619. * Instantiates a particle system.
  11620. * 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.
  11621. * @param name The name of the particle system
  11622. * @param capacity The max number of particles alive at the same time
  11623. * @param scene The scene the particle system belongs to
  11624. * @param customEffect a custom effect used to change the way particles are rendered by default
  11625. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11626. * @param epsilon Offset used to render the particles
  11627. */
  11628. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11629. private _addFactorGradient;
  11630. private _removeFactorGradient;
  11631. /**
  11632. * Adds a new life time gradient
  11633. * @param gradient defines the gradient to use (between 0 and 1)
  11634. * @param factor defines the life time factor to affect to the specified gradient
  11635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11636. * @returns the current particle system
  11637. */
  11638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11639. /**
  11640. * Remove a specific life time gradient
  11641. * @param gradient defines the gradient to remove
  11642. * @returns the current particle system
  11643. */
  11644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11645. /**
  11646. * Adds a new size gradient
  11647. * @param gradient defines the gradient to use (between 0 and 1)
  11648. * @param factor defines the size factor to affect to the specified gradient
  11649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11650. * @returns the current particle system
  11651. */
  11652. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11653. /**
  11654. * Remove a specific size gradient
  11655. * @param gradient defines the gradient to remove
  11656. * @returns the current particle system
  11657. */
  11658. removeSizeGradient(gradient: number): IParticleSystem;
  11659. /**
  11660. * Adds a new color remap gradient
  11661. * @param gradient defines the gradient to use (between 0 and 1)
  11662. * @param min defines the color remap minimal range
  11663. * @param max defines the color remap maximal range
  11664. * @returns the current particle system
  11665. */
  11666. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11667. /**
  11668. * Remove a specific color remap gradient
  11669. * @param gradient defines the gradient to remove
  11670. * @returns the current particle system
  11671. */
  11672. removeColorRemapGradient(gradient: number): IParticleSystem;
  11673. /**
  11674. * Adds a new alpha remap gradient
  11675. * @param gradient defines the gradient to use (between 0 and 1)
  11676. * @param min defines the alpha remap minimal range
  11677. * @param max defines the alpha remap maximal range
  11678. * @returns the current particle system
  11679. */
  11680. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11681. /**
  11682. * Remove a specific alpha remap gradient
  11683. * @param gradient defines the gradient to remove
  11684. * @returns the current particle system
  11685. */
  11686. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11687. /**
  11688. * Adds a new angular speed gradient
  11689. * @param gradient defines the gradient to use (between 0 and 1)
  11690. * @param factor defines the angular speed to affect to the specified gradient
  11691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11692. * @returns the current particle system
  11693. */
  11694. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11695. /**
  11696. * Remove a specific angular speed gradient
  11697. * @param gradient defines the gradient to remove
  11698. * @returns the current particle system
  11699. */
  11700. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11701. /**
  11702. * Adds a new velocity gradient
  11703. * @param gradient defines the gradient to use (between 0 and 1)
  11704. * @param factor defines the velocity to affect to the specified gradient
  11705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11706. * @returns the current particle system
  11707. */
  11708. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11709. /**
  11710. * Remove a specific velocity gradient
  11711. * @param gradient defines the gradient to remove
  11712. * @returns the current particle system
  11713. */
  11714. removeVelocityGradient(gradient: number): IParticleSystem;
  11715. /**
  11716. * Adds a new limit velocity gradient
  11717. * @param gradient defines the gradient to use (between 0 and 1)
  11718. * @param factor defines the limit velocity value to affect to the specified gradient
  11719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11720. * @returns the current particle system
  11721. */
  11722. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11723. /**
  11724. * Remove a specific limit velocity gradient
  11725. * @param gradient defines the gradient to remove
  11726. * @returns the current particle system
  11727. */
  11728. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11729. /**
  11730. * Adds a new drag gradient
  11731. * @param gradient defines the gradient to use (between 0 and 1)
  11732. * @param factor defines the drag value to affect to the specified gradient
  11733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11734. * @returns the current particle system
  11735. */
  11736. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11737. /**
  11738. * Remove a specific drag gradient
  11739. * @param gradient defines the gradient to remove
  11740. * @returns the current particle system
  11741. */
  11742. removeDragGradient(gradient: number): IParticleSystem;
  11743. /**
  11744. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11745. * @param gradient defines the gradient to use (between 0 and 1)
  11746. * @param factor defines the emit rate value to affect to the specified gradient
  11747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11748. * @returns the current particle system
  11749. */
  11750. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11751. /**
  11752. * Remove a specific emit rate gradient
  11753. * @param gradient defines the gradient to remove
  11754. * @returns the current particle system
  11755. */
  11756. removeEmitRateGradient(gradient: number): IParticleSystem;
  11757. /**
  11758. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11759. * @param gradient defines the gradient to use (between 0 and 1)
  11760. * @param factor defines the start size value to affect to the specified gradient
  11761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11762. * @returns the current particle system
  11763. */
  11764. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11765. /**
  11766. * Remove a specific start size gradient
  11767. * @param gradient defines the gradient to remove
  11768. * @returns the current particle system
  11769. */
  11770. removeStartSizeGradient(gradient: number): IParticleSystem;
  11771. private _createRampGradientTexture;
  11772. /**
  11773. * Gets the current list of ramp gradients.
  11774. * You must use addRampGradient and removeRampGradient to udpate this list
  11775. * @returns the list of ramp gradients
  11776. */
  11777. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11778. /**
  11779. * Adds a new ramp gradient used to remap particle colors
  11780. * @param gradient defines the gradient to use (between 0 and 1)
  11781. * @param color defines the color to affect to the specified gradient
  11782. * @returns the current particle system
  11783. */
  11784. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11785. /**
  11786. * Remove a specific ramp gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeRampGradient(gradient: number): ParticleSystem;
  11791. /**
  11792. * Adds a new color gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param color1 defines the color to affect to the specified gradient
  11795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11796. * @returns this particle system
  11797. */
  11798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11799. /**
  11800. * Remove a specific color gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns this particle system
  11803. */
  11804. removeColorGradient(gradient: number): IParticleSystem;
  11805. private _fetchR;
  11806. protected _reset(): void;
  11807. private _resetEffect;
  11808. private _createVertexBuffers;
  11809. private _createIndexBuffer;
  11810. /**
  11811. * Gets the maximum number of particles active at the same time.
  11812. * @returns The max number of active particles.
  11813. */
  11814. getCapacity(): number;
  11815. /**
  11816. * Gets whether there are still active particles in the system.
  11817. * @returns True if it is alive, otherwise false.
  11818. */
  11819. isAlive(): boolean;
  11820. /**
  11821. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11822. * @returns True if it has been started, otherwise false.
  11823. */
  11824. isStarted(): boolean;
  11825. private _prepareSubEmitterInternalArray;
  11826. /**
  11827. * Starts the particle system and begins to emit
  11828. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11829. */
  11830. start(delay?: number): void;
  11831. /**
  11832. * Stops the particle system.
  11833. * @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.
  11834. */
  11835. stop(stopSubEmitters?: boolean): void;
  11836. /**
  11837. * Remove all active particles
  11838. */
  11839. reset(): void;
  11840. /**
  11841. * @hidden (for internal use only)
  11842. */
  11843. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11844. /**
  11845. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11846. * Its lifetime will start back at 0.
  11847. */
  11848. recycleParticle: (particle: Particle) => void;
  11849. private _stopSubEmitters;
  11850. private _createParticle;
  11851. private _removeFromRoot;
  11852. private _emitFromParticle;
  11853. private _update;
  11854. /** @hidden */
  11855. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11856. /** @hidden */
  11857. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11858. /** @hidden */
  11859. private _getEffect;
  11860. /**
  11861. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11862. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11863. */
  11864. animate(preWarmOnly?: boolean): void;
  11865. private _appendParticleVertices;
  11866. /**
  11867. * Rebuilds the particle system.
  11868. */
  11869. rebuild(): void;
  11870. /**
  11871. * Is this system ready to be used/rendered
  11872. * @return true if the system is ready
  11873. */
  11874. isReady(): boolean;
  11875. private _render;
  11876. /**
  11877. * Renders the particle system in its current state.
  11878. * @returns the current number of particles
  11879. */
  11880. render(): number;
  11881. /**
  11882. * Disposes the particle system and free the associated resources
  11883. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11884. */
  11885. dispose(disposeTexture?: boolean): void;
  11886. /**
  11887. * Clones the particle system.
  11888. * @param name The name of the cloned object
  11889. * @param newEmitter The new emitter to use
  11890. * @returns the cloned particle system
  11891. */
  11892. clone(name: string, newEmitter: any): ParticleSystem;
  11893. /**
  11894. * Serializes the particle system to a JSON object.
  11895. * @returns the JSON object
  11896. */
  11897. serialize(): any;
  11898. /** @hidden */
  11899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11900. /** @hidden */
  11901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11902. /**
  11903. * Parses a JSON object to create a particle system.
  11904. * @param parsedParticleSystem The JSON object to parse
  11905. * @param scene The scene to create the particle system in
  11906. * @param rootUrl The root url to use to load external dependencies like texture
  11907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11908. * @returns the Parsed particle system
  11909. */
  11910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11911. }
  11912. }
  11913. declare module BABYLON {
  11914. /**
  11915. * A particle represents one of the element emitted by a particle system.
  11916. * This is mainly define by its coordinates, direction, velocity and age.
  11917. */
  11918. export class Particle {
  11919. /**
  11920. * The particle system the particle belongs to.
  11921. */
  11922. particleSystem: ParticleSystem;
  11923. private static _Count;
  11924. /**
  11925. * Unique ID of the particle
  11926. */
  11927. id: number;
  11928. /**
  11929. * The world position of the particle in the scene.
  11930. */
  11931. position: Vector3;
  11932. /**
  11933. * The world direction of the particle in the scene.
  11934. */
  11935. direction: Vector3;
  11936. /**
  11937. * The color of the particle.
  11938. */
  11939. color: Color4;
  11940. /**
  11941. * The color change of the particle per step.
  11942. */
  11943. colorStep: Color4;
  11944. /**
  11945. * Defines how long will the life of the particle be.
  11946. */
  11947. lifeTime: number;
  11948. /**
  11949. * The current age of the particle.
  11950. */
  11951. age: number;
  11952. /**
  11953. * The current size of the particle.
  11954. */
  11955. size: number;
  11956. /**
  11957. * The current scale of the particle.
  11958. */
  11959. scale: Vector2;
  11960. /**
  11961. * The current angle of the particle.
  11962. */
  11963. angle: number;
  11964. /**
  11965. * Defines how fast is the angle changing.
  11966. */
  11967. angularSpeed: number;
  11968. /**
  11969. * Defines the cell index used by the particle to be rendered from a sprite.
  11970. */
  11971. cellIndex: number;
  11972. /**
  11973. * The information required to support color remapping
  11974. */
  11975. remapData: Vector4;
  11976. /** @hidden */
  11977. _randomCellOffset?: number;
  11978. /** @hidden */
  11979. _initialDirection: Nullable<Vector3>;
  11980. /** @hidden */
  11981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11982. /** @hidden */
  11983. _initialStartSpriteCellID: number;
  11984. /** @hidden */
  11985. _initialEndSpriteCellID: number;
  11986. /** @hidden */
  11987. _currentColorGradient: Nullable<ColorGradient>;
  11988. /** @hidden */
  11989. _currentColor1: Color4;
  11990. /** @hidden */
  11991. _currentColor2: Color4;
  11992. /** @hidden */
  11993. _currentSizeGradient: Nullable<FactorGradient>;
  11994. /** @hidden */
  11995. _currentSize1: number;
  11996. /** @hidden */
  11997. _currentSize2: number;
  11998. /** @hidden */
  11999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12000. /** @hidden */
  12001. _currentAngularSpeed1: number;
  12002. /** @hidden */
  12003. _currentAngularSpeed2: number;
  12004. /** @hidden */
  12005. _currentVelocityGradient: Nullable<FactorGradient>;
  12006. /** @hidden */
  12007. _currentVelocity1: number;
  12008. /** @hidden */
  12009. _currentVelocity2: number;
  12010. /** @hidden */
  12011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12012. /** @hidden */
  12013. _currentLimitVelocity1: number;
  12014. /** @hidden */
  12015. _currentLimitVelocity2: number;
  12016. /** @hidden */
  12017. _currentDragGradient: Nullable<FactorGradient>;
  12018. /** @hidden */
  12019. _currentDrag1: number;
  12020. /** @hidden */
  12021. _currentDrag2: number;
  12022. /** @hidden */
  12023. _randomNoiseCoordinates1: Vector3;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates2: Vector3;
  12026. /** @hidden */
  12027. _localPosition?: 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. * @param isLocal defines if the direction should be set in local space
  12067. */
  12068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12069. /**
  12070. * Called by the particle System when the position is computed for the created particle.
  12071. * @param worldMatrix is the world matrix of the particle system
  12072. * @param positionToUpdate is the position vector to update with the result
  12073. * @param particle is the particle we are computed the position for
  12074. * @param isLocal defines if the position should be set in local space
  12075. */
  12076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12077. /**
  12078. * Clones the current emitter and returns a copy of it
  12079. * @returns the new emitter
  12080. */
  12081. clone(): IParticleEmitterType;
  12082. /**
  12083. * Called by the GPUParticleSystem to setup the update shader
  12084. * @param effect defines the update shader
  12085. */
  12086. applyToShader(effect: Effect): void;
  12087. /**
  12088. * Returns a string to use to update the GPU particles update shader
  12089. * @returns the effect defines string
  12090. */
  12091. getEffectDefines(): string;
  12092. /**
  12093. * Returns a string representing the class name
  12094. * @returns a string containing the class name
  12095. */
  12096. getClassName(): string;
  12097. /**
  12098. * Serializes the particle system to a JSON object.
  12099. * @returns the JSON object
  12100. */
  12101. serialize(): any;
  12102. /**
  12103. * Parse properties from a JSON object
  12104. * @param serializationObject defines the JSON object
  12105. * @param scene defines the hosting scene
  12106. */
  12107. parse(serializationObject: any, scene: Scene): void;
  12108. }
  12109. }
  12110. declare module BABYLON {
  12111. /**
  12112. * Particle emitter emitting particles from the inside of a box.
  12113. * It emits the particles randomly between 2 given directions.
  12114. */
  12115. export class BoxParticleEmitter implements IParticleEmitterType {
  12116. /**
  12117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12118. */
  12119. direction1: Vector3;
  12120. /**
  12121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12122. */
  12123. direction2: Vector3;
  12124. /**
  12125. * 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.
  12126. */
  12127. minEmitBox: Vector3;
  12128. /**
  12129. * 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.
  12130. */
  12131. maxEmitBox: Vector3;
  12132. /**
  12133. * Creates a new instance BoxParticleEmitter
  12134. */
  12135. constructor();
  12136. /**
  12137. * Called by the particle System when the direction is computed for the created particle.
  12138. * @param worldMatrix is the world matrix of the particle system
  12139. * @param directionToUpdate is the direction vector to update with the result
  12140. * @param particle is the particle we are computed the direction for
  12141. * @param isLocal defines if the direction should be set in local space
  12142. */
  12143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12144. /**
  12145. * Called by the particle System when the position is computed for the created particle.
  12146. * @param worldMatrix is the world matrix of the particle system
  12147. * @param positionToUpdate is the position vector to update with the result
  12148. * @param particle is the particle we are computed the position for
  12149. * @param isLocal defines if the position should be set in local space
  12150. */
  12151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12152. /**
  12153. * Clones the current emitter and returns a copy of it
  12154. * @returns the new emitter
  12155. */
  12156. clone(): BoxParticleEmitter;
  12157. /**
  12158. * Called by the GPUParticleSystem to setup the update shader
  12159. * @param effect defines the update shader
  12160. */
  12161. applyToShader(effect: Effect): void;
  12162. /**
  12163. * Returns a string to use to update the GPU particles update shader
  12164. * @returns a string containng the defines string
  12165. */
  12166. getEffectDefines(): string;
  12167. /**
  12168. * Returns the string "BoxParticleEmitter"
  12169. * @returns a string containing the class name
  12170. */
  12171. getClassName(): string;
  12172. /**
  12173. * Serializes the particle system to a JSON object.
  12174. * @returns the JSON object
  12175. */
  12176. serialize(): any;
  12177. /**
  12178. * Parse properties from a JSON object
  12179. * @param serializationObject defines the JSON object
  12180. */
  12181. parse(serializationObject: any): void;
  12182. }
  12183. }
  12184. declare module BABYLON {
  12185. /**
  12186. * Particle emitter emitting particles from the inside of a cone.
  12187. * It emits the particles alongside the cone volume from the base to the particle.
  12188. * The emission direction might be randomized.
  12189. */
  12190. export class ConeParticleEmitter implements IParticleEmitterType {
  12191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12192. directionRandomizer: number;
  12193. private _radius;
  12194. private _angle;
  12195. private _height;
  12196. /**
  12197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. radiusRange: number;
  12200. /**
  12201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12202. */
  12203. heightRange: number;
  12204. /**
  12205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12206. */
  12207. emitFromSpawnPointOnly: boolean;
  12208. /**
  12209. * Gets or sets the radius of the emission cone
  12210. */
  12211. get radius(): number;
  12212. set radius(value: number);
  12213. /**
  12214. * Gets or sets the angle of the emission cone
  12215. */
  12216. get angle(): number;
  12217. set angle(value: number);
  12218. private _buildHeight;
  12219. /**
  12220. * Creates a new instance ConeParticleEmitter
  12221. * @param radius the radius of the emission cone (1 by default)
  12222. * @param angle the cone base angle (PI by default)
  12223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12224. */
  12225. constructor(radius?: number, angle?: number,
  12226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12227. directionRandomizer?: number);
  12228. /**
  12229. * Called by the particle System when the direction is computed for the created particle.
  12230. * @param worldMatrix is the world matrix of the particle system
  12231. * @param directionToUpdate is the direction vector to update with the result
  12232. * @param particle is the particle we are computed the direction for
  12233. * @param isLocal defines if the direction should be set in local space
  12234. */
  12235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12236. /**
  12237. * Called by the particle System when the position is computed for the created particle.
  12238. * @param worldMatrix is the world matrix of the particle system
  12239. * @param positionToUpdate is the position vector to update with the result
  12240. * @param particle is the particle we are computed the position for
  12241. * @param isLocal defines if the position should be set in local space
  12242. */
  12243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12244. /**
  12245. * Clones the current emitter and returns a copy of it
  12246. * @returns the new emitter
  12247. */
  12248. clone(): ConeParticleEmitter;
  12249. /**
  12250. * Called by the GPUParticleSystem to setup the update shader
  12251. * @param effect defines the update shader
  12252. */
  12253. applyToShader(effect: Effect): void;
  12254. /**
  12255. * Returns a string to use to update the GPU particles update shader
  12256. * @returns a string containng the defines string
  12257. */
  12258. getEffectDefines(): string;
  12259. /**
  12260. * Returns the string "ConeParticleEmitter"
  12261. * @returns a string containing the class name
  12262. */
  12263. getClassName(): string;
  12264. /**
  12265. * Serializes the particle system to a JSON object.
  12266. * @returns the JSON object
  12267. */
  12268. serialize(): any;
  12269. /**
  12270. * Parse properties from a JSON object
  12271. * @param serializationObject defines the JSON object
  12272. */
  12273. parse(serializationObject: any): void;
  12274. }
  12275. }
  12276. declare module BABYLON {
  12277. /**
  12278. * Particle emitter emitting particles from the inside of a cylinder.
  12279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12280. */
  12281. export class CylinderParticleEmitter implements IParticleEmitterType {
  12282. /**
  12283. * The radius of the emission cylinder.
  12284. */
  12285. radius: number;
  12286. /**
  12287. * The height of the emission cylinder.
  12288. */
  12289. height: number;
  12290. /**
  12291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12292. */
  12293. radiusRange: number;
  12294. /**
  12295. * How much to randomize the particle direction [0-1].
  12296. */
  12297. directionRandomizer: number;
  12298. /**
  12299. * Creates a new instance CylinderParticleEmitter
  12300. * @param radius the radius of the emission cylinder (1 by default)
  12301. * @param height the height of the emission cylinder (1 by default)
  12302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12304. */
  12305. constructor(
  12306. /**
  12307. * The radius of the emission cylinder.
  12308. */
  12309. radius?: number,
  12310. /**
  12311. * The height of the emission cylinder.
  12312. */
  12313. height?: number,
  12314. /**
  12315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12316. */
  12317. radiusRange?: number,
  12318. /**
  12319. * How much to randomize the particle direction [0-1].
  12320. */
  12321. directionRandomizer?: number);
  12322. /**
  12323. * Called by the particle System when the direction is computed for the created particle.
  12324. * @param worldMatrix is the world matrix of the particle system
  12325. * @param directionToUpdate is the direction vector to update with the result
  12326. * @param particle is the particle we are computed the direction for
  12327. * @param isLocal defines if the direction should be set in local space
  12328. */
  12329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12330. /**
  12331. * Called by the particle System when the position is computed for the created particle.
  12332. * @param worldMatrix is the world matrix of the particle system
  12333. * @param positionToUpdate is the position vector to update with the result
  12334. * @param particle is the particle we are computed the position for
  12335. * @param isLocal defines if the position should be set in local space
  12336. */
  12337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12338. /**
  12339. * Clones the current emitter and returns a copy of it
  12340. * @returns the new emitter
  12341. */
  12342. clone(): CylinderParticleEmitter;
  12343. /**
  12344. * Called by the GPUParticleSystem to setup the update shader
  12345. * @param effect defines the update shader
  12346. */
  12347. applyToShader(effect: Effect): void;
  12348. /**
  12349. * Returns a string to use to update the GPU particles update shader
  12350. * @returns a string containng the defines string
  12351. */
  12352. getEffectDefines(): string;
  12353. /**
  12354. * Returns the string "CylinderParticleEmitter"
  12355. * @returns a string containing the class name
  12356. */
  12357. getClassName(): string;
  12358. /**
  12359. * Serializes the particle system to a JSON object.
  12360. * @returns the JSON object
  12361. */
  12362. serialize(): any;
  12363. /**
  12364. * Parse properties from a JSON object
  12365. * @param serializationObject defines the JSON object
  12366. */
  12367. parse(serializationObject: any): void;
  12368. }
  12369. /**
  12370. * Particle emitter emitting particles from the inside of a cylinder.
  12371. * It emits the particles randomly between two vectors.
  12372. */
  12373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12374. /**
  12375. * The min limit of the emission direction.
  12376. */
  12377. direction1: Vector3;
  12378. /**
  12379. * The max limit of the emission direction.
  12380. */
  12381. direction2: Vector3;
  12382. /**
  12383. * Creates a new instance CylinderDirectedParticleEmitter
  12384. * @param radius the radius of the emission cylinder (1 by default)
  12385. * @param height the height of the emission cylinder (1 by default)
  12386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12387. * @param direction1 the min limit of the emission direction (up vector by default)
  12388. * @param direction2 the max limit of the emission direction (up vector by default)
  12389. */
  12390. constructor(radius?: number, height?: number, radiusRange?: number,
  12391. /**
  12392. * The min limit of the emission direction.
  12393. */
  12394. direction1?: Vector3,
  12395. /**
  12396. * The max limit of the emission direction.
  12397. */
  12398. direction2?: Vector3);
  12399. /**
  12400. * Called by the particle System when the direction is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param directionToUpdate is the direction vector to update with the result
  12403. * @param particle is the particle we are computed the direction for
  12404. */
  12405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12406. /**
  12407. * Clones the current emitter and returns a copy of it
  12408. * @returns the new emitter
  12409. */
  12410. clone(): CylinderDirectedParticleEmitter;
  12411. /**
  12412. * Called by the GPUParticleSystem to setup the update shader
  12413. * @param effect defines the update shader
  12414. */
  12415. applyToShader(effect: Effect): void;
  12416. /**
  12417. * Returns a string to use to update the GPU particles update shader
  12418. * @returns a string containng the defines string
  12419. */
  12420. getEffectDefines(): string;
  12421. /**
  12422. * Returns the string "CylinderDirectedParticleEmitter"
  12423. * @returns a string containing the class name
  12424. */
  12425. getClassName(): string;
  12426. /**
  12427. * Serializes the particle system to a JSON object.
  12428. * @returns the JSON object
  12429. */
  12430. serialize(): any;
  12431. /**
  12432. * Parse properties from a JSON object
  12433. * @param serializationObject defines the JSON object
  12434. */
  12435. parse(serializationObject: any): void;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Particle emitter emitting particles from the inside of a hemisphere.
  12441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12442. */
  12443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12444. /**
  12445. * The radius of the emission hemisphere.
  12446. */
  12447. radius: number;
  12448. /**
  12449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12450. */
  12451. radiusRange: number;
  12452. /**
  12453. * How much to randomize the particle direction [0-1].
  12454. */
  12455. directionRandomizer: number;
  12456. /**
  12457. * Creates a new instance HemisphericParticleEmitter
  12458. * @param radius the radius of the emission hemisphere (1 by default)
  12459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12461. */
  12462. constructor(
  12463. /**
  12464. * The radius of the emission hemisphere.
  12465. */
  12466. radius?: number,
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange?: number,
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer?: number);
  12475. /**
  12476. * Called by the particle System when the direction is computed for the created particle.
  12477. * @param worldMatrix is the world matrix of the particle system
  12478. * @param directionToUpdate is the direction vector to update with the result
  12479. * @param particle is the particle we are computed the direction for
  12480. * @param isLocal defines if the direction should be set in local space
  12481. */
  12482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12483. /**
  12484. * Called by the particle System when the position is computed for the created particle.
  12485. * @param worldMatrix is the world matrix of the particle system
  12486. * @param positionToUpdate is the position vector to update with the result
  12487. * @param particle is the particle we are computed the position for
  12488. * @param isLocal defines if the position should be set in local space
  12489. */
  12490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12491. /**
  12492. * Clones the current emitter and returns a copy of it
  12493. * @returns the new emitter
  12494. */
  12495. clone(): HemisphericParticleEmitter;
  12496. /**
  12497. * Called by the GPUParticleSystem to setup the update shader
  12498. * @param effect defines the update shader
  12499. */
  12500. applyToShader(effect: Effect): void;
  12501. /**
  12502. * Returns a string to use to update the GPU particles update shader
  12503. * @returns a string containng the defines string
  12504. */
  12505. getEffectDefines(): string;
  12506. /**
  12507. * Returns the string "HemisphericParticleEmitter"
  12508. * @returns a string containing the class name
  12509. */
  12510. getClassName(): string;
  12511. /**
  12512. * Serializes the particle system to a JSON object.
  12513. * @returns the JSON object
  12514. */
  12515. serialize(): any;
  12516. /**
  12517. * Parse properties from a JSON object
  12518. * @param serializationObject defines the JSON object
  12519. */
  12520. parse(serializationObject: any): void;
  12521. }
  12522. }
  12523. declare module BABYLON {
  12524. /**
  12525. * Particle emitter emitting particles from a point.
  12526. * It emits the particles randomly between 2 given directions.
  12527. */
  12528. export class PointParticleEmitter implements IParticleEmitterType {
  12529. /**
  12530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12531. */
  12532. direction1: Vector3;
  12533. /**
  12534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12535. */
  12536. direction2: Vector3;
  12537. /**
  12538. * Creates a new instance PointParticleEmitter
  12539. */
  12540. constructor();
  12541. /**
  12542. * Called by the particle System when the direction is computed for the created particle.
  12543. * @param worldMatrix is the world matrix of the particle system
  12544. * @param directionToUpdate is the direction vector to update with the result
  12545. * @param particle is the particle we are computed the direction for
  12546. * @param isLocal defines if the direction should be set in local space
  12547. */
  12548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12549. /**
  12550. * Called by the particle System when the position is computed for the created particle.
  12551. * @param worldMatrix is the world matrix of the particle system
  12552. * @param positionToUpdate is the position vector to update with the result
  12553. * @param particle is the particle we are computed the position for
  12554. * @param isLocal defines if the position should be set in local space
  12555. */
  12556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12557. /**
  12558. * Clones the current emitter and returns a copy of it
  12559. * @returns the new emitter
  12560. */
  12561. clone(): PointParticleEmitter;
  12562. /**
  12563. * Called by the GPUParticleSystem to setup the update shader
  12564. * @param effect defines the update shader
  12565. */
  12566. applyToShader(effect: Effect): void;
  12567. /**
  12568. * Returns a string to use to update the GPU particles update shader
  12569. * @returns a string containng the defines string
  12570. */
  12571. getEffectDefines(): string;
  12572. /**
  12573. * Returns the string "PointParticleEmitter"
  12574. * @returns a string containing the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Serializes the particle system to a JSON object.
  12579. * @returns the JSON object
  12580. */
  12581. serialize(): any;
  12582. /**
  12583. * Parse properties from a JSON object
  12584. * @param serializationObject defines the JSON object
  12585. */
  12586. parse(serializationObject: any): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Particle emitter emitting particles from the inside of a sphere.
  12592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12593. */
  12594. export class SphereParticleEmitter implements IParticleEmitterType {
  12595. /**
  12596. * The radius of the emission sphere.
  12597. */
  12598. radius: number;
  12599. /**
  12600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12601. */
  12602. radiusRange: number;
  12603. /**
  12604. * How much to randomize the particle direction [0-1].
  12605. */
  12606. directionRandomizer: number;
  12607. /**
  12608. * Creates a new instance SphereParticleEmitter
  12609. * @param radius the radius of the emission sphere (1 by default)
  12610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12612. */
  12613. constructor(
  12614. /**
  12615. * The radius of the emission sphere.
  12616. */
  12617. radius?: number,
  12618. /**
  12619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12620. */
  12621. radiusRange?: number,
  12622. /**
  12623. * How much to randomize the particle direction [0-1].
  12624. */
  12625. directionRandomizer?: number);
  12626. /**
  12627. * Called by the particle System when the direction is computed for the created particle.
  12628. * @param worldMatrix is the world matrix of the particle system
  12629. * @param directionToUpdate is the direction vector to update with the result
  12630. * @param particle is the particle we are computed the direction for
  12631. * @param isLocal defines if the direction should be set in local space
  12632. */
  12633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12634. /**
  12635. * Called by the particle System when the position is computed for the created particle.
  12636. * @param worldMatrix is the world matrix of the particle system
  12637. * @param positionToUpdate is the position vector to update with the result
  12638. * @param particle is the particle we are computed the position for
  12639. * @param isLocal defines if the position should be set in local space
  12640. */
  12641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12642. /**
  12643. * Clones the current emitter and returns a copy of it
  12644. * @returns the new emitter
  12645. */
  12646. clone(): SphereParticleEmitter;
  12647. /**
  12648. * Called by the GPUParticleSystem to setup the update shader
  12649. * @param effect defines the update shader
  12650. */
  12651. applyToShader(effect: Effect): void;
  12652. /**
  12653. * Returns a string to use to update the GPU particles update shader
  12654. * @returns a string containng the defines string
  12655. */
  12656. getEffectDefines(): string;
  12657. /**
  12658. * Returns the string "SphereParticleEmitter"
  12659. * @returns a string containing the class name
  12660. */
  12661. getClassName(): string;
  12662. /**
  12663. * Serializes the particle system to a JSON object.
  12664. * @returns the JSON object
  12665. */
  12666. serialize(): any;
  12667. /**
  12668. * Parse properties from a JSON object
  12669. * @param serializationObject defines the JSON object
  12670. */
  12671. parse(serializationObject: any): void;
  12672. }
  12673. /**
  12674. * Particle emitter emitting particles from the inside of a sphere.
  12675. * It emits the particles randomly between two vectors.
  12676. */
  12677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12678. /**
  12679. * The min limit of the emission direction.
  12680. */
  12681. direction1: Vector3;
  12682. /**
  12683. * The max limit of the emission direction.
  12684. */
  12685. direction2: Vector3;
  12686. /**
  12687. * Creates a new instance SphereDirectedParticleEmitter
  12688. * @param radius the radius of the emission sphere (1 by default)
  12689. * @param direction1 the min limit of the emission direction (up vector by default)
  12690. * @param direction2 the max limit of the emission direction (up vector by default)
  12691. */
  12692. constructor(radius?: number,
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1?: Vector3,
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2?: Vector3);
  12701. /**
  12702. * Called by the particle System when the direction is computed for the created particle.
  12703. * @param worldMatrix is the world matrix of the particle system
  12704. * @param directionToUpdate is the direction vector to update with the result
  12705. * @param particle is the particle we are computed the direction for
  12706. */
  12707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12708. /**
  12709. * Clones the current emitter and returns a copy of it
  12710. * @returns the new emitter
  12711. */
  12712. clone(): SphereDirectedParticleEmitter;
  12713. /**
  12714. * Called by the GPUParticleSystem to setup the update shader
  12715. * @param effect defines the update shader
  12716. */
  12717. applyToShader(effect: Effect): void;
  12718. /**
  12719. * Returns a string to use to update the GPU particles update shader
  12720. * @returns a string containng the defines string
  12721. */
  12722. getEffectDefines(): string;
  12723. /**
  12724. * Returns the string "SphereDirectedParticleEmitter"
  12725. * @returns a string containing the class name
  12726. */
  12727. getClassName(): string;
  12728. /**
  12729. * Serializes the particle system to a JSON object.
  12730. * @returns the JSON object
  12731. */
  12732. serialize(): any;
  12733. /**
  12734. * Parse properties from a JSON object
  12735. * @param serializationObject defines the JSON object
  12736. */
  12737. parse(serializationObject: any): void;
  12738. }
  12739. }
  12740. declare module BABYLON {
  12741. /**
  12742. * Particle emitter emitting particles from a custom list of positions.
  12743. */
  12744. export class CustomParticleEmitter implements IParticleEmitterType {
  12745. /**
  12746. * Gets or sets the position generator that will create the inital position of each particle.
  12747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12748. */
  12749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12750. /**
  12751. * Gets or sets the destination generator that will create the final destination of each particle.
  12752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12753. */
  12754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12755. /**
  12756. * Creates a new instance CustomParticleEmitter
  12757. */
  12758. constructor();
  12759. /**
  12760. * Called by the particle System when the direction is computed for the created particle.
  12761. * @param worldMatrix is the world matrix of the particle system
  12762. * @param directionToUpdate is the direction vector to update with the result
  12763. * @param particle is the particle we are computed the direction for
  12764. * @param isLocal defines if the direction should be set in local space
  12765. */
  12766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12767. /**
  12768. * Called by the particle System when the position is computed for the created particle.
  12769. * @param worldMatrix is the world matrix of the particle system
  12770. * @param positionToUpdate is the position vector to update with the result
  12771. * @param particle is the particle we are computed the position for
  12772. * @param isLocal defines if the position should be set in local space
  12773. */
  12774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12775. /**
  12776. * Clones the current emitter and returns a copy of it
  12777. * @returns the new emitter
  12778. */
  12779. clone(): CustomParticleEmitter;
  12780. /**
  12781. * Called by the GPUParticleSystem to setup the update shader
  12782. * @param effect defines the update shader
  12783. */
  12784. applyToShader(effect: Effect): void;
  12785. /**
  12786. * Returns a string to use to update the GPU particles update shader
  12787. * @returns a string containng the defines string
  12788. */
  12789. getEffectDefines(): string;
  12790. /**
  12791. * Returns the string "PointParticleEmitter"
  12792. * @returns a string containing the class name
  12793. */
  12794. getClassName(): string;
  12795. /**
  12796. * Serializes the particle system to a JSON object.
  12797. * @returns the JSON object
  12798. */
  12799. serialize(): any;
  12800. /**
  12801. * Parse properties from a JSON object
  12802. * @param serializationObject defines the JSON object
  12803. */
  12804. parse(serializationObject: any): void;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Particle emitter emitting particles from the inside of a box.
  12810. * It emits the particles randomly between 2 given directions.
  12811. */
  12812. export class MeshParticleEmitter implements IParticleEmitterType {
  12813. /** Defines the mesh to use as source */
  12814. mesh?: AbstractMesh | undefined;
  12815. private _indices;
  12816. private _positions;
  12817. private _normals;
  12818. private _storedNormal;
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12829. */
  12830. useMeshNormalsForDirection: boolean;
  12831. /**
  12832. * Creates a new instance MeshParticleEmitter
  12833. * @param mesh defines the mesh to use as source
  12834. */
  12835. constructor(
  12836. /** Defines the mesh to use as source */
  12837. mesh?: AbstractMesh | undefined);
  12838. /**
  12839. * Called by the particle System when the direction is computed for the created particle.
  12840. * @param worldMatrix is the world matrix of the particle system
  12841. * @param directionToUpdate is the direction vector to update with the result
  12842. * @param particle is the particle we are computed the direction for
  12843. * @param isLocal defines if the direction should be set in local space
  12844. */
  12845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12846. /**
  12847. * Called by the particle System when the position is computed for the created particle.
  12848. * @param worldMatrix is the world matrix of the particle system
  12849. * @param positionToUpdate is the position vector to update with the result
  12850. * @param particle is the particle we are computed the position for
  12851. * @param isLocal defines if the position should be set in local space
  12852. */
  12853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12854. /**
  12855. * Clones the current emitter and returns a copy of it
  12856. * @returns the new emitter
  12857. */
  12858. clone(): MeshParticleEmitter;
  12859. /**
  12860. * Called by the GPUParticleSystem to setup the update shader
  12861. * @param effect defines the update shader
  12862. */
  12863. applyToShader(effect: Effect): void;
  12864. /**
  12865. * Returns a string to use to update the GPU particles update shader
  12866. * @returns a string containng the defines string
  12867. */
  12868. getEffectDefines(): string;
  12869. /**
  12870. * Returns the string "BoxParticleEmitter"
  12871. * @returns a string containing the class name
  12872. */
  12873. getClassName(): string;
  12874. /**
  12875. * Serializes the particle system to a JSON object.
  12876. * @returns the JSON object
  12877. */
  12878. serialize(): any;
  12879. /**
  12880. * Parse properties from a JSON object
  12881. * @param serializationObject defines the JSON object
  12882. * @param scene defines the hosting scene
  12883. */
  12884. parse(serializationObject: any, scene: Scene): void;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * Interface representing a particle system in Babylon.js.
  12890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12892. */
  12893. export interface IParticleSystem {
  12894. /**
  12895. * List of animations used by the particle system.
  12896. */
  12897. animations: Animation[];
  12898. /**
  12899. * The id of the Particle system.
  12900. */
  12901. id: string;
  12902. /**
  12903. * The name of the Particle system.
  12904. */
  12905. name: string;
  12906. /**
  12907. * The emitter represents the Mesh or position we are attaching the particle system to.
  12908. */
  12909. emitter: Nullable<AbstractMesh | Vector3>;
  12910. /**
  12911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12912. */
  12913. isBillboardBased: boolean;
  12914. /**
  12915. * The rendering group used by the Particle system to chose when to render.
  12916. */
  12917. renderingGroupId: number;
  12918. /**
  12919. * The layer mask we are rendering the particles through.
  12920. */
  12921. layerMask: number;
  12922. /**
  12923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12924. */
  12925. updateSpeed: number;
  12926. /**
  12927. * The amount of time the particle system is running (depends of the overall update speed).
  12928. */
  12929. targetStopDuration: number;
  12930. /**
  12931. * The texture used to render each particle. (this can be a spritesheet)
  12932. */
  12933. particleTexture: Nullable<Texture>;
  12934. /**
  12935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12936. */
  12937. blendMode: number;
  12938. /**
  12939. * Minimum life time of emitting particles.
  12940. */
  12941. minLifeTime: number;
  12942. /**
  12943. * Maximum life time of emitting particles.
  12944. */
  12945. maxLifeTime: number;
  12946. /**
  12947. * Minimum Size of emitting particles.
  12948. */
  12949. minSize: number;
  12950. /**
  12951. * Maximum Size of emitting particles.
  12952. */
  12953. maxSize: number;
  12954. /**
  12955. * Minimum scale of emitting particles on X axis.
  12956. */
  12957. minScaleX: number;
  12958. /**
  12959. * Maximum scale of emitting particles on X axis.
  12960. */
  12961. maxScaleX: number;
  12962. /**
  12963. * Minimum scale of emitting particles on Y axis.
  12964. */
  12965. minScaleY: number;
  12966. /**
  12967. * Maximum scale of emitting particles on Y axis.
  12968. */
  12969. maxScaleY: number;
  12970. /**
  12971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12972. */
  12973. color1: Color4;
  12974. /**
  12975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12976. */
  12977. color2: Color4;
  12978. /**
  12979. * Color the particle will have at the end of its lifetime.
  12980. */
  12981. colorDead: Color4;
  12982. /**
  12983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12984. */
  12985. emitRate: number;
  12986. /**
  12987. * You can use gravity if you want to give an orientation to your particles.
  12988. */
  12989. gravity: Vector3;
  12990. /**
  12991. * Minimum power of emitting particles.
  12992. */
  12993. minEmitPower: number;
  12994. /**
  12995. * Maximum power of emitting particles.
  12996. */
  12997. maxEmitPower: number;
  12998. /**
  12999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13000. */
  13001. minAngularSpeed: number;
  13002. /**
  13003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13004. */
  13005. maxAngularSpeed: number;
  13006. /**
  13007. * Gets or sets the minimal initial rotation in radians.
  13008. */
  13009. minInitialRotation: number;
  13010. /**
  13011. * Gets or sets the maximal initial rotation in radians.
  13012. */
  13013. maxInitialRotation: number;
  13014. /**
  13015. * The particle emitter type defines the emitter used by the particle system.
  13016. * It can be for example box, sphere, or cone...
  13017. */
  13018. particleEmitterType: Nullable<IParticleEmitterType>;
  13019. /**
  13020. * Defines the delay in milliseconds before starting the system (0 by default)
  13021. */
  13022. startDelay: number;
  13023. /**
  13024. * 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
  13025. */
  13026. preWarmCycles: number;
  13027. /**
  13028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13029. */
  13030. preWarmStepOffset: number;
  13031. /**
  13032. * 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)
  13033. */
  13034. spriteCellChangeSpeed: number;
  13035. /**
  13036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13037. */
  13038. startSpriteCellID: number;
  13039. /**
  13040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13041. */
  13042. endSpriteCellID: number;
  13043. /**
  13044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13045. */
  13046. spriteCellWidth: number;
  13047. /**
  13048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13049. */
  13050. spriteCellHeight: number;
  13051. /**
  13052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13053. */
  13054. spriteRandomStartCell: boolean;
  13055. /**
  13056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13057. */
  13058. isAnimationSheetEnabled: boolean;
  13059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13060. translationPivot: Vector2;
  13061. /**
  13062. * Gets or sets a texture used to add random noise to particle positions
  13063. */
  13064. noiseTexture: Nullable<BaseTexture>;
  13065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13066. noiseStrength: Vector3;
  13067. /**
  13068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13070. */
  13071. billboardMode: number;
  13072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13073. limitVelocityDamping: number;
  13074. /**
  13075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13076. */
  13077. beginAnimationOnStart: boolean;
  13078. /**
  13079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13080. */
  13081. beginAnimationFrom: number;
  13082. /**
  13083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13084. */
  13085. beginAnimationTo: number;
  13086. /**
  13087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13088. */
  13089. beginAnimationLoop: boolean;
  13090. /**
  13091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13092. */
  13093. disposeOnStop: boolean;
  13094. /**
  13095. * Specifies if the particles are updated in emitter local space or world space
  13096. */
  13097. isLocal: boolean;
  13098. /**
  13099. * Gets the maximum number of particles active at the same time.
  13100. * @returns The max number of active particles.
  13101. */
  13102. getCapacity(): number;
  13103. /**
  13104. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13105. * @returns True if it has been started, otherwise false.
  13106. */
  13107. isStarted(): boolean;
  13108. /**
  13109. * Animates the particle system for this frame.
  13110. */
  13111. animate(): void;
  13112. /**
  13113. * Renders the particle system in its current state.
  13114. * @returns the current number of particles
  13115. */
  13116. render(): number;
  13117. /**
  13118. * Dispose the particle system and frees its associated resources.
  13119. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13120. */
  13121. dispose(disposeTexture?: boolean): void;
  13122. /**
  13123. * Clones the particle system.
  13124. * @param name The name of the cloned object
  13125. * @param newEmitter The new emitter to use
  13126. * @returns the cloned particle system
  13127. */
  13128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13129. /**
  13130. * Serializes the particle system to a JSON object.
  13131. * @returns the JSON object
  13132. */
  13133. serialize(): any;
  13134. /**
  13135. * Rebuild the particle system
  13136. */
  13137. rebuild(): void;
  13138. /**
  13139. * Starts the particle system and begins to emit
  13140. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13141. */
  13142. start(delay?: number): void;
  13143. /**
  13144. * Stops the particle system.
  13145. */
  13146. stop(): void;
  13147. /**
  13148. * Remove all active particles
  13149. */
  13150. reset(): void;
  13151. /**
  13152. * Is this system ready to be used/rendered
  13153. * @return true if the system is ready
  13154. */
  13155. isReady(): boolean;
  13156. /**
  13157. * Adds a new color gradient
  13158. * @param gradient defines the gradient to use (between 0 and 1)
  13159. * @param color1 defines the color to affect to the specified gradient
  13160. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13161. * @returns the current particle system
  13162. */
  13163. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13164. /**
  13165. * Remove a specific color gradient
  13166. * @param gradient defines the gradient to remove
  13167. * @returns the current particle system
  13168. */
  13169. removeColorGradient(gradient: number): IParticleSystem;
  13170. /**
  13171. * Adds a new size gradient
  13172. * @param gradient defines the gradient to use (between 0 and 1)
  13173. * @param factor defines the size factor to affect to the specified gradient
  13174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13175. * @returns the current particle system
  13176. */
  13177. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13178. /**
  13179. * Remove a specific size gradient
  13180. * @param gradient defines the gradient to remove
  13181. * @returns the current particle system
  13182. */
  13183. removeSizeGradient(gradient: number): IParticleSystem;
  13184. /**
  13185. * Gets the current list of color gradients.
  13186. * You must use addColorGradient and removeColorGradient to udpate this list
  13187. * @returns the list of color gradients
  13188. */
  13189. getColorGradients(): Nullable<Array<ColorGradient>>;
  13190. /**
  13191. * Gets the current list of size gradients.
  13192. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13193. * @returns the list of size gradients
  13194. */
  13195. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13196. /**
  13197. * Gets the current list of angular speed gradients.
  13198. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13199. * @returns the list of angular speed gradients
  13200. */
  13201. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13202. /**
  13203. * Adds a new angular speed gradient
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the angular speed to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific angular speed gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13216. /**
  13217. * Gets the current list of velocity gradients.
  13218. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13219. * @returns the list of velocity gradients
  13220. */
  13221. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13222. /**
  13223. * Adds a new velocity gradient
  13224. * @param gradient defines the gradient to use (between 0 and 1)
  13225. * @param factor defines the velocity to affect to the specified gradient
  13226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13227. * @returns the current particle system
  13228. */
  13229. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13230. /**
  13231. * Remove a specific velocity gradient
  13232. * @param gradient defines the gradient to remove
  13233. * @returns the current particle system
  13234. */
  13235. removeVelocityGradient(gradient: number): IParticleSystem;
  13236. /**
  13237. * Gets the current list of limit velocity gradients.
  13238. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13239. * @returns the list of limit velocity gradients
  13240. */
  13241. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13242. /**
  13243. * Adds a new limit velocity gradient
  13244. * @param gradient defines the gradient to use (between 0 and 1)
  13245. * @param factor defines the limit velocity to affect to the specified gradient
  13246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13247. * @returns the current particle system
  13248. */
  13249. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13250. /**
  13251. * Remove a specific limit velocity gradient
  13252. * @param gradient defines the gradient to remove
  13253. * @returns the current particle system
  13254. */
  13255. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13256. /**
  13257. * Adds a new drag gradient
  13258. * @param gradient defines the gradient to use (between 0 and 1)
  13259. * @param factor defines the drag to affect to the specified gradient
  13260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13261. * @returns the current particle system
  13262. */
  13263. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13264. /**
  13265. * Remove a specific drag gradient
  13266. * @param gradient defines the gradient to remove
  13267. * @returns the current particle system
  13268. */
  13269. removeDragGradient(gradient: number): IParticleSystem;
  13270. /**
  13271. * Gets the current list of drag gradients.
  13272. * You must use addDragGradient and removeDragGradient to udpate this list
  13273. * @returns the list of drag gradients
  13274. */
  13275. getDragGradients(): Nullable<Array<FactorGradient>>;
  13276. /**
  13277. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13278. * @param gradient defines the gradient to use (between 0 and 1)
  13279. * @param factor defines the emit rate to affect to the specified gradient
  13280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13281. * @returns the current particle system
  13282. */
  13283. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13284. /**
  13285. * Remove a specific emit rate gradient
  13286. * @param gradient defines the gradient to remove
  13287. * @returns the current particle system
  13288. */
  13289. removeEmitRateGradient(gradient: number): IParticleSystem;
  13290. /**
  13291. * Gets the current list of emit rate gradients.
  13292. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13293. * @returns the list of emit rate gradients
  13294. */
  13295. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13296. /**
  13297. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13298. * @param gradient defines the gradient to use (between 0 and 1)
  13299. * @param factor defines the start size to affect to the specified gradient
  13300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13301. * @returns the current particle system
  13302. */
  13303. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13304. /**
  13305. * Remove a specific start size gradient
  13306. * @param gradient defines the gradient to remove
  13307. * @returns the current particle system
  13308. */
  13309. removeStartSizeGradient(gradient: number): IParticleSystem;
  13310. /**
  13311. * Gets the current list of start size gradients.
  13312. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13313. * @returns the list of start size gradients
  13314. */
  13315. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13316. /**
  13317. * Adds a new life time gradient
  13318. * @param gradient defines the gradient to use (between 0 and 1)
  13319. * @param factor defines the life time factor to affect to the specified gradient
  13320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13321. * @returns the current particle system
  13322. */
  13323. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13324. /**
  13325. * Remove a specific life time gradient
  13326. * @param gradient defines the gradient to remove
  13327. * @returns the current particle system
  13328. */
  13329. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13330. /**
  13331. * Gets the current list of life time gradients.
  13332. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13333. * @returns the list of life time gradients
  13334. */
  13335. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13336. /**
  13337. * Gets the current list of color gradients.
  13338. * You must use addColorGradient and removeColorGradient to udpate this list
  13339. * @returns the list of color gradients
  13340. */
  13341. getColorGradients(): Nullable<Array<ColorGradient>>;
  13342. /**
  13343. * Adds a new ramp gradient used to remap particle colors
  13344. * @param gradient defines the gradient to use (between 0 and 1)
  13345. * @param color defines the color to affect to the specified gradient
  13346. * @returns the current particle system
  13347. */
  13348. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13349. /**
  13350. * Gets the current list of ramp gradients.
  13351. * You must use addRampGradient and removeRampGradient to udpate this list
  13352. * @returns the list of ramp gradients
  13353. */
  13354. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13355. /** Gets or sets a boolean indicating that ramp gradients must be used
  13356. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13357. */
  13358. useRampGradients: boolean;
  13359. /**
  13360. * Adds a new color remap gradient
  13361. * @param gradient defines the gradient to use (between 0 and 1)
  13362. * @param min defines the color remap minimal range
  13363. * @param max defines the color remap maximal range
  13364. * @returns the current particle system
  13365. */
  13366. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of color remap gradients.
  13369. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13370. * @returns the list of color remap gradients
  13371. */
  13372. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13373. /**
  13374. * Adds a new alpha remap gradient
  13375. * @param gradient defines the gradient to use (between 0 and 1)
  13376. * @param min defines the alpha remap minimal range
  13377. * @param max defines the alpha remap maximal range
  13378. * @returns the current particle system
  13379. */
  13380. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13381. /**
  13382. * Gets the current list of alpha remap gradients.
  13383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13384. * @returns the list of alpha remap gradients
  13385. */
  13386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13387. /**
  13388. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13391. * @returns the emitter
  13392. */
  13393. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13394. /**
  13395. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13396. * @param radius The radius of the hemisphere to emit from
  13397. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13398. * @returns the emitter
  13399. */
  13400. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13401. /**
  13402. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13403. * @param radius The radius of the sphere to emit from
  13404. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13405. * @returns the emitter
  13406. */
  13407. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13408. /**
  13409. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13410. * @param radius The radius of the sphere to emit from
  13411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13413. * @returns the emitter
  13414. */
  13415. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13416. /**
  13417. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13418. * @param radius The radius of the emission cylinder
  13419. * @param height The height of the emission cylinder
  13420. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13421. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13422. * @returns the emitter
  13423. */
  13424. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13425. /**
  13426. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13427. * @param radius The radius of the cylinder to emit from
  13428. * @param height The height of the emission cylinder
  13429. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13432. * @returns the emitter
  13433. */
  13434. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13435. /**
  13436. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13437. * @param radius The radius of the cone to emit from
  13438. * @param angle The base angle of the cone
  13439. * @returns the emitter
  13440. */
  13441. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13442. /**
  13443. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13446. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13447. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13448. * @returns the emitter
  13449. */
  13450. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13451. /**
  13452. * Get hosting scene
  13453. * @returns the scene
  13454. */
  13455. getScene(): Scene;
  13456. }
  13457. }
  13458. declare module BABYLON {
  13459. /**
  13460. * 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.
  13461. * @see https://doc.babylonjs.com/how_to/transformnode
  13462. */
  13463. export class TransformNode extends Node {
  13464. /**
  13465. * Object will not rotate to face the camera
  13466. */
  13467. static BILLBOARDMODE_NONE: number;
  13468. /**
  13469. * Object will rotate to face the camera but only on the x axis
  13470. */
  13471. static BILLBOARDMODE_X: number;
  13472. /**
  13473. * Object will rotate to face the camera but only on the y axis
  13474. */
  13475. static BILLBOARDMODE_Y: number;
  13476. /**
  13477. * Object will rotate to face the camera but only on the z axis
  13478. */
  13479. static BILLBOARDMODE_Z: number;
  13480. /**
  13481. * Object will rotate to face the camera
  13482. */
  13483. static BILLBOARDMODE_ALL: number;
  13484. /**
  13485. * Object will rotate to face the camera's position instead of orientation
  13486. */
  13487. static BILLBOARDMODE_USE_POSITION: number;
  13488. private _forward;
  13489. private _forwardInverted;
  13490. private _up;
  13491. private _right;
  13492. private _rightInverted;
  13493. private _position;
  13494. private _rotation;
  13495. private _rotationQuaternion;
  13496. protected _scaling: Vector3;
  13497. protected _isDirty: boolean;
  13498. private _transformToBoneReferal;
  13499. private _isAbsoluteSynced;
  13500. private _billboardMode;
  13501. /**
  13502. * Gets or sets the billboard mode. Default is 0.
  13503. *
  13504. * | Value | Type | Description |
  13505. * | --- | --- | --- |
  13506. * | 0 | BILLBOARDMODE_NONE | |
  13507. * | 1 | BILLBOARDMODE_X | |
  13508. * | 2 | BILLBOARDMODE_Y | |
  13509. * | 4 | BILLBOARDMODE_Z | |
  13510. * | 7 | BILLBOARDMODE_ALL | |
  13511. *
  13512. */
  13513. get billboardMode(): number;
  13514. set billboardMode(value: number);
  13515. private _preserveParentRotationForBillboard;
  13516. /**
  13517. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13518. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13519. */
  13520. get preserveParentRotationForBillboard(): boolean;
  13521. set preserveParentRotationForBillboard(value: boolean);
  13522. /**
  13523. * 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
  13524. */
  13525. scalingDeterminant: number;
  13526. private _infiniteDistance;
  13527. /**
  13528. * Gets or sets the distance of the object to max, often used by skybox
  13529. */
  13530. get infiniteDistance(): boolean;
  13531. set infiniteDistance(value: boolean);
  13532. /**
  13533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13534. * By default the system will update normals to compensate
  13535. */
  13536. ignoreNonUniformScaling: boolean;
  13537. /**
  13538. * 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
  13539. */
  13540. reIntegrateRotationIntoRotationQuaternion: boolean;
  13541. /** @hidden */
  13542. _poseMatrix: Nullable<Matrix>;
  13543. /** @hidden */
  13544. _localMatrix: Matrix;
  13545. private _usePivotMatrix;
  13546. private _absolutePosition;
  13547. private _absoluteScaling;
  13548. private _absoluteRotationQuaternion;
  13549. private _pivotMatrix;
  13550. private _pivotMatrixInverse;
  13551. protected _postMultiplyPivotMatrix: boolean;
  13552. protected _isWorldMatrixFrozen: boolean;
  13553. /** @hidden */
  13554. _indexInSceneTransformNodesArray: number;
  13555. /**
  13556. * An event triggered after the world matrix is updated
  13557. */
  13558. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13559. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13560. /**
  13561. * Gets a string identifying the name of the class
  13562. * @returns "TransformNode" string
  13563. */
  13564. getClassName(): string;
  13565. /**
  13566. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13567. */
  13568. get position(): Vector3;
  13569. set position(newPosition: Vector3);
  13570. /**
  13571. * 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)).
  13572. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13573. */
  13574. get rotation(): Vector3;
  13575. set rotation(newRotation: Vector3);
  13576. /**
  13577. * 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)).
  13578. */
  13579. get scaling(): Vector3;
  13580. set scaling(newScaling: Vector3);
  13581. /**
  13582. * 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).
  13583. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13584. */
  13585. get rotationQuaternion(): Nullable<Quaternion>;
  13586. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13587. /**
  13588. * The forward direction of that transform in world space.
  13589. */
  13590. get forward(): Vector3;
  13591. /**
  13592. * The up direction of that transform in world space.
  13593. */
  13594. get up(): Vector3;
  13595. /**
  13596. * The right direction of that transform in world space.
  13597. */
  13598. get right(): Vector3;
  13599. /**
  13600. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13601. * @param matrix the matrix to copy the pose from
  13602. * @returns this TransformNode.
  13603. */
  13604. updatePoseMatrix(matrix: Matrix): TransformNode;
  13605. /**
  13606. * Returns the mesh Pose matrix.
  13607. * @returns the pose matrix
  13608. */
  13609. getPoseMatrix(): Matrix;
  13610. /** @hidden */
  13611. _isSynchronized(): boolean;
  13612. /** @hidden */
  13613. _initCache(): void;
  13614. /**
  13615. * Flag the transform node as dirty (Forcing it to update everything)
  13616. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13617. * @returns this transform node
  13618. */
  13619. markAsDirty(property: string): TransformNode;
  13620. /**
  13621. * Returns the current mesh absolute position.
  13622. * Returns a Vector3.
  13623. */
  13624. get absolutePosition(): Vector3;
  13625. /**
  13626. * Returns the current mesh absolute scaling.
  13627. * Returns a Vector3.
  13628. */
  13629. get absoluteScaling(): Vector3;
  13630. /**
  13631. * Returns the current mesh absolute rotation.
  13632. * Returns a Quaternion.
  13633. */
  13634. get absoluteRotationQuaternion(): Quaternion;
  13635. /**
  13636. * Sets a new matrix to apply before all other transformation
  13637. * @param matrix defines the transform matrix
  13638. * @returns the current TransformNode
  13639. */
  13640. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13641. /**
  13642. * Sets a new pivot matrix to the current node
  13643. * @param matrix defines the new pivot matrix to use
  13644. * @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
  13645. * @returns the current TransformNode
  13646. */
  13647. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13648. /**
  13649. * Returns the mesh pivot matrix.
  13650. * Default : Identity.
  13651. * @returns the matrix
  13652. */
  13653. getPivotMatrix(): Matrix;
  13654. /**
  13655. * Instantiate (when possible) or clone that node with its hierarchy
  13656. * @param newParent defines the new parent to use for the instance (or clone)
  13657. * @param options defines options to configure how copy is done
  13658. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13659. * @returns an instance (or a clone) of the current node with its hiearchy
  13660. */
  13661. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13662. doNotInstantiate: boolean;
  13663. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13664. /**
  13665. * Prevents the World matrix to be computed any longer
  13666. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13667. * @returns the TransformNode.
  13668. */
  13669. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13670. /**
  13671. * Allows back the World matrix computation.
  13672. * @returns the TransformNode.
  13673. */
  13674. unfreezeWorldMatrix(): this;
  13675. /**
  13676. * True if the World matrix has been frozen.
  13677. */
  13678. get isWorldMatrixFrozen(): boolean;
  13679. /**
  13680. * Retuns the mesh absolute position in the World.
  13681. * @returns a Vector3.
  13682. */
  13683. getAbsolutePosition(): Vector3;
  13684. /**
  13685. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13686. * @param absolutePosition the absolute position to set
  13687. * @returns the TransformNode.
  13688. */
  13689. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13690. /**
  13691. * Sets the mesh position in its local space.
  13692. * @param vector3 the position to set in localspace
  13693. * @returns the TransformNode.
  13694. */
  13695. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13696. /**
  13697. * Returns the mesh position in the local space from the current World matrix values.
  13698. * @returns a new Vector3.
  13699. */
  13700. getPositionExpressedInLocalSpace(): Vector3;
  13701. /**
  13702. * Translates the mesh along the passed Vector3 in its local space.
  13703. * @param vector3 the distance to translate in localspace
  13704. * @returns the TransformNode.
  13705. */
  13706. locallyTranslate(vector3: Vector3): TransformNode;
  13707. private static _lookAtVectorCache;
  13708. /**
  13709. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13710. * @param targetPoint the position (must be in same space as current mesh) to look at
  13711. * @param yawCor optional yaw (y-axis) correction in radians
  13712. * @param pitchCor optional pitch (x-axis) correction in radians
  13713. * @param rollCor optional roll (z-axis) correction in radians
  13714. * @param space the choosen space of the target
  13715. * @returns the TransformNode.
  13716. */
  13717. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13718. /**
  13719. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13720. * This Vector3 is expressed in the World space.
  13721. * @param localAxis axis to rotate
  13722. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13723. */
  13724. getDirection(localAxis: Vector3): Vector3;
  13725. /**
  13726. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13727. * localAxis is expressed in the mesh local space.
  13728. * result is computed in the Wordl space from the mesh World matrix.
  13729. * @param localAxis axis to rotate
  13730. * @param result the resulting transformnode
  13731. * @returns this TransformNode.
  13732. */
  13733. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13734. /**
  13735. * Sets this transform node rotation to the given local axis.
  13736. * @param localAxis the axis in local space
  13737. * @param yawCor optional yaw (y-axis) correction in radians
  13738. * @param pitchCor optional pitch (x-axis) correction in radians
  13739. * @param rollCor optional roll (z-axis) correction in radians
  13740. * @returns this TransformNode
  13741. */
  13742. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13743. /**
  13744. * Sets a new pivot point to the current node
  13745. * @param point defines the new pivot point to use
  13746. * @param space defines if the point is in world or local space (local by default)
  13747. * @returns the current TransformNode
  13748. */
  13749. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13750. /**
  13751. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13752. * @returns the pivot point
  13753. */
  13754. getPivotPoint(): Vector3;
  13755. /**
  13756. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13757. * @param result the vector3 to store the result
  13758. * @returns this TransformNode.
  13759. */
  13760. getPivotPointToRef(result: Vector3): TransformNode;
  13761. /**
  13762. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13763. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13764. */
  13765. getAbsolutePivotPoint(): Vector3;
  13766. /**
  13767. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13768. * @param result vector3 to store the result
  13769. * @returns this TransformNode.
  13770. */
  13771. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13772. /**
  13773. * Defines the passed node as the parent of the current node.
  13774. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13775. * @see https://doc.babylonjs.com/how_to/parenting
  13776. * @param node the node ot set as the parent
  13777. * @returns this TransformNode.
  13778. */
  13779. setParent(node: Nullable<Node>): TransformNode;
  13780. private _nonUniformScaling;
  13781. /**
  13782. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13783. */
  13784. get nonUniformScaling(): boolean;
  13785. /** @hidden */
  13786. _updateNonUniformScalingState(value: boolean): boolean;
  13787. /**
  13788. * Attach the current TransformNode to another TransformNode associated with a bone
  13789. * @param bone Bone affecting the TransformNode
  13790. * @param affectedTransformNode TransformNode associated with the bone
  13791. * @returns this object
  13792. */
  13793. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13794. /**
  13795. * Detach the transform node if its associated with a bone
  13796. * @returns this object
  13797. */
  13798. detachFromBone(): TransformNode;
  13799. private static _rotationAxisCache;
  13800. /**
  13801. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13804. * The passed axis is also normalized.
  13805. * @param axis the axis to rotate around
  13806. * @param amount the amount to rotate in radians
  13807. * @param space Space to rotate in (Default: local)
  13808. * @returns the TransformNode.
  13809. */
  13810. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13811. /**
  13812. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13813. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13814. * The passed axis is also normalized. .
  13815. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13816. * @param point the point to rotate around
  13817. * @param axis the axis to rotate around
  13818. * @param amount the amount to rotate in radians
  13819. * @returns the TransformNode
  13820. */
  13821. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13822. /**
  13823. * Translates the mesh along the axis vector for the passed distance in the given space.
  13824. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13825. * @param axis the axis to translate in
  13826. * @param distance the distance to translate
  13827. * @param space Space to rotate in (Default: local)
  13828. * @returns the TransformNode.
  13829. */
  13830. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13831. /**
  13832. * Adds a rotation step to the mesh current rotation.
  13833. * x, y, z are Euler angles expressed in radians.
  13834. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13835. * This means this rotation is made in the mesh local space only.
  13836. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13837. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13838. * ```javascript
  13839. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13840. * ```
  13841. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13842. * 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.
  13843. * @param x Rotation to add
  13844. * @param y Rotation to add
  13845. * @param z Rotation to add
  13846. * @returns the TransformNode.
  13847. */
  13848. addRotation(x: number, y: number, z: number): TransformNode;
  13849. /**
  13850. * @hidden
  13851. */
  13852. protected _getEffectiveParent(): Nullable<Node>;
  13853. /**
  13854. * Computes the world matrix of the node
  13855. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13856. * @returns the world matrix
  13857. */
  13858. computeWorldMatrix(force?: boolean): Matrix;
  13859. /**
  13860. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13861. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13862. */
  13863. resetLocalMatrix(independentOfChildren?: boolean): void;
  13864. protected _afterComputeWorldMatrix(): void;
  13865. /**
  13866. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13867. * @param func callback function to add
  13868. *
  13869. * @returns the TransformNode.
  13870. */
  13871. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13872. /**
  13873. * Removes a registered callback function.
  13874. * @param func callback function to remove
  13875. * @returns the TransformNode.
  13876. */
  13877. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13878. /**
  13879. * Gets the position of the current mesh in camera space
  13880. * @param camera defines the camera to use
  13881. * @returns a position
  13882. */
  13883. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13884. /**
  13885. * Returns the distance from the mesh to the active camera
  13886. * @param camera defines the camera to use
  13887. * @returns the distance
  13888. */
  13889. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13890. /**
  13891. * Clone the current transform node
  13892. * @param name Name of the new clone
  13893. * @param newParent New parent for the clone
  13894. * @param doNotCloneChildren Do not clone children hierarchy
  13895. * @returns the new transform node
  13896. */
  13897. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13898. /**
  13899. * Serializes the objects information.
  13900. * @param currentSerializationObject defines the object to serialize in
  13901. * @returns the serialized object
  13902. */
  13903. serialize(currentSerializationObject?: any): any;
  13904. /**
  13905. * Returns a new TransformNode object parsed from the source provided.
  13906. * @param parsedTransformNode is the source.
  13907. * @param scene the scne the object belongs to
  13908. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13909. * @returns a new TransformNode object parsed from the source provided.
  13910. */
  13911. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13912. /**
  13913. * Get all child-transformNodes of this node
  13914. * @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
  13915. * @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
  13916. * @returns an array of TransformNode
  13917. */
  13918. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13919. /**
  13920. * Releases resources associated with this transform node.
  13921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13923. */
  13924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13925. /**
  13926. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13927. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13928. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13929. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13930. * @returns the current mesh
  13931. */
  13932. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13933. private _syncAbsoluteScalingAndRotation;
  13934. }
  13935. }
  13936. declare module BABYLON {
  13937. /**
  13938. * Class used to override all child animations of a given target
  13939. */
  13940. export class AnimationPropertiesOverride {
  13941. /**
  13942. * Gets or sets a value indicating if animation blending must be used
  13943. */
  13944. enableBlending: boolean;
  13945. /**
  13946. * Gets or sets the blending speed to use when enableBlending is true
  13947. */
  13948. blendingSpeed: number;
  13949. /**
  13950. * Gets or sets the default loop mode to use
  13951. */
  13952. loopMode: number;
  13953. }
  13954. }
  13955. declare module BABYLON {
  13956. /**
  13957. * Class used to store bone information
  13958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13959. */
  13960. export class Bone extends Node {
  13961. /**
  13962. * defines the bone name
  13963. */
  13964. name: string;
  13965. private static _tmpVecs;
  13966. private static _tmpQuat;
  13967. private static _tmpMats;
  13968. /**
  13969. * Gets the list of child bones
  13970. */
  13971. children: Bone[];
  13972. /** Gets the animations associated with this bone */
  13973. animations: Animation[];
  13974. /**
  13975. * Gets or sets bone length
  13976. */
  13977. length: number;
  13978. /**
  13979. * @hidden Internal only
  13980. * Set this value to map this bone to a different index in the transform matrices
  13981. * Set this value to -1 to exclude the bone from the transform matrices
  13982. */
  13983. _index: Nullable<number>;
  13984. private _skeleton;
  13985. private _localMatrix;
  13986. private _restPose;
  13987. private _baseMatrix;
  13988. private _absoluteTransform;
  13989. private _invertedAbsoluteTransform;
  13990. private _parent;
  13991. private _scalingDeterminant;
  13992. private _worldTransform;
  13993. private _localScaling;
  13994. private _localRotation;
  13995. private _localPosition;
  13996. private _needToDecompose;
  13997. private _needToCompose;
  13998. /** @hidden */
  13999. _linkedTransformNode: Nullable<TransformNode>;
  14000. /** @hidden */
  14001. _waitingTransformNodeId: Nullable<string>;
  14002. /** @hidden */
  14003. get _matrix(): Matrix;
  14004. /** @hidden */
  14005. set _matrix(value: Matrix);
  14006. /**
  14007. * Create a new bone
  14008. * @param name defines the bone name
  14009. * @param skeleton defines the parent skeleton
  14010. * @param parentBone defines the parent (can be null if the bone is the root)
  14011. * @param localMatrix defines the local matrix
  14012. * @param restPose defines the rest pose matrix
  14013. * @param baseMatrix defines the base matrix
  14014. * @param index defines index of the bone in the hiearchy
  14015. */
  14016. constructor(
  14017. /**
  14018. * defines the bone name
  14019. */
  14020. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14021. /**
  14022. * Gets the current object class name.
  14023. * @return the class name
  14024. */
  14025. getClassName(): string;
  14026. /**
  14027. * Gets the parent skeleton
  14028. * @returns a skeleton
  14029. */
  14030. getSkeleton(): Skeleton;
  14031. /**
  14032. * Gets parent bone
  14033. * @returns a bone or null if the bone is the root of the bone hierarchy
  14034. */
  14035. getParent(): Nullable<Bone>;
  14036. /**
  14037. * Returns an array containing the root bones
  14038. * @returns an array containing the root bones
  14039. */
  14040. getChildren(): Array<Bone>;
  14041. /**
  14042. * Gets the node index in matrix array generated for rendering
  14043. * @returns the node index
  14044. */
  14045. getIndex(): number;
  14046. /**
  14047. * Sets the parent bone
  14048. * @param parent defines the parent (can be null if the bone is the root)
  14049. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14050. */
  14051. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14052. /**
  14053. * Gets the local matrix
  14054. * @returns a matrix
  14055. */
  14056. getLocalMatrix(): Matrix;
  14057. /**
  14058. * Gets the base matrix (initial matrix which remains unchanged)
  14059. * @returns a matrix
  14060. */
  14061. getBaseMatrix(): Matrix;
  14062. /**
  14063. * Gets the rest pose matrix
  14064. * @returns a matrix
  14065. */
  14066. getRestPose(): Matrix;
  14067. /**
  14068. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14069. */
  14070. getWorldMatrix(): Matrix;
  14071. /**
  14072. * Sets the local matrix to rest pose matrix
  14073. */
  14074. returnToRest(): void;
  14075. /**
  14076. * Gets the inverse of the absolute transform matrix.
  14077. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14078. * @returns a matrix
  14079. */
  14080. getInvertedAbsoluteTransform(): Matrix;
  14081. /**
  14082. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14083. * @returns a matrix
  14084. */
  14085. getAbsoluteTransform(): Matrix;
  14086. /**
  14087. * Links with the given transform node.
  14088. * The local matrix of this bone is copied from the transform node every frame.
  14089. * @param transformNode defines the transform node to link to
  14090. */
  14091. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14092. /**
  14093. * Gets the node used to drive the bone's transformation
  14094. * @returns a transform node or null
  14095. */
  14096. getTransformNode(): Nullable<TransformNode>;
  14097. /** Gets or sets current position (in local space) */
  14098. get position(): Vector3;
  14099. set position(newPosition: Vector3);
  14100. /** Gets or sets current rotation (in local space) */
  14101. get rotation(): Vector3;
  14102. set rotation(newRotation: Vector3);
  14103. /** Gets or sets current rotation quaternion (in local space) */
  14104. get rotationQuaternion(): Quaternion;
  14105. set rotationQuaternion(newRotation: Quaternion);
  14106. /** Gets or sets current scaling (in local space) */
  14107. get scaling(): Vector3;
  14108. set scaling(newScaling: Vector3);
  14109. /**
  14110. * Gets the animation properties override
  14111. */
  14112. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14113. private _decompose;
  14114. private _compose;
  14115. /**
  14116. * Update the base and local matrices
  14117. * @param matrix defines the new base or local matrix
  14118. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14119. * @param updateLocalMatrix defines if the local matrix should be updated
  14120. */
  14121. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14122. /** @hidden */
  14123. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14124. /**
  14125. * Flag the bone as dirty (Forcing it to update everything)
  14126. */
  14127. markAsDirty(): void;
  14128. /** @hidden */
  14129. _markAsDirtyAndCompose(): void;
  14130. private _markAsDirtyAndDecompose;
  14131. /**
  14132. * Translate the bone in local or world space
  14133. * @param vec The amount to translate the bone
  14134. * @param space The space that the translation is in
  14135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14136. */
  14137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14138. /**
  14139. * Set the postion of the bone in local or world space
  14140. * @param position The position to set the bone
  14141. * @param space The space that the position is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the absolute position of the bone (world space)
  14147. * @param position The position to set the bone
  14148. * @param mesh The mesh that this bone is attached to
  14149. */
  14150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14151. /**
  14152. * Scale the bone on the x, y and z axes (in local space)
  14153. * @param x The amount to scale the bone on the x axis
  14154. * @param y The amount to scale the bone on the y axis
  14155. * @param z The amount to scale the bone on the z axis
  14156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14157. */
  14158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14159. /**
  14160. * Set the bone scaling in local space
  14161. * @param scale defines the scaling vector
  14162. */
  14163. setScale(scale: Vector3): void;
  14164. /**
  14165. * Gets the current scaling in local space
  14166. * @returns the current scaling vector
  14167. */
  14168. getScale(): Vector3;
  14169. /**
  14170. * Gets the current scaling in local space and stores it in a target vector
  14171. * @param result defines the target vector
  14172. */
  14173. getScaleToRef(result: Vector3): void;
  14174. /**
  14175. * Set the yaw, pitch, and roll of the bone in local or world space
  14176. * @param yaw The rotation of the bone on the y axis
  14177. * @param pitch The rotation of the bone on the x axis
  14178. * @param roll The rotation of the bone on the z axis
  14179. * @param space The space that the axes of rotation are in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. */
  14182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14183. /**
  14184. * Add a rotation to the bone on an axis in local or world space
  14185. * @param axis The axis to rotate the bone on
  14186. * @param amount The amount to rotate the bone
  14187. * @param space The space that the axis is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation of the bone to a particular axis angle in local or world space
  14193. * @param axis The axis to rotate the bone on
  14194. * @param angle The angle that the bone should be rotated to
  14195. * @param space The space that the axis is in
  14196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14197. */
  14198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14199. /**
  14200. * Set the euler rotation of the bone in local of world space
  14201. * @param rotation The euler rotation that the bone should be set to
  14202. * @param space The space that the rotation is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the quaternion rotation of the bone in local of world space
  14208. * @param quat The quaternion rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the rotation matrix of the bone in local of world space
  14215. * @param rotMat The rotation matrix that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14220. private _rotateWithMatrix;
  14221. private _getNegativeRotationToRef;
  14222. /**
  14223. * Get the position of the bone in local or world space
  14224. * @param space The space that the returned position is in
  14225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14226. * @returns The position of the bone
  14227. */
  14228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14229. /**
  14230. * Copy the position of the bone to a vector3 in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @param result The vector3 to copy the position to
  14234. */
  14235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14236. /**
  14237. * Get the absolute position of the bone (world space)
  14238. * @param mesh The mesh that this bone is attached to
  14239. * @returns The absolute position of the bone
  14240. */
  14241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14242. /**
  14243. * Copy the absolute position of the bone (world space) to the result param
  14244. * @param mesh The mesh that this bone is attached to
  14245. * @param result The vector3 to copy the absolute position to
  14246. */
  14247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14248. /**
  14249. * Compute the absolute transforms of this bone and its children
  14250. */
  14251. computeAbsoluteTransforms(): void;
  14252. /**
  14253. * Get the world direction from an axis that is in the local space of the bone
  14254. * @param localAxis The local direction that is used to compute the world direction
  14255. * @param mesh The mesh that this bone is attached to
  14256. * @returns The world direction
  14257. */
  14258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14259. /**
  14260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @param result The vector3 that the world direction will be copied to
  14264. */
  14265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14266. /**
  14267. * Get the euler rotation of the bone in local or world space
  14268. * @param space The space that the rotation should be in
  14269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14270. * @returns The euler rotation
  14271. */
  14272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14273. /**
  14274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @param result The vector3 that the rotation should be copied to
  14278. */
  14279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14280. /**
  14281. * Get the quaternion rotation of the bone in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @returns The quaternion rotation
  14285. */
  14286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14287. /**
  14288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @param result The quaternion that the rotation should be copied to
  14292. */
  14293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14294. /**
  14295. * Get the rotation matrix of the bone in local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @returns The rotation matrix
  14299. */
  14300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14301. /**
  14302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @param result The quaternion that the rotation should be copied to
  14306. */
  14307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14308. /**
  14309. * Get the world position of a point that is in the local space of the bone
  14310. * @param position The local position
  14311. * @param mesh The mesh that this bone is attached to
  14312. * @returns The world position
  14313. */
  14314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @param result The vector3 that the world position should be copied to
  14320. */
  14321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the local position of a point that is in world space
  14324. * @param position The world position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @returns The local position
  14327. */
  14328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14329. /**
  14330. * Get the local position of a point that is in world space and copy it to the result param
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @param result The vector3 that the local position should be copied to
  14334. */
  14335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14336. }
  14337. }
  14338. declare module BABYLON {
  14339. /**
  14340. * Defines a runtime animation
  14341. */
  14342. export class RuntimeAnimation {
  14343. private _events;
  14344. /**
  14345. * The current frame of the runtime animation
  14346. */
  14347. private _currentFrame;
  14348. /**
  14349. * The animation used by the runtime animation
  14350. */
  14351. private _animation;
  14352. /**
  14353. * The target of the runtime animation
  14354. */
  14355. private _target;
  14356. /**
  14357. * The initiating animatable
  14358. */
  14359. private _host;
  14360. /**
  14361. * The original value of the runtime animation
  14362. */
  14363. private _originalValue;
  14364. /**
  14365. * The original blend value of the runtime animation
  14366. */
  14367. private _originalBlendValue;
  14368. /**
  14369. * The offsets cache of the runtime animation
  14370. */
  14371. private _offsetsCache;
  14372. /**
  14373. * The high limits cache of the runtime animation
  14374. */
  14375. private _highLimitsCache;
  14376. /**
  14377. * Specifies if the runtime animation has been stopped
  14378. */
  14379. private _stopped;
  14380. /**
  14381. * The blending factor of the runtime animation
  14382. */
  14383. private _blendingFactor;
  14384. /**
  14385. * The BabylonJS scene
  14386. */
  14387. private _scene;
  14388. /**
  14389. * The current value of the runtime animation
  14390. */
  14391. private _currentValue;
  14392. /** @hidden */
  14393. _animationState: _IAnimationState;
  14394. /**
  14395. * The active target of the runtime animation
  14396. */
  14397. private _activeTargets;
  14398. private _currentActiveTarget;
  14399. private _directTarget;
  14400. /**
  14401. * The target path of the runtime animation
  14402. */
  14403. private _targetPath;
  14404. /**
  14405. * The weight of the runtime animation
  14406. */
  14407. private _weight;
  14408. /**
  14409. * The ratio offset of the runtime animation
  14410. */
  14411. private _ratioOffset;
  14412. /**
  14413. * The previous delay of the runtime animation
  14414. */
  14415. private _previousDelay;
  14416. /**
  14417. * The previous ratio of the runtime animation
  14418. */
  14419. private _previousRatio;
  14420. private _enableBlending;
  14421. private _keys;
  14422. private _minFrame;
  14423. private _maxFrame;
  14424. private _minValue;
  14425. private _maxValue;
  14426. private _targetIsArray;
  14427. /**
  14428. * Gets the current frame of the runtime animation
  14429. */
  14430. get currentFrame(): number;
  14431. /**
  14432. * Gets the weight of the runtime animation
  14433. */
  14434. get weight(): number;
  14435. /**
  14436. * Gets the current value of the runtime animation
  14437. */
  14438. get currentValue(): any;
  14439. /**
  14440. * Gets the target path of the runtime animation
  14441. */
  14442. get targetPath(): string;
  14443. /**
  14444. * Gets the actual target of the runtime animation
  14445. */
  14446. get target(): any;
  14447. /** @hidden */
  14448. _onLoop: () => void;
  14449. /**
  14450. * Create a new RuntimeAnimation object
  14451. * @param target defines the target of the animation
  14452. * @param animation defines the source animation object
  14453. * @param scene defines the hosting scene
  14454. * @param host defines the initiating Animatable
  14455. */
  14456. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14457. private _preparePath;
  14458. /**
  14459. * Gets the animation from the runtime animation
  14460. */
  14461. get animation(): Animation;
  14462. /**
  14463. * Resets the runtime animation to the beginning
  14464. * @param restoreOriginal defines whether to restore the target property to the original value
  14465. */
  14466. reset(restoreOriginal?: boolean): void;
  14467. /**
  14468. * Specifies if the runtime animation is stopped
  14469. * @returns Boolean specifying if the runtime animation is stopped
  14470. */
  14471. isStopped(): boolean;
  14472. /**
  14473. * Disposes of the runtime animation
  14474. */
  14475. dispose(): void;
  14476. /**
  14477. * Apply the interpolated value to the target
  14478. * @param currentValue defines the value computed by the animation
  14479. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14480. */
  14481. setValue(currentValue: any, weight: number): void;
  14482. private _getOriginalValues;
  14483. private _setValue;
  14484. /**
  14485. * Gets the loop pmode of the runtime animation
  14486. * @returns Loop Mode
  14487. */
  14488. private _getCorrectLoopMode;
  14489. /**
  14490. * Move the current animation to a given frame
  14491. * @param frame defines the frame to move to
  14492. */
  14493. goToFrame(frame: number): void;
  14494. /**
  14495. * @hidden Internal use only
  14496. */
  14497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14498. /**
  14499. * Execute the current animation
  14500. * @param delay defines the delay to add to the current frame
  14501. * @param from defines the lower bound of the animation range
  14502. * @param to defines the upper bound of the animation range
  14503. * @param loop defines if the current animation must loop
  14504. * @param speedRatio defines the current speed ratio
  14505. * @param weight defines the weight of the animation (default is -1 so no weight)
  14506. * @param onLoop optional callback called when animation loops
  14507. * @returns a boolean indicating if the animation is running
  14508. */
  14509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. /**
  14514. * Class used to store an actual running animation
  14515. */
  14516. export class Animatable {
  14517. /** defines the target object */
  14518. target: any;
  14519. /** defines the starting frame number (default is 0) */
  14520. fromFrame: number;
  14521. /** defines the ending frame number (default is 100) */
  14522. toFrame: number;
  14523. /** defines if the animation must loop (default is false) */
  14524. loopAnimation: boolean;
  14525. /** defines a callback to call when animation ends if it is not looping */
  14526. onAnimationEnd?: (() => void) | null | undefined;
  14527. /** defines a callback to call when animation loops */
  14528. onAnimationLoop?: (() => void) | null | undefined;
  14529. private _localDelayOffset;
  14530. private _pausedDelay;
  14531. private _runtimeAnimations;
  14532. private _paused;
  14533. private _scene;
  14534. private _speedRatio;
  14535. private _weight;
  14536. private _syncRoot;
  14537. /**
  14538. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14539. * This will only apply for non looping animation (default is true)
  14540. */
  14541. disposeOnEnd: boolean;
  14542. /**
  14543. * Gets a boolean indicating if the animation has started
  14544. */
  14545. animationStarted: boolean;
  14546. /**
  14547. * Observer raised when the animation ends
  14548. */
  14549. onAnimationEndObservable: Observable<Animatable>;
  14550. /**
  14551. * Observer raised when the animation loops
  14552. */
  14553. onAnimationLoopObservable: Observable<Animatable>;
  14554. /**
  14555. * Gets the root Animatable used to synchronize and normalize animations
  14556. */
  14557. get syncRoot(): Nullable<Animatable>;
  14558. /**
  14559. * Gets the current frame of the first RuntimeAnimation
  14560. * Used to synchronize Animatables
  14561. */
  14562. get masterFrame(): number;
  14563. /**
  14564. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14565. */
  14566. get weight(): number;
  14567. set weight(value: number);
  14568. /**
  14569. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14570. */
  14571. get speedRatio(): number;
  14572. set speedRatio(value: number);
  14573. /**
  14574. * Creates a new Animatable
  14575. * @param scene defines the hosting scene
  14576. * @param target defines the target object
  14577. * @param fromFrame defines the starting frame number (default is 0)
  14578. * @param toFrame defines the ending frame number (default is 100)
  14579. * @param loopAnimation defines if the animation must loop (default is false)
  14580. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14581. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14582. * @param animations defines a group of animation to add to the new Animatable
  14583. * @param onAnimationLoop defines a callback to call when animation loops
  14584. */
  14585. constructor(scene: Scene,
  14586. /** defines the target object */
  14587. target: any,
  14588. /** defines the starting frame number (default is 0) */
  14589. fromFrame?: number,
  14590. /** defines the ending frame number (default is 100) */
  14591. toFrame?: number,
  14592. /** defines if the animation must loop (default is false) */
  14593. loopAnimation?: boolean, speedRatio?: number,
  14594. /** defines a callback to call when animation ends if it is not looping */
  14595. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14596. /** defines a callback to call when animation loops */
  14597. onAnimationLoop?: (() => void) | null | undefined);
  14598. /**
  14599. * Synchronize and normalize current Animatable with a source Animatable
  14600. * This is useful when using animation weights and when animations are not of the same length
  14601. * @param root defines the root Animatable to synchronize with
  14602. * @returns the current Animatable
  14603. */
  14604. syncWith(root: Animatable): Animatable;
  14605. /**
  14606. * Gets the list of runtime animations
  14607. * @returns an array of RuntimeAnimation
  14608. */
  14609. getAnimations(): RuntimeAnimation[];
  14610. /**
  14611. * Adds more animations to the current animatable
  14612. * @param target defines the target of the animations
  14613. * @param animations defines the new animations to add
  14614. */
  14615. appendAnimations(target: any, animations: Animation[]): void;
  14616. /**
  14617. * Gets the source animation for a specific property
  14618. * @param property defines the propertyu to look for
  14619. * @returns null or the source animation for the given property
  14620. */
  14621. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14622. /**
  14623. * Gets the runtime animation for a specific property
  14624. * @param property defines the propertyu to look for
  14625. * @returns null or the runtime animation for the given property
  14626. */
  14627. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14628. /**
  14629. * Resets the animatable to its original state
  14630. */
  14631. reset(): void;
  14632. /**
  14633. * Allows the animatable to blend with current running animations
  14634. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14635. * @param blendingSpeed defines the blending speed to use
  14636. */
  14637. enableBlending(blendingSpeed: number): void;
  14638. /**
  14639. * Disable animation blending
  14640. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14641. */
  14642. disableBlending(): void;
  14643. /**
  14644. * Jump directly to a given frame
  14645. * @param frame defines the frame to jump to
  14646. */
  14647. goToFrame(frame: number): void;
  14648. /**
  14649. * Pause the animation
  14650. */
  14651. pause(): void;
  14652. /**
  14653. * Restart the animation
  14654. */
  14655. restart(): void;
  14656. private _raiseOnAnimationEnd;
  14657. /**
  14658. * Stop and delete the current animation
  14659. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14660. * @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)
  14661. */
  14662. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14663. /**
  14664. * Wait asynchronously for the animation to end
  14665. * @returns a promise which will be fullfilled when the animation ends
  14666. */
  14667. waitAsync(): Promise<Animatable>;
  14668. /** @hidden */
  14669. _animate(delay: number): boolean;
  14670. }
  14671. interface Scene {
  14672. /** @hidden */
  14673. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14674. /** @hidden */
  14675. _processLateAnimationBindingsForMatrices(holder: {
  14676. totalWeight: number;
  14677. animations: RuntimeAnimation[];
  14678. originalValue: Matrix;
  14679. }): any;
  14680. /** @hidden */
  14681. _processLateAnimationBindingsForQuaternions(holder: {
  14682. totalWeight: number;
  14683. animations: RuntimeAnimation[];
  14684. originalValue: Quaternion;
  14685. }, refQuaternion: Quaternion): Quaternion;
  14686. /** @hidden */
  14687. _processLateAnimationBindings(): void;
  14688. /**
  14689. * Will start the animation sequence of a given target
  14690. * @param target defines the target
  14691. * @param from defines from which frame should animation start
  14692. * @param to defines until which frame should animation run.
  14693. * @param weight defines the weight to apply to the animation (1.0 by default)
  14694. * @param loop defines if the animation loops
  14695. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14696. * @param onAnimationEnd defines the function to be executed when the animation ends
  14697. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14698. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14699. * @param onAnimationLoop defines the callback to call when an animation loops
  14700. * @returns the animatable object created for this animation
  14701. */
  14702. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14703. /**
  14704. * Will start the animation sequence of a given target
  14705. * @param target defines the target
  14706. * @param from defines from which frame should animation start
  14707. * @param to defines until which frame should animation run.
  14708. * @param loop defines if the animation loops
  14709. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14710. * @param onAnimationEnd defines the function to be executed when the animation ends
  14711. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14712. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14713. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14714. * @param onAnimationLoop defines the callback to call when an animation loops
  14715. * @returns the animatable object created for this animation
  14716. */
  14717. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14718. /**
  14719. * Will start the animation sequence of a given target and its hierarchy
  14720. * @param target defines the target
  14721. * @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.
  14722. * @param from defines from which frame should animation start
  14723. * @param to defines until which frame should animation run.
  14724. * @param loop defines if the animation loops
  14725. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14726. * @param onAnimationEnd defines the function to be executed when the animation ends
  14727. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14728. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14729. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14730. * @param onAnimationLoop defines the callback to call when an animation loops
  14731. * @returns the list of created animatables
  14732. */
  14733. 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[];
  14734. /**
  14735. * Begin a new animation on a given node
  14736. * @param target defines the target where the animation will take place
  14737. * @param animations defines the list of animations to start
  14738. * @param from defines the initial value
  14739. * @param to defines the final value
  14740. * @param loop defines if you want animation to loop (off by default)
  14741. * @param speedRatio defines the speed ratio to apply to all animations
  14742. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14743. * @param onAnimationLoop defines the callback to call when an animation loops
  14744. * @returns the list of created animatables
  14745. */
  14746. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14747. /**
  14748. * Begin a new animation on a given node and its hierarchy
  14749. * @param target defines the root node where the animation will take place
  14750. * @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.
  14751. * @param animations defines the list of animations to start
  14752. * @param from defines the initial value
  14753. * @param to defines the final value
  14754. * @param loop defines if you want animation to loop (off by default)
  14755. * @param speedRatio defines the speed ratio to apply to all animations
  14756. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14757. * @param onAnimationLoop defines the callback to call when an animation loops
  14758. * @returns the list of animatables created for all nodes
  14759. */
  14760. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14761. /**
  14762. * Gets the animatable associated with a specific target
  14763. * @param target defines the target of the animatable
  14764. * @returns the required animatable if found
  14765. */
  14766. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14767. /**
  14768. * Gets all animatables associated with a given target
  14769. * @param target defines the target to look animatables for
  14770. * @returns an array of Animatables
  14771. */
  14772. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14773. /**
  14774. * Stops and removes all animations that have been applied to the scene
  14775. */
  14776. stopAllAnimations(): void;
  14777. /**
  14778. * Gets the current delta time used by animation engine
  14779. */
  14780. deltaTime: number;
  14781. }
  14782. interface Bone {
  14783. /**
  14784. * Copy an animation range from another bone
  14785. * @param source defines the source bone
  14786. * @param rangeName defines the range name to copy
  14787. * @param frameOffset defines the frame offset
  14788. * @param rescaleAsRequired defines if rescaling must be applied if required
  14789. * @param skelDimensionsRatio defines the scaling ratio
  14790. * @returns true if operation was successful
  14791. */
  14792. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14793. }
  14794. }
  14795. declare module BABYLON {
  14796. /**
  14797. * Class used to handle skinning animations
  14798. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14799. */
  14800. export class Skeleton implements IAnimatable {
  14801. /** defines the skeleton name */
  14802. name: string;
  14803. /** defines the skeleton Id */
  14804. id: string;
  14805. /**
  14806. * Defines the list of child bones
  14807. */
  14808. bones: Bone[];
  14809. /**
  14810. * Defines an estimate of the dimension of the skeleton at rest
  14811. */
  14812. dimensionsAtRest: Vector3;
  14813. /**
  14814. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14815. */
  14816. needInitialSkinMatrix: boolean;
  14817. /**
  14818. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14819. */
  14820. overrideMesh: Nullable<AbstractMesh>;
  14821. /**
  14822. * Gets the list of animations attached to this skeleton
  14823. */
  14824. animations: Array<Animation>;
  14825. private _scene;
  14826. private _isDirty;
  14827. private _transformMatrices;
  14828. private _transformMatrixTexture;
  14829. private _meshesWithPoseMatrix;
  14830. private _animatables;
  14831. private _identity;
  14832. private _synchronizedWithMesh;
  14833. private _ranges;
  14834. private _lastAbsoluteTransformsUpdateId;
  14835. private _canUseTextureForBones;
  14836. private _uniqueId;
  14837. /** @hidden */
  14838. _numBonesWithLinkedTransformNode: number;
  14839. /** @hidden */
  14840. _hasWaitingData: Nullable<boolean>;
  14841. /**
  14842. * Specifies if the skeleton should be serialized
  14843. */
  14844. doNotSerialize: boolean;
  14845. private _useTextureToStoreBoneMatrices;
  14846. /**
  14847. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14848. * Please note that this option is not available if the hardware does not support it
  14849. */
  14850. get useTextureToStoreBoneMatrices(): boolean;
  14851. set useTextureToStoreBoneMatrices(value: boolean);
  14852. private _animationPropertiesOverride;
  14853. /**
  14854. * Gets or sets the animation properties override
  14855. */
  14856. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14857. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14858. /**
  14859. * List of inspectable custom properties (used by the Inspector)
  14860. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14861. */
  14862. inspectableCustomProperties: IInspectable[];
  14863. /**
  14864. * An observable triggered before computing the skeleton's matrices
  14865. */
  14866. onBeforeComputeObservable: Observable<Skeleton>;
  14867. /**
  14868. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14869. */
  14870. get isUsingTextureForMatrices(): boolean;
  14871. /**
  14872. * Gets the unique ID of this skeleton
  14873. */
  14874. get uniqueId(): number;
  14875. /**
  14876. * Creates a new skeleton
  14877. * @param name defines the skeleton name
  14878. * @param id defines the skeleton Id
  14879. * @param scene defines the hosting scene
  14880. */
  14881. constructor(
  14882. /** defines the skeleton name */
  14883. name: string,
  14884. /** defines the skeleton Id */
  14885. id: string, scene: Scene);
  14886. /**
  14887. * Gets the current object class name.
  14888. * @return the class name
  14889. */
  14890. getClassName(): string;
  14891. /**
  14892. * Returns an array containing the root bones
  14893. * @returns an array containing the root bones
  14894. */
  14895. getChildren(): Array<Bone>;
  14896. /**
  14897. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14898. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14899. * @returns a Float32Array containing matrices data
  14900. */
  14901. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14902. /**
  14903. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14904. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14905. * @returns a raw texture containing the data
  14906. */
  14907. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14908. /**
  14909. * Gets the current hosting scene
  14910. * @returns a scene object
  14911. */
  14912. getScene(): Scene;
  14913. /**
  14914. * Gets a string representing the current skeleton data
  14915. * @param fullDetails defines a boolean indicating if we want a verbose version
  14916. * @returns a string representing the current skeleton data
  14917. */
  14918. toString(fullDetails?: boolean): string;
  14919. /**
  14920. * Get bone's index searching by name
  14921. * @param name defines bone's name to search for
  14922. * @return the indice of the bone. Returns -1 if not found
  14923. */
  14924. getBoneIndexByName(name: string): number;
  14925. /**
  14926. * Creater a new animation range
  14927. * @param name defines the name of the range
  14928. * @param from defines the start key
  14929. * @param to defines the end key
  14930. */
  14931. createAnimationRange(name: string, from: number, to: number): void;
  14932. /**
  14933. * Delete a specific animation range
  14934. * @param name defines the name of the range
  14935. * @param deleteFrames defines if frames must be removed as well
  14936. */
  14937. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14938. /**
  14939. * Gets a specific animation range
  14940. * @param name defines the name of the range to look for
  14941. * @returns the requested animation range or null if not found
  14942. */
  14943. getAnimationRange(name: string): Nullable<AnimationRange>;
  14944. /**
  14945. * Gets the list of all animation ranges defined on this skeleton
  14946. * @returns an array
  14947. */
  14948. getAnimationRanges(): Nullable<AnimationRange>[];
  14949. /**
  14950. * Copy animation range from a source skeleton.
  14951. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14952. * @param source defines the source skeleton
  14953. * @param name defines the name of the range to copy
  14954. * @param rescaleAsRequired defines if rescaling must be applied if required
  14955. * @returns true if operation was successful
  14956. */
  14957. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14958. /**
  14959. * Forces the skeleton to go to rest pose
  14960. */
  14961. returnToRest(): void;
  14962. private _getHighestAnimationFrame;
  14963. /**
  14964. * Begin a specific animation range
  14965. * @param name defines the name of the range to start
  14966. * @param loop defines if looping must be turned on (false by default)
  14967. * @param speedRatio defines the speed ratio to apply (1 by default)
  14968. * @param onAnimationEnd defines a callback which will be called when animation will end
  14969. * @returns a new animatable
  14970. */
  14971. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14972. /** @hidden */
  14973. _markAsDirty(): void;
  14974. /** @hidden */
  14975. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14976. /** @hidden */
  14977. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14978. private _computeTransformMatrices;
  14979. /**
  14980. * Build all resources required to render a skeleton
  14981. */
  14982. prepare(): void;
  14983. /**
  14984. * Gets the list of animatables currently running for this skeleton
  14985. * @returns an array of animatables
  14986. */
  14987. getAnimatables(): IAnimatable[];
  14988. /**
  14989. * Clone the current skeleton
  14990. * @param name defines the name of the new skeleton
  14991. * @param id defines the id of the new skeleton
  14992. * @returns the new skeleton
  14993. */
  14994. clone(name: string, id?: string): Skeleton;
  14995. /**
  14996. * Enable animation blending for this skeleton
  14997. * @param blendingSpeed defines the blending speed to apply
  14998. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14999. */
  15000. enableBlending(blendingSpeed?: number): void;
  15001. /**
  15002. * Releases all resources associated with the current skeleton
  15003. */
  15004. dispose(): void;
  15005. /**
  15006. * Serialize the skeleton in a JSON object
  15007. * @returns a JSON object
  15008. */
  15009. serialize(): any;
  15010. /**
  15011. * Creates a new skeleton from serialized data
  15012. * @param parsedSkeleton defines the serialized data
  15013. * @param scene defines the hosting scene
  15014. * @returns a new skeleton
  15015. */
  15016. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15017. /**
  15018. * Compute all node absolute transforms
  15019. * @param forceUpdate defines if computation must be done even if cache is up to date
  15020. */
  15021. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15022. /**
  15023. * Gets the root pose matrix
  15024. * @returns a matrix
  15025. */
  15026. getPoseMatrix(): Nullable<Matrix>;
  15027. /**
  15028. * Sorts bones per internal index
  15029. */
  15030. sortBones(): void;
  15031. private _sortBones;
  15032. }
  15033. }
  15034. declare module BABYLON {
  15035. /**
  15036. * Creates an instance based on a source mesh.
  15037. */
  15038. export class InstancedMesh extends AbstractMesh {
  15039. private _sourceMesh;
  15040. private _currentLOD;
  15041. /** @hidden */
  15042. _indexInSourceMeshInstanceArray: number;
  15043. constructor(name: string, source: Mesh);
  15044. /**
  15045. * Returns the string "InstancedMesh".
  15046. */
  15047. getClassName(): string;
  15048. /** Gets the list of lights affecting that mesh */
  15049. get lightSources(): Light[];
  15050. _resyncLightSources(): void;
  15051. _resyncLightSource(light: Light): void;
  15052. _removeLightSource(light: Light, dispose: boolean): void;
  15053. /**
  15054. * If the source mesh receives shadows
  15055. */
  15056. get receiveShadows(): boolean;
  15057. /**
  15058. * The material of the source mesh
  15059. */
  15060. get material(): Nullable<Material>;
  15061. /**
  15062. * Visibility of the source mesh
  15063. */
  15064. get visibility(): number;
  15065. /**
  15066. * Skeleton of the source mesh
  15067. */
  15068. get skeleton(): Nullable<Skeleton>;
  15069. /**
  15070. * Rendering ground id of the source mesh
  15071. */
  15072. get renderingGroupId(): number;
  15073. set renderingGroupId(value: number);
  15074. /**
  15075. * Returns the total number of vertices (integer).
  15076. */
  15077. getTotalVertices(): number;
  15078. /**
  15079. * Returns a positive integer : the total number of indices in this mesh geometry.
  15080. * @returns the numner of indices or zero if the mesh has no geometry.
  15081. */
  15082. getTotalIndices(): number;
  15083. /**
  15084. * The source mesh of the instance
  15085. */
  15086. get sourceMesh(): Mesh;
  15087. /**
  15088. * Is this node ready to be used/rendered
  15089. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15090. * @return {boolean} is it ready
  15091. */
  15092. isReady(completeCheck?: boolean): boolean;
  15093. /**
  15094. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15095. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15096. * @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.
  15097. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15098. */
  15099. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15100. /**
  15101. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15102. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15103. * The `data` are either a numeric array either a Float32Array.
  15104. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15105. * 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).
  15106. * Note that a new underlying VertexBuffer object is created each call.
  15107. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15108. *
  15109. * Possible `kind` values :
  15110. * - VertexBuffer.PositionKind
  15111. * - VertexBuffer.UVKind
  15112. * - VertexBuffer.UV2Kind
  15113. * - VertexBuffer.UV3Kind
  15114. * - VertexBuffer.UV4Kind
  15115. * - VertexBuffer.UV5Kind
  15116. * - VertexBuffer.UV6Kind
  15117. * - VertexBuffer.ColorKind
  15118. * - VertexBuffer.MatricesIndicesKind
  15119. * - VertexBuffer.MatricesIndicesExtraKind
  15120. * - VertexBuffer.MatricesWeightsKind
  15121. * - VertexBuffer.MatricesWeightsExtraKind
  15122. *
  15123. * Returns the Mesh.
  15124. */
  15125. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15126. /**
  15127. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15128. * If the mesh has no geometry, it is simply returned as it is.
  15129. * The `data` are either a numeric array either a Float32Array.
  15130. * No new underlying VertexBuffer object is created.
  15131. * 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.
  15132. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15133. *
  15134. * Possible `kind` values :
  15135. * - VertexBuffer.PositionKind
  15136. * - VertexBuffer.UVKind
  15137. * - VertexBuffer.UV2Kind
  15138. * - VertexBuffer.UV3Kind
  15139. * - VertexBuffer.UV4Kind
  15140. * - VertexBuffer.UV5Kind
  15141. * - VertexBuffer.UV6Kind
  15142. * - VertexBuffer.ColorKind
  15143. * - VertexBuffer.MatricesIndicesKind
  15144. * - VertexBuffer.MatricesIndicesExtraKind
  15145. * - VertexBuffer.MatricesWeightsKind
  15146. * - VertexBuffer.MatricesWeightsExtraKind
  15147. *
  15148. * Returns the Mesh.
  15149. */
  15150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15151. /**
  15152. * Sets the mesh indices.
  15153. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15154. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15155. * This method creates a new index buffer each call.
  15156. * Returns the Mesh.
  15157. */
  15158. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15159. /**
  15160. * Boolean : True if the mesh owns the requested kind of data.
  15161. */
  15162. isVerticesDataPresent(kind: string): boolean;
  15163. /**
  15164. * Returns an array of indices (IndicesArray).
  15165. */
  15166. getIndices(): Nullable<IndicesArray>;
  15167. get _positions(): Nullable<Vector3[]>;
  15168. /**
  15169. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15170. * This means the mesh underlying bounding box and sphere are recomputed.
  15171. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15172. * @returns the current mesh
  15173. */
  15174. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15175. /** @hidden */
  15176. _preActivate(): InstancedMesh;
  15177. /** @hidden */
  15178. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15179. /** @hidden */
  15180. _postActivate(): void;
  15181. getWorldMatrix(): Matrix;
  15182. get isAnInstance(): boolean;
  15183. /**
  15184. * Returns the current associated LOD AbstractMesh.
  15185. */
  15186. getLOD(camera: Camera): AbstractMesh;
  15187. /** @hidden */
  15188. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15189. /** @hidden */
  15190. _syncSubMeshes(): InstancedMesh;
  15191. /** @hidden */
  15192. _generatePointsArray(): boolean;
  15193. /**
  15194. * Creates a new InstancedMesh from the current mesh.
  15195. * - name (string) : the cloned mesh name
  15196. * - newParent (optional Node) : the optional Node to parent the clone to.
  15197. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15198. *
  15199. * Returns the clone.
  15200. */
  15201. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15202. /**
  15203. * Disposes the InstancedMesh.
  15204. * Returns nothing.
  15205. */
  15206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15207. }
  15208. interface Mesh {
  15209. /**
  15210. * Register a custom buffer that will be instanced
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. * @param kind defines the buffer kind
  15213. * @param stride defines the stride in floats
  15214. */
  15215. registerInstancedBuffer(kind: string, stride: number): void;
  15216. /** @hidden */
  15217. _userInstancedBuffersStorage: {
  15218. data: {
  15219. [key: string]: Float32Array;
  15220. };
  15221. sizes: {
  15222. [key: string]: number;
  15223. };
  15224. vertexBuffers: {
  15225. [key: string]: Nullable<VertexBuffer>;
  15226. };
  15227. strides: {
  15228. [key: string]: number;
  15229. };
  15230. };
  15231. }
  15232. interface AbstractMesh {
  15233. /**
  15234. * Object used to store instanced buffers defined by user
  15235. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15236. */
  15237. instancedBuffers: {
  15238. [key: string]: any;
  15239. };
  15240. }
  15241. }
  15242. declare module BABYLON {
  15243. /**
  15244. * Defines the options associated with the creation of a shader material.
  15245. */
  15246. export interface IShaderMaterialOptions {
  15247. /**
  15248. * Does the material work in alpha blend mode
  15249. */
  15250. needAlphaBlending: boolean;
  15251. /**
  15252. * Does the material work in alpha test mode
  15253. */
  15254. needAlphaTesting: boolean;
  15255. /**
  15256. * The list of attribute names used in the shader
  15257. */
  15258. attributes: string[];
  15259. /**
  15260. * The list of unifrom names used in the shader
  15261. */
  15262. uniforms: string[];
  15263. /**
  15264. * The list of UBO names used in the shader
  15265. */
  15266. uniformBuffers: string[];
  15267. /**
  15268. * The list of sampler names used in the shader
  15269. */
  15270. samplers: string[];
  15271. /**
  15272. * The list of defines used in the shader
  15273. */
  15274. defines: string[];
  15275. }
  15276. /**
  15277. * 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.
  15278. *
  15279. * This returned material effects how the mesh will look based on the code in the shaders.
  15280. *
  15281. * @see http://doc.babylonjs.com/how_to/shader_material
  15282. */
  15283. export class ShaderMaterial extends Material {
  15284. private _shaderPath;
  15285. private _options;
  15286. private _textures;
  15287. private _textureArrays;
  15288. private _floats;
  15289. private _ints;
  15290. private _floatsArrays;
  15291. private _colors3;
  15292. private _colors3Arrays;
  15293. private _colors4;
  15294. private _colors4Arrays;
  15295. private _vectors2;
  15296. private _vectors3;
  15297. private _vectors4;
  15298. private _matrices;
  15299. private _matrixArrays;
  15300. private _matrices3x3;
  15301. private _matrices2x2;
  15302. private _vectors2Arrays;
  15303. private _vectors3Arrays;
  15304. private _vectors4Arrays;
  15305. private _cachedWorldViewMatrix;
  15306. private _cachedWorldViewProjectionMatrix;
  15307. private _renderId;
  15308. private _multiview;
  15309. /**
  15310. * Instantiate a new shader material.
  15311. * 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.
  15312. * This returned material effects how the mesh will look based on the code in the shaders.
  15313. * @see http://doc.babylonjs.com/how_to/shader_material
  15314. * @param name Define the name of the material in the scene
  15315. * @param scene Define the scene the material belongs to
  15316. * @param shaderPath Defines the route to the shader code in one of three ways:
  15317. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15318. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15319. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15320. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15321. * @param options Define the options used to create the shader
  15322. */
  15323. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15324. /**
  15325. * Gets the shader path used to define the shader code
  15326. * It can be modified to trigger a new compilation
  15327. */
  15328. get shaderPath(): any;
  15329. /**
  15330. * Sets the shader path used to define the shader code
  15331. * It can be modified to trigger a new compilation
  15332. */
  15333. set shaderPath(shaderPath: any);
  15334. /**
  15335. * Gets the options used to compile the shader.
  15336. * They can be modified to trigger a new compilation
  15337. */
  15338. get options(): IShaderMaterialOptions;
  15339. /**
  15340. * Gets the current class name of the material e.g. "ShaderMaterial"
  15341. * Mainly use in serialization.
  15342. * @returns the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Specifies if the material will require alpha blending
  15347. * @returns a boolean specifying if alpha blending is needed
  15348. */
  15349. needAlphaBlending(): boolean;
  15350. /**
  15351. * Specifies if this material should be rendered in alpha test mode
  15352. * @returns a boolean specifying if an alpha test is needed.
  15353. */
  15354. needAlphaTesting(): boolean;
  15355. private _checkUniform;
  15356. /**
  15357. * Set a texture in the shader.
  15358. * @param name Define the name of the uniform samplers as defined in the shader
  15359. * @param texture Define the texture to bind to this sampler
  15360. * @return the material itself allowing "fluent" like uniform updates
  15361. */
  15362. setTexture(name: string, texture: Texture): ShaderMaterial;
  15363. /**
  15364. * Set a texture array in the shader.
  15365. * @param name Define the name of the uniform sampler array as defined in the shader
  15366. * @param textures Define the list of textures to bind to this sampler
  15367. * @return the material itself allowing "fluent" like uniform updates
  15368. */
  15369. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15370. /**
  15371. * Set a float in the shader.
  15372. * @param name Define the name of the uniform as defined in the shader
  15373. * @param value Define the value to give to the uniform
  15374. * @return the material itself allowing "fluent" like uniform updates
  15375. */
  15376. setFloat(name: string, value: number): ShaderMaterial;
  15377. /**
  15378. * Set a int in the shader.
  15379. * @param name Define the name of the uniform as defined in the shader
  15380. * @param value Define the value to give to the uniform
  15381. * @return the material itself allowing "fluent" like uniform updates
  15382. */
  15383. setInt(name: string, value: number): ShaderMaterial;
  15384. /**
  15385. * Set an array of floats in the shader.
  15386. * @param name Define the name of the uniform as defined in the shader
  15387. * @param value Define the value to give to the uniform
  15388. * @return the material itself allowing "fluent" like uniform updates
  15389. */
  15390. setFloats(name: string, value: number[]): ShaderMaterial;
  15391. /**
  15392. * Set a vec3 in the shader from a Color3.
  15393. * @param name Define the name of the uniform as defined in the shader
  15394. * @param value Define the value to give to the uniform
  15395. * @return the material itself allowing "fluent" like uniform updates
  15396. */
  15397. setColor3(name: string, value: Color3): ShaderMaterial;
  15398. /**
  15399. * Set a vec3 array in the shader from a Color3 array.
  15400. * @param name Define the name of the uniform as defined in the shader
  15401. * @param value Define the value to give to the uniform
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15405. /**
  15406. * Set a vec4 in the shader from a Color4.
  15407. * @param name Define the name of the uniform as defined in the shader
  15408. * @param value Define the value to give to the uniform
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setColor4(name: string, value: Color4): ShaderMaterial;
  15412. /**
  15413. * Set a vec4 array in the shader from a Color4 array.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15419. /**
  15420. * Set a vec2 in the shader from a Vector2.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setVector2(name: string, value: Vector2): ShaderMaterial;
  15426. /**
  15427. * Set a vec3 in the shader from a Vector3.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setVector3(name: string, value: Vector3): ShaderMaterial;
  15433. /**
  15434. * Set a vec4 in the shader from a Vector4.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setVector4(name: string, value: Vector4): ShaderMaterial;
  15440. /**
  15441. * Set a mat4 in the shader from a Matrix.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15447. /**
  15448. * Set a float32Array in the shader from a matrix array.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15454. /**
  15455. * Set a mat3 in the shader from a Float32Array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15461. /**
  15462. * Set a mat2 in the shader from a Float32Array.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15468. /**
  15469. * Set a vec2 array in the shader from a number array.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setArray2(name: string, value: number[]): ShaderMaterial;
  15475. /**
  15476. * Set a vec3 array in the shader from a number array.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setArray3(name: string, value: number[]): ShaderMaterial;
  15482. /**
  15483. * Set a vec4 array in the shader from a number array.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setArray4(name: string, value: number[]): ShaderMaterial;
  15489. private _checkCache;
  15490. /**
  15491. * Specifies that the submesh is ready to be used
  15492. * @param mesh defines the mesh to check
  15493. * @param subMesh defines which submesh to check
  15494. * @param useInstances specifies that instances should be used
  15495. * @returns a boolean indicating that the submesh is ready or not
  15496. */
  15497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15498. /**
  15499. * Checks if the material is ready to render the requested mesh
  15500. * @param mesh Define the mesh to render
  15501. * @param useInstances Define whether or not the material is used with instances
  15502. * @returns true if ready, otherwise false
  15503. */
  15504. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15505. /**
  15506. * Binds the world matrix to the material
  15507. * @param world defines the world transformation matrix
  15508. */
  15509. bindOnlyWorldMatrix(world: Matrix): void;
  15510. /**
  15511. * Binds the material to the mesh
  15512. * @param world defines the world transformation matrix
  15513. * @param mesh defines the mesh to bind the material to
  15514. */
  15515. bind(world: Matrix, mesh?: Mesh): void;
  15516. /**
  15517. * Gets the active textures from the material
  15518. * @returns an array of textures
  15519. */
  15520. getActiveTextures(): BaseTexture[];
  15521. /**
  15522. * Specifies if the material uses a texture
  15523. * @param texture defines the texture to check against the material
  15524. * @returns a boolean specifying if the material uses the texture
  15525. */
  15526. hasTexture(texture: BaseTexture): boolean;
  15527. /**
  15528. * Makes a duplicate of the material, and gives it a new name
  15529. * @param name defines the new name for the duplicated material
  15530. * @returns the cloned material
  15531. */
  15532. clone(name: string): ShaderMaterial;
  15533. /**
  15534. * Disposes the material
  15535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15538. */
  15539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15540. /**
  15541. * Serializes this material in a JSON representation
  15542. * @returns the serialized material object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Creates a shader material from parsed shader material data
  15547. * @param source defines the JSON represnetation of the material
  15548. * @param scene defines the hosting scene
  15549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15550. * @returns a new material
  15551. */
  15552. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /** @hidden */
  15557. export var colorPixelShader: {
  15558. name: string;
  15559. shader: string;
  15560. };
  15561. }
  15562. declare module BABYLON {
  15563. /** @hidden */
  15564. export var colorVertexShader: {
  15565. name: string;
  15566. shader: string;
  15567. };
  15568. }
  15569. declare module BABYLON {
  15570. /**
  15571. * Line mesh
  15572. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15573. */
  15574. export class LinesMesh extends Mesh {
  15575. /**
  15576. * If vertex color should be applied to the mesh
  15577. */
  15578. readonly useVertexColor?: boolean | undefined;
  15579. /**
  15580. * If vertex alpha should be applied to the mesh
  15581. */
  15582. readonly useVertexAlpha?: boolean | undefined;
  15583. /**
  15584. * Color of the line (Default: White)
  15585. */
  15586. color: Color3;
  15587. /**
  15588. * Alpha of the line (Default: 1)
  15589. */
  15590. alpha: number;
  15591. /**
  15592. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15593. * This margin is expressed in world space coordinates, so its value may vary.
  15594. * Default value is 0.1
  15595. */
  15596. intersectionThreshold: number;
  15597. private _colorShader;
  15598. private color4;
  15599. /**
  15600. * Creates a new LinesMesh
  15601. * @param name defines the name
  15602. * @param scene defines the hosting scene
  15603. * @param parent defines the parent mesh if any
  15604. * @param source defines the optional source LinesMesh used to clone data from
  15605. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15606. * When false, achieved by calling a clone(), also passing False.
  15607. * This will make creation of children, recursive.
  15608. * @param useVertexColor defines if this LinesMesh supports vertex color
  15609. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15610. */
  15611. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15612. /**
  15613. * If vertex color should be applied to the mesh
  15614. */
  15615. useVertexColor?: boolean | undefined,
  15616. /**
  15617. * If vertex alpha should be applied to the mesh
  15618. */
  15619. useVertexAlpha?: boolean | undefined);
  15620. private _addClipPlaneDefine;
  15621. private _removeClipPlaneDefine;
  15622. isReady(): boolean;
  15623. /**
  15624. * Returns the string "LineMesh"
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * @hidden
  15629. */
  15630. get material(): Material;
  15631. /**
  15632. * @hidden
  15633. */
  15634. set material(value: Material);
  15635. /**
  15636. * @hidden
  15637. */
  15638. get checkCollisions(): boolean;
  15639. /** @hidden */
  15640. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15641. /** @hidden */
  15642. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15643. /**
  15644. * Disposes of the line mesh
  15645. * @param doNotRecurse If children should be disposed
  15646. */
  15647. dispose(doNotRecurse?: boolean): void;
  15648. /**
  15649. * Returns a new LineMesh object cloned from the current one.
  15650. */
  15651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15652. /**
  15653. * Creates a new InstancedLinesMesh object from the mesh model.
  15654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15655. * @param name defines the name of the new instance
  15656. * @returns a new InstancedLinesMesh
  15657. */
  15658. createInstance(name: string): InstancedLinesMesh;
  15659. }
  15660. /**
  15661. * Creates an instance based on a source LinesMesh
  15662. */
  15663. export class InstancedLinesMesh extends InstancedMesh {
  15664. /**
  15665. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15666. * This margin is expressed in world space coordinates, so its value may vary.
  15667. * Initilized with the intersectionThreshold value of the source LinesMesh
  15668. */
  15669. intersectionThreshold: number;
  15670. constructor(name: string, source: LinesMesh);
  15671. /**
  15672. * Returns the string "InstancedLinesMesh".
  15673. */
  15674. getClassName(): string;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /** @hidden */
  15679. export var linePixelShader: {
  15680. name: string;
  15681. shader: string;
  15682. };
  15683. }
  15684. declare module BABYLON {
  15685. /** @hidden */
  15686. export var lineVertexShader: {
  15687. name: string;
  15688. shader: string;
  15689. };
  15690. }
  15691. declare module BABYLON {
  15692. interface AbstractMesh {
  15693. /**
  15694. * Gets the edgesRenderer associated with the mesh
  15695. */
  15696. edgesRenderer: Nullable<EdgesRenderer>;
  15697. }
  15698. interface LinesMesh {
  15699. /**
  15700. * Enables the edge rendering mode on the mesh.
  15701. * This mode makes the mesh edges visible
  15702. * @param epsilon defines the maximal distance between two angles to detect a face
  15703. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15704. * @returns the currentAbstractMesh
  15705. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15706. */
  15707. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15708. }
  15709. interface InstancedLinesMesh {
  15710. /**
  15711. * Enables the edge rendering mode on the mesh.
  15712. * This mode makes the mesh edges visible
  15713. * @param epsilon defines the maximal distance between two angles to detect a face
  15714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15715. * @returns the current InstancedLinesMesh
  15716. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15717. */
  15718. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15719. }
  15720. /**
  15721. * Defines the minimum contract an Edges renderer should follow.
  15722. */
  15723. export interface IEdgesRenderer extends IDisposable {
  15724. /**
  15725. * Gets or sets a boolean indicating if the edgesRenderer is active
  15726. */
  15727. isEnabled: boolean;
  15728. /**
  15729. * Renders the edges of the attached mesh,
  15730. */
  15731. render(): void;
  15732. /**
  15733. * Checks wether or not the edges renderer is ready to render.
  15734. * @return true if ready, otherwise false.
  15735. */
  15736. isReady(): boolean;
  15737. }
  15738. /**
  15739. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15740. */
  15741. export class EdgesRenderer implements IEdgesRenderer {
  15742. /**
  15743. * Define the size of the edges with an orthographic camera
  15744. */
  15745. edgesWidthScalerForOrthographic: number;
  15746. /**
  15747. * Define the size of the edges with a perspective camera
  15748. */
  15749. edgesWidthScalerForPerspective: number;
  15750. protected _source: AbstractMesh;
  15751. protected _linesPositions: number[];
  15752. protected _linesNormals: number[];
  15753. protected _linesIndices: number[];
  15754. protected _epsilon: number;
  15755. protected _indicesCount: number;
  15756. protected _lineShader: ShaderMaterial;
  15757. protected _ib: DataBuffer;
  15758. protected _buffers: {
  15759. [key: string]: Nullable<VertexBuffer>;
  15760. };
  15761. protected _checkVerticesInsteadOfIndices: boolean;
  15762. private _meshRebuildObserver;
  15763. private _meshDisposeObserver;
  15764. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15765. isEnabled: boolean;
  15766. /**
  15767. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15768. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15769. * @param source Mesh used to create edges
  15770. * @param epsilon sum of angles in adjacency to check for edge
  15771. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15772. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15773. */
  15774. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15775. protected _prepareRessources(): void;
  15776. /** @hidden */
  15777. _rebuild(): void;
  15778. /**
  15779. * Releases the required resources for the edges renderer
  15780. */
  15781. dispose(): void;
  15782. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15783. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15784. /**
  15785. * Checks if the pair of p0 and p1 is en edge
  15786. * @param faceIndex
  15787. * @param edge
  15788. * @param faceNormals
  15789. * @param p0
  15790. * @param p1
  15791. * @private
  15792. */
  15793. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15794. /**
  15795. * push line into the position, normal and index buffer
  15796. * @protected
  15797. */
  15798. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15799. /**
  15800. * Generates lines edges from adjacencjes
  15801. * @private
  15802. */
  15803. _generateEdgesLines(): void;
  15804. /**
  15805. * Checks wether or not the edges renderer is ready to render.
  15806. * @return true if ready, otherwise false.
  15807. */
  15808. isReady(): boolean;
  15809. /**
  15810. * Renders the edges of the attached mesh,
  15811. */
  15812. render(): void;
  15813. }
  15814. /**
  15815. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15816. */
  15817. export class LineEdgesRenderer extends EdgesRenderer {
  15818. /**
  15819. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15820. * @param source LineMesh used to generate edges
  15821. * @param epsilon not important (specified angle for edge detection)
  15822. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15823. */
  15824. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15825. /**
  15826. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15827. */
  15828. _generateEdgesLines(): void;
  15829. }
  15830. }
  15831. declare module BABYLON {
  15832. /**
  15833. * This represents the object necessary to create a rendering group.
  15834. * This is exclusively used and created by the rendering manager.
  15835. * To modify the behavior, you use the available helpers in your scene or meshes.
  15836. * @hidden
  15837. */
  15838. export class RenderingGroup {
  15839. index: number;
  15840. private static _zeroVector;
  15841. private _scene;
  15842. private _opaqueSubMeshes;
  15843. private _transparentSubMeshes;
  15844. private _alphaTestSubMeshes;
  15845. private _depthOnlySubMeshes;
  15846. private _particleSystems;
  15847. private _spriteManagers;
  15848. private _opaqueSortCompareFn;
  15849. private _alphaTestSortCompareFn;
  15850. private _transparentSortCompareFn;
  15851. private _renderOpaque;
  15852. private _renderAlphaTest;
  15853. private _renderTransparent;
  15854. /** @hidden */
  15855. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15856. onBeforeTransparentRendering: () => void;
  15857. /**
  15858. * Set the opaque sort comparison function.
  15859. * If null the sub meshes will be render in the order they were created
  15860. */
  15861. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15862. /**
  15863. * Set the alpha test sort comparison function.
  15864. * If null the sub meshes will be render in the order they were created
  15865. */
  15866. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15867. /**
  15868. * Set the transparent sort comparison function.
  15869. * If null the sub meshes will be render in the order they were created
  15870. */
  15871. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15872. /**
  15873. * Creates a new rendering group.
  15874. * @param index The rendering group index
  15875. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15876. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15877. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15878. */
  15879. 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>);
  15880. /**
  15881. * Render all the sub meshes contained in the group.
  15882. * @param customRenderFunction Used to override the default render behaviour of the group.
  15883. * @returns true if rendered some submeshes.
  15884. */
  15885. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15886. /**
  15887. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15888. * @param subMeshes The submeshes to render
  15889. */
  15890. private renderOpaqueSorted;
  15891. /**
  15892. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15893. * @param subMeshes The submeshes to render
  15894. */
  15895. private renderAlphaTestSorted;
  15896. /**
  15897. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15898. * @param subMeshes The submeshes to render
  15899. */
  15900. private renderTransparentSorted;
  15901. /**
  15902. * Renders the submeshes in a specified order.
  15903. * @param subMeshes The submeshes to sort before render
  15904. * @param sortCompareFn The comparison function use to sort
  15905. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15906. * @param transparent Specifies to activate blending if true
  15907. */
  15908. private static renderSorted;
  15909. /**
  15910. * Renders the submeshes in the order they were dispatched (no sort applied).
  15911. * @param subMeshes The submeshes to render
  15912. */
  15913. private static renderUnsorted;
  15914. /**
  15915. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15916. * are rendered back to front if in the same alpha index.
  15917. *
  15918. * @param a The first submesh
  15919. * @param b The second submesh
  15920. * @returns The result of the comparison
  15921. */
  15922. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15923. /**
  15924. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15925. * are rendered back to front.
  15926. *
  15927. * @param a The first submesh
  15928. * @param b The second submesh
  15929. * @returns The result of the comparison
  15930. */
  15931. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15932. /**
  15933. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15934. * are rendered front to back (prevent overdraw).
  15935. *
  15936. * @param a The first submesh
  15937. * @param b The second submesh
  15938. * @returns The result of the comparison
  15939. */
  15940. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15941. /**
  15942. * Resets the different lists of submeshes to prepare a new frame.
  15943. */
  15944. prepare(): void;
  15945. dispose(): void;
  15946. /**
  15947. * Inserts the submesh in its correct queue depending on its material.
  15948. * @param subMesh The submesh to dispatch
  15949. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15950. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15951. */
  15952. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15953. dispatchSprites(spriteManager: ISpriteManager): void;
  15954. dispatchParticles(particleSystem: IParticleSystem): void;
  15955. private _renderParticles;
  15956. private _renderSprites;
  15957. }
  15958. }
  15959. declare module BABYLON {
  15960. /**
  15961. * Interface describing the different options available in the rendering manager
  15962. * regarding Auto Clear between groups.
  15963. */
  15964. export interface IRenderingManagerAutoClearSetup {
  15965. /**
  15966. * Defines whether or not autoclear is enable.
  15967. */
  15968. autoClear: boolean;
  15969. /**
  15970. * Defines whether or not to autoclear the depth buffer.
  15971. */
  15972. depth: boolean;
  15973. /**
  15974. * Defines whether or not to autoclear the stencil buffer.
  15975. */
  15976. stencil: boolean;
  15977. }
  15978. /**
  15979. * This class is used by the onRenderingGroupObservable
  15980. */
  15981. export class RenderingGroupInfo {
  15982. /**
  15983. * The Scene that being rendered
  15984. */
  15985. scene: Scene;
  15986. /**
  15987. * The camera currently used for the rendering pass
  15988. */
  15989. camera: Nullable<Camera>;
  15990. /**
  15991. * The ID of the renderingGroup being processed
  15992. */
  15993. renderingGroupId: number;
  15994. }
  15995. /**
  15996. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15997. * It is enable to manage the different groups as well as the different necessary sort functions.
  15998. * This should not be used directly aside of the few static configurations
  15999. */
  16000. export class RenderingManager {
  16001. /**
  16002. * The max id used for rendering groups (not included)
  16003. */
  16004. static MAX_RENDERINGGROUPS: number;
  16005. /**
  16006. * The min id used for rendering groups (included)
  16007. */
  16008. static MIN_RENDERINGGROUPS: number;
  16009. /**
  16010. * Used to globally prevent autoclearing scenes.
  16011. */
  16012. static AUTOCLEAR: boolean;
  16013. /**
  16014. * @hidden
  16015. */
  16016. _useSceneAutoClearSetup: boolean;
  16017. private _scene;
  16018. private _renderingGroups;
  16019. private _depthStencilBufferAlreadyCleaned;
  16020. private _autoClearDepthStencil;
  16021. private _customOpaqueSortCompareFn;
  16022. private _customAlphaTestSortCompareFn;
  16023. private _customTransparentSortCompareFn;
  16024. private _renderingGroupInfo;
  16025. /**
  16026. * Instantiates a new rendering group for a particular scene
  16027. * @param scene Defines the scene the groups belongs to
  16028. */
  16029. constructor(scene: Scene);
  16030. private _clearDepthStencilBuffer;
  16031. /**
  16032. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16033. * @hidden
  16034. */
  16035. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16036. /**
  16037. * Resets the different information of the group to prepare a new frame
  16038. * @hidden
  16039. */
  16040. reset(): void;
  16041. /**
  16042. * Dispose and release the group and its associated resources.
  16043. * @hidden
  16044. */
  16045. dispose(): void;
  16046. /**
  16047. * Clear the info related to rendering groups preventing retention points during dispose.
  16048. */
  16049. freeRenderingGroups(): void;
  16050. private _prepareRenderingGroup;
  16051. /**
  16052. * Add a sprite manager to the rendering manager in order to render it this frame.
  16053. * @param spriteManager Define the sprite manager to render
  16054. */
  16055. dispatchSprites(spriteManager: ISpriteManager): void;
  16056. /**
  16057. * Add a particle system to the rendering manager in order to render it this frame.
  16058. * @param particleSystem Define the particle system to render
  16059. */
  16060. dispatchParticles(particleSystem: IParticleSystem): void;
  16061. /**
  16062. * Add a submesh to the manager in order to render it this frame
  16063. * @param subMesh The submesh to dispatch
  16064. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16065. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16066. */
  16067. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16068. /**
  16069. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16070. * This allowed control for front to back rendering or reversly depending of the special needs.
  16071. *
  16072. * @param renderingGroupId The rendering group id corresponding to its index
  16073. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16074. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16075. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16076. */
  16077. 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;
  16078. /**
  16079. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16080. *
  16081. * @param renderingGroupId The rendering group id corresponding to its index
  16082. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16083. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16084. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16085. */
  16086. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16087. /**
  16088. * Gets the current auto clear configuration for one rendering group of the rendering
  16089. * manager.
  16090. * @param index the rendering group index to get the information for
  16091. * @returns The auto clear setup for the requested rendering group
  16092. */
  16093. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16094. }
  16095. }
  16096. declare module BABYLON {
  16097. /**
  16098. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16099. */
  16100. export interface ICustomShaderOptions {
  16101. /**
  16102. * Gets or sets the custom shader name to use
  16103. */
  16104. shaderName: string;
  16105. /**
  16106. * The list of attribute names used in the shader
  16107. */
  16108. attributes?: string[];
  16109. /**
  16110. * The list of unifrom names used in the shader
  16111. */
  16112. uniforms?: string[];
  16113. /**
  16114. * The list of sampler names used in the shader
  16115. */
  16116. samplers?: string[];
  16117. /**
  16118. * The list of defines used in the shader
  16119. */
  16120. defines?: string[];
  16121. }
  16122. /**
  16123. * Interface to implement to create a shadow generator compatible with BJS.
  16124. */
  16125. export interface IShadowGenerator {
  16126. /**
  16127. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16128. * @returns The render target texture if present otherwise, null
  16129. */
  16130. getShadowMap(): Nullable<RenderTargetTexture>;
  16131. /**
  16132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16133. * @param subMesh The submesh we want to render in the shadow map
  16134. * @param useInstances Defines wether will draw in the map using instances
  16135. * @returns true if ready otherwise, false
  16136. */
  16137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16138. /**
  16139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16140. * @param defines Defines of the material we want to update
  16141. * @param lightIndex Index of the light in the enabled light list of the material
  16142. */
  16143. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16144. /**
  16145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16146. * defined in the generator but impacting the effect).
  16147. * It implies the unifroms available on the materials are the standard BJS ones.
  16148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16149. * @param effect The effect we are binfing the information for
  16150. */
  16151. bindShadowLight(lightIndex: string, effect: Effect): void;
  16152. /**
  16153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16154. * (eq to shadow prjection matrix * light transform matrix)
  16155. * @returns The transform matrix used to create the shadow map
  16156. */
  16157. getTransformMatrix(): Matrix;
  16158. /**
  16159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16160. * Cube and 2D textures for instance.
  16161. */
  16162. recreateShadowMap(): void;
  16163. /**
  16164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16165. * @param onCompiled Callback triggered at the and of the effects compilation
  16166. * @param options Sets of optional options forcing the compilation with different modes
  16167. */
  16168. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16169. useInstances: boolean;
  16170. }>): void;
  16171. /**
  16172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16173. * @param options Sets of optional options forcing the compilation with different modes
  16174. * @returns A promise that resolves when the compilation completes
  16175. */
  16176. forceCompilationAsync(options?: Partial<{
  16177. useInstances: boolean;
  16178. }>): Promise<void>;
  16179. /**
  16180. * Serializes the shadow generator setup to a json object.
  16181. * @returns The serialized JSON object
  16182. */
  16183. serialize(): any;
  16184. /**
  16185. * Disposes the Shadow map and related Textures and effects.
  16186. */
  16187. dispose(): void;
  16188. }
  16189. /**
  16190. * Default implementation IShadowGenerator.
  16191. * This is the main object responsible of generating shadows in the framework.
  16192. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16193. */
  16194. export class ShadowGenerator implements IShadowGenerator {
  16195. /**
  16196. * Name of the shadow generator class
  16197. */
  16198. static CLASSNAME: string;
  16199. /**
  16200. * Shadow generator mode None: no filtering applied.
  16201. */
  16202. static readonly FILTER_NONE: number;
  16203. /**
  16204. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16206. */
  16207. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16208. /**
  16209. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16210. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16211. */
  16212. static readonly FILTER_POISSONSAMPLING: number;
  16213. /**
  16214. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16216. */
  16217. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16218. /**
  16219. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16220. * edge artifacts on steep falloff.
  16221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16222. */
  16223. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16224. /**
  16225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16226. * edge artifacts on steep falloff.
  16227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16228. */
  16229. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16230. /**
  16231. * Shadow generator mode PCF: Percentage Closer Filtering
  16232. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16233. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16234. */
  16235. static readonly FILTER_PCF: number;
  16236. /**
  16237. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16239. * Contact Hardening
  16240. */
  16241. static readonly FILTER_PCSS: number;
  16242. /**
  16243. * Reserved for PCF and PCSS
  16244. * Highest Quality.
  16245. *
  16246. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16247. *
  16248. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16249. */
  16250. static readonly QUALITY_HIGH: number;
  16251. /**
  16252. * Reserved for PCF and PCSS
  16253. * Good tradeoff for quality/perf cross devices
  16254. *
  16255. * Execute PCF on a 3*3 kernel.
  16256. *
  16257. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16258. */
  16259. static readonly QUALITY_MEDIUM: number;
  16260. /**
  16261. * Reserved for PCF and PCSS
  16262. * The lowest quality but the fastest.
  16263. *
  16264. * Execute PCF on a 1*1 kernel.
  16265. *
  16266. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16267. */
  16268. static readonly QUALITY_LOW: number;
  16269. /** Gets or sets the custom shader name to use */
  16270. customShaderOptions: ICustomShaderOptions;
  16271. /**
  16272. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16273. */
  16274. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16275. /**
  16276. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16277. */
  16278. onAfterShadowMapRenderObservable: Observable<Effect>;
  16279. /**
  16280. * Observable triggered before a mesh is rendered in the shadow map.
  16281. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16282. */
  16283. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16284. /**
  16285. * Observable triggered after a mesh is rendered in the shadow map.
  16286. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16287. */
  16288. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16289. protected _bias: number;
  16290. /**
  16291. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16292. */
  16293. get bias(): number;
  16294. /**
  16295. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16296. */
  16297. set bias(bias: number);
  16298. protected _normalBias: number;
  16299. /**
  16300. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16301. */
  16302. get normalBias(): number;
  16303. /**
  16304. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16305. */
  16306. set normalBias(normalBias: number);
  16307. protected _blurBoxOffset: number;
  16308. /**
  16309. * Gets the blur box offset: offset applied during the blur pass.
  16310. * Only useful if useKernelBlur = false
  16311. */
  16312. get blurBoxOffset(): number;
  16313. /**
  16314. * Sets the blur box offset: offset applied during the blur pass.
  16315. * Only useful if useKernelBlur = false
  16316. */
  16317. set blurBoxOffset(value: number);
  16318. protected _blurScale: number;
  16319. /**
  16320. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16321. * 2 means half of the size.
  16322. */
  16323. get blurScale(): number;
  16324. /**
  16325. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16326. * 2 means half of the size.
  16327. */
  16328. set blurScale(value: number);
  16329. protected _blurKernel: number;
  16330. /**
  16331. * Gets the blur kernel: kernel size of the blur pass.
  16332. * Only useful if useKernelBlur = true
  16333. */
  16334. get blurKernel(): number;
  16335. /**
  16336. * Sets the blur kernel: kernel size of the blur pass.
  16337. * Only useful if useKernelBlur = true
  16338. */
  16339. set blurKernel(value: number);
  16340. protected _useKernelBlur: boolean;
  16341. /**
  16342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16344. */
  16345. get useKernelBlur(): boolean;
  16346. /**
  16347. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16348. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16349. */
  16350. set useKernelBlur(value: boolean);
  16351. protected _depthScale: number;
  16352. /**
  16353. * Gets the depth scale used in ESM mode.
  16354. */
  16355. get depthScale(): number;
  16356. /**
  16357. * Sets the depth scale used in ESM mode.
  16358. * This can override the scale stored on the light.
  16359. */
  16360. set depthScale(value: number);
  16361. protected _validateFilter(filter: number): number;
  16362. protected _filter: number;
  16363. /**
  16364. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16365. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16366. */
  16367. get filter(): number;
  16368. /**
  16369. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16370. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16371. */
  16372. set filter(value: number);
  16373. /**
  16374. * Gets if the current filter is set to Poisson Sampling.
  16375. */
  16376. get usePoissonSampling(): boolean;
  16377. /**
  16378. * Sets the current filter to Poisson Sampling.
  16379. */
  16380. set usePoissonSampling(value: boolean);
  16381. /**
  16382. * Gets if the current filter is set to ESM.
  16383. */
  16384. get useExponentialShadowMap(): boolean;
  16385. /**
  16386. * Sets the current filter is to ESM.
  16387. */
  16388. set useExponentialShadowMap(value: boolean);
  16389. /**
  16390. * Gets if the current filter is set to filtered ESM.
  16391. */
  16392. get useBlurExponentialShadowMap(): boolean;
  16393. /**
  16394. * Gets if the current filter is set to filtered ESM.
  16395. */
  16396. set useBlurExponentialShadowMap(value: boolean);
  16397. /**
  16398. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16399. * exponential to prevent steep falloff artifacts).
  16400. */
  16401. get useCloseExponentialShadowMap(): boolean;
  16402. /**
  16403. * Sets the current filter to "close ESM" (using the inverse of the
  16404. * exponential to prevent steep falloff artifacts).
  16405. */
  16406. set useCloseExponentialShadowMap(value: boolean);
  16407. /**
  16408. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16409. * exponential to prevent steep falloff artifacts).
  16410. */
  16411. get useBlurCloseExponentialShadowMap(): boolean;
  16412. /**
  16413. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16414. * exponential to prevent steep falloff artifacts).
  16415. */
  16416. set useBlurCloseExponentialShadowMap(value: boolean);
  16417. /**
  16418. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16419. */
  16420. get usePercentageCloserFiltering(): boolean;
  16421. /**
  16422. * Sets the current filter to "PCF" (percentage closer filtering).
  16423. */
  16424. set usePercentageCloserFiltering(value: boolean);
  16425. protected _filteringQuality: number;
  16426. /**
  16427. * Gets the PCF or PCSS Quality.
  16428. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16429. */
  16430. get filteringQuality(): number;
  16431. /**
  16432. * Sets the PCF or PCSS Quality.
  16433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16434. */
  16435. set filteringQuality(filteringQuality: number);
  16436. /**
  16437. * Gets if the current filter is set to "PCSS" (contact hardening).
  16438. */
  16439. get useContactHardeningShadow(): boolean;
  16440. /**
  16441. * Sets the current filter to "PCSS" (contact hardening).
  16442. */
  16443. set useContactHardeningShadow(value: boolean);
  16444. protected _contactHardeningLightSizeUVRatio: number;
  16445. /**
  16446. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16447. * Using a ratio helps keeping shape stability independently of the map size.
  16448. *
  16449. * It does not account for the light projection as it was having too much
  16450. * instability during the light setup or during light position changes.
  16451. *
  16452. * Only valid if useContactHardeningShadow is true.
  16453. */
  16454. get contactHardeningLightSizeUVRatio(): number;
  16455. /**
  16456. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16457. * Using a ratio helps keeping shape stability independently of the map size.
  16458. *
  16459. * It does not account for the light projection as it was having too much
  16460. * instability during the light setup or during light position changes.
  16461. *
  16462. * Only valid if useContactHardeningShadow is true.
  16463. */
  16464. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16465. protected _darkness: number;
  16466. /** Gets or sets the actual darkness of a shadow */
  16467. get darkness(): number;
  16468. set darkness(value: number);
  16469. /**
  16470. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16471. * 0 means strongest and 1 would means no shadow.
  16472. * @returns the darkness.
  16473. */
  16474. getDarkness(): number;
  16475. /**
  16476. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16477. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16478. * @returns the shadow generator allowing fluent coding.
  16479. */
  16480. setDarkness(darkness: number): ShadowGenerator;
  16481. protected _transparencyShadow: boolean;
  16482. /** Gets or sets the ability to have transparent shadow */
  16483. get transparencyShadow(): boolean;
  16484. set transparencyShadow(value: boolean);
  16485. /**
  16486. * Sets the ability to have transparent shadow (boolean).
  16487. * @param transparent True if transparent else False
  16488. * @returns the shadow generator allowing fluent coding
  16489. */
  16490. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16491. protected _shadowMap: Nullable<RenderTargetTexture>;
  16492. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16493. /**
  16494. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16495. * @returns The render target texture if present otherwise, null
  16496. */
  16497. getShadowMap(): Nullable<RenderTargetTexture>;
  16498. /**
  16499. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16500. * @returns The render target texture if the shadow map is present otherwise, null
  16501. */
  16502. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16503. /**
  16504. * Gets the class name of that object
  16505. * @returns "ShadowGenerator"
  16506. */
  16507. getClassName(): string;
  16508. /**
  16509. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16510. * @param mesh Mesh to add
  16511. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16512. * @returns the Shadow Generator itself
  16513. */
  16514. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16515. /**
  16516. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16517. * @param mesh Mesh to remove
  16518. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16519. * @returns the Shadow Generator itself
  16520. */
  16521. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16522. /**
  16523. * Controls the extent to which the shadows fade out at the edge of the frustum
  16524. */
  16525. frustumEdgeFalloff: number;
  16526. protected _light: IShadowLight;
  16527. /**
  16528. * Returns the associated light object.
  16529. * @returns the light generating the shadow
  16530. */
  16531. getLight(): IShadowLight;
  16532. /**
  16533. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16534. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16535. * It might on the other hand introduce peter panning.
  16536. */
  16537. forceBackFacesOnly: boolean;
  16538. protected _scene: Scene;
  16539. protected _lightDirection: Vector3;
  16540. protected _effect: Effect;
  16541. protected _viewMatrix: Matrix;
  16542. protected _projectionMatrix: Matrix;
  16543. protected _transformMatrix: Matrix;
  16544. protected _cachedPosition: Vector3;
  16545. protected _cachedDirection: Vector3;
  16546. protected _cachedDefines: string;
  16547. protected _currentRenderID: number;
  16548. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16549. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16550. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16551. protected _blurPostProcesses: PostProcess[];
  16552. protected _mapSize: number;
  16553. protected _currentFaceIndex: number;
  16554. protected _currentFaceIndexCache: number;
  16555. protected _textureType: number;
  16556. protected _defaultTextureMatrix: Matrix;
  16557. protected _storedUniqueId: Nullable<number>;
  16558. /** @hidden */
  16559. static _SceneComponentInitialization: (scene: Scene) => void;
  16560. /**
  16561. * Creates a ShadowGenerator object.
  16562. * A ShadowGenerator is the required tool to use the shadows.
  16563. * Each light casting shadows needs to use its own ShadowGenerator.
  16564. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16565. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16566. * @param light The light object generating the shadows.
  16567. * @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.
  16568. */
  16569. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16570. protected _initializeGenerator(): void;
  16571. protected _createTargetRenderTexture(): void;
  16572. protected _initializeShadowMap(): void;
  16573. protected _initializeBlurRTTAndPostProcesses(): void;
  16574. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16575. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16576. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16577. protected _applyFilterValues(): void;
  16578. /**
  16579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16580. * @param onCompiled Callback triggered at the and of the effects compilation
  16581. * @param options Sets of optional options forcing the compilation with different modes
  16582. */
  16583. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16584. useInstances: boolean;
  16585. }>): void;
  16586. /**
  16587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16588. * @param options Sets of optional options forcing the compilation with different modes
  16589. * @returns A promise that resolves when the compilation completes
  16590. */
  16591. forceCompilationAsync(options?: Partial<{
  16592. useInstances: boolean;
  16593. }>): Promise<void>;
  16594. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16595. /**
  16596. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16597. * @param subMesh The submesh we want to render in the shadow map
  16598. * @param useInstances Defines wether will draw in the map using instances
  16599. * @returns true if ready otherwise, false
  16600. */
  16601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16602. /**
  16603. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16604. * @param defines Defines of the material we want to update
  16605. * @param lightIndex Index of the light in the enabled light list of the material
  16606. */
  16607. prepareDefines(defines: any, lightIndex: number): void;
  16608. /**
  16609. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16610. * defined in the generator but impacting the effect).
  16611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16612. * @param effect The effect we are binfing the information for
  16613. */
  16614. bindShadowLight(lightIndex: string, effect: Effect): void;
  16615. /**
  16616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16617. * (eq to shadow prjection matrix * light transform matrix)
  16618. * @returns The transform matrix used to create the shadow map
  16619. */
  16620. getTransformMatrix(): Matrix;
  16621. /**
  16622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16623. * Cube and 2D textures for instance.
  16624. */
  16625. recreateShadowMap(): void;
  16626. protected _disposeBlurPostProcesses(): void;
  16627. protected _disposeRTTandPostProcesses(): void;
  16628. /**
  16629. * Disposes the ShadowGenerator.
  16630. * Returns nothing.
  16631. */
  16632. dispose(): void;
  16633. /**
  16634. * Serializes the shadow generator setup to a json object.
  16635. * @returns The serialized JSON object
  16636. */
  16637. serialize(): any;
  16638. /**
  16639. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16640. * @param parsedShadowGenerator The JSON object to parse
  16641. * @param scene The scene to create the shadow map for
  16642. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16643. * @returns The parsed shadow generator
  16644. */
  16645. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16646. }
  16647. }
  16648. declare module BABYLON {
  16649. /**
  16650. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16651. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16652. * 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.
  16653. */
  16654. export abstract class Light extends Node {
  16655. /**
  16656. * Falloff Default: light is falling off following the material specification:
  16657. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16658. */
  16659. static readonly FALLOFF_DEFAULT: number;
  16660. /**
  16661. * Falloff Physical: light is falling off following the inverse squared distance law.
  16662. */
  16663. static readonly FALLOFF_PHYSICAL: number;
  16664. /**
  16665. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16666. * to enhance interoperability with other engines.
  16667. */
  16668. static readonly FALLOFF_GLTF: number;
  16669. /**
  16670. * Falloff Standard: light is falling off like in the standard material
  16671. * to enhance interoperability with other materials.
  16672. */
  16673. static readonly FALLOFF_STANDARD: number;
  16674. /**
  16675. * If every light affecting the material is in this lightmapMode,
  16676. * material.lightmapTexture adds or multiplies
  16677. * (depends on material.useLightmapAsShadowmap)
  16678. * after every other light calculations.
  16679. */
  16680. static readonly LIGHTMAP_DEFAULT: number;
  16681. /**
  16682. * material.lightmapTexture as only diffuse lighting from this light
  16683. * adds only specular lighting from this light
  16684. * adds dynamic shadows
  16685. */
  16686. static readonly LIGHTMAP_SPECULAR: number;
  16687. /**
  16688. * material.lightmapTexture as only lighting
  16689. * no light calculation from this light
  16690. * only adds dynamic shadows from this light
  16691. */
  16692. static readonly LIGHTMAP_SHADOWSONLY: number;
  16693. /**
  16694. * Each light type uses the default quantity according to its type:
  16695. * point/spot lights use luminous intensity
  16696. * directional lights use illuminance
  16697. */
  16698. static readonly INTENSITYMODE_AUTOMATIC: number;
  16699. /**
  16700. * lumen (lm)
  16701. */
  16702. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16703. /**
  16704. * candela (lm/sr)
  16705. */
  16706. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16707. /**
  16708. * lux (lm/m^2)
  16709. */
  16710. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16711. /**
  16712. * nit (cd/m^2)
  16713. */
  16714. static readonly INTENSITYMODE_LUMINANCE: number;
  16715. /**
  16716. * Light type const id of the point light.
  16717. */
  16718. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16719. /**
  16720. * Light type const id of the directional light.
  16721. */
  16722. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16723. /**
  16724. * Light type const id of the spot light.
  16725. */
  16726. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16727. /**
  16728. * Light type const id of the hemispheric light.
  16729. */
  16730. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16731. /**
  16732. * Diffuse gives the basic color to an object.
  16733. */
  16734. diffuse: Color3;
  16735. /**
  16736. * Specular produces a highlight color on an object.
  16737. * Note: This is note affecting PBR materials.
  16738. */
  16739. specular: Color3;
  16740. /**
  16741. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16742. * falling off base on range or angle.
  16743. * This can be set to any values in Light.FALLOFF_x.
  16744. *
  16745. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16746. * other types of materials.
  16747. */
  16748. falloffType: number;
  16749. /**
  16750. * Strength of the light.
  16751. * Note: By default it is define in the framework own unit.
  16752. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16753. */
  16754. intensity: number;
  16755. private _range;
  16756. protected _inverseSquaredRange: number;
  16757. /**
  16758. * Defines how far from the source the light is impacting in scene units.
  16759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16760. */
  16761. get range(): number;
  16762. /**
  16763. * Defines how far from the source the light is impacting in scene units.
  16764. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16765. */
  16766. set range(value: number);
  16767. /**
  16768. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16769. * of light.
  16770. */
  16771. private _photometricScale;
  16772. private _intensityMode;
  16773. /**
  16774. * Gets the photometric scale used to interpret the intensity.
  16775. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16776. */
  16777. get intensityMode(): number;
  16778. /**
  16779. * Sets the photometric scale used to interpret the intensity.
  16780. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16781. */
  16782. set intensityMode(value: number);
  16783. private _radius;
  16784. /**
  16785. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16786. */
  16787. get radius(): number;
  16788. /**
  16789. * sets the light radius used by PBR Materials to simulate soft area lights.
  16790. */
  16791. set radius(value: number);
  16792. private _renderPriority;
  16793. /**
  16794. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16795. * exceeding the number allowed of the materials.
  16796. */
  16797. renderPriority: number;
  16798. private _shadowEnabled;
  16799. /**
  16800. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16801. * the current shadow generator.
  16802. */
  16803. get shadowEnabled(): boolean;
  16804. /**
  16805. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16806. * the current shadow generator.
  16807. */
  16808. set shadowEnabled(value: boolean);
  16809. private _includedOnlyMeshes;
  16810. /**
  16811. * Gets the only meshes impacted by this light.
  16812. */
  16813. get includedOnlyMeshes(): AbstractMesh[];
  16814. /**
  16815. * Sets the only meshes impacted by this light.
  16816. */
  16817. set includedOnlyMeshes(value: AbstractMesh[]);
  16818. private _excludedMeshes;
  16819. /**
  16820. * Gets the meshes not impacted by this light.
  16821. */
  16822. get excludedMeshes(): AbstractMesh[];
  16823. /**
  16824. * Sets the meshes not impacted by this light.
  16825. */
  16826. set excludedMeshes(value: AbstractMesh[]);
  16827. private _excludeWithLayerMask;
  16828. /**
  16829. * Gets the layer id use to find what meshes are not impacted by the light.
  16830. * Inactive if 0
  16831. */
  16832. get excludeWithLayerMask(): number;
  16833. /**
  16834. * Sets the layer id use to find what meshes are not impacted by the light.
  16835. * Inactive if 0
  16836. */
  16837. set excludeWithLayerMask(value: number);
  16838. private _includeOnlyWithLayerMask;
  16839. /**
  16840. * Gets the layer id use to find what meshes are impacted by the light.
  16841. * Inactive if 0
  16842. */
  16843. get includeOnlyWithLayerMask(): number;
  16844. /**
  16845. * Sets the layer id use to find what meshes are impacted by the light.
  16846. * Inactive if 0
  16847. */
  16848. set includeOnlyWithLayerMask(value: number);
  16849. private _lightmapMode;
  16850. /**
  16851. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16852. */
  16853. get lightmapMode(): number;
  16854. /**
  16855. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16856. */
  16857. set lightmapMode(value: number);
  16858. /**
  16859. * Shadow generator associted to the light.
  16860. * @hidden Internal use only.
  16861. */
  16862. _shadowGenerator: Nullable<IShadowGenerator>;
  16863. /**
  16864. * @hidden Internal use only.
  16865. */
  16866. _excludedMeshesIds: string[];
  16867. /**
  16868. * @hidden Internal use only.
  16869. */
  16870. _includedOnlyMeshesIds: string[];
  16871. /**
  16872. * The current light unifom buffer.
  16873. * @hidden Internal use only.
  16874. */
  16875. _uniformBuffer: UniformBuffer;
  16876. /** @hidden */
  16877. _renderId: number;
  16878. /**
  16879. * Creates a Light object in the scene.
  16880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16881. * @param name The firendly name of the light
  16882. * @param scene The scene the light belongs too
  16883. */
  16884. constructor(name: string, scene: Scene);
  16885. protected abstract _buildUniformLayout(): void;
  16886. /**
  16887. * Sets the passed Effect "effect" with the Light information.
  16888. * @param effect The effect to update
  16889. * @param lightIndex The index of the light in the effect to update
  16890. * @returns The light
  16891. */
  16892. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16893. /**
  16894. * Sets the passed Effect "effect" with the Light textures.
  16895. * @param effect The effect to update
  16896. * @param lightIndex The index of the light in the effect to update
  16897. * @returns The light
  16898. */
  16899. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16900. /**
  16901. * Binds the lights information from the scene to the effect for the given mesh.
  16902. * @param lightIndex Light index
  16903. * @param scene The scene where the light belongs to
  16904. * @param effect The effect we are binding the data to
  16905. * @param useSpecular Defines if specular is supported
  16906. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16907. */
  16908. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16909. /**
  16910. * Sets the passed Effect "effect" with the Light information.
  16911. * @param effect The effect to update
  16912. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16913. * @returns The light
  16914. */
  16915. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16916. /**
  16917. * Returns the string "Light".
  16918. * @returns the class name
  16919. */
  16920. getClassName(): string;
  16921. /** @hidden */
  16922. readonly _isLight: boolean;
  16923. /**
  16924. * Converts the light information to a readable string for debug purpose.
  16925. * @param fullDetails Supports for multiple levels of logging within scene loading
  16926. * @returns the human readable light info
  16927. */
  16928. toString(fullDetails?: boolean): string;
  16929. /** @hidden */
  16930. protected _syncParentEnabledState(): void;
  16931. /**
  16932. * Set the enabled state of this node.
  16933. * @param value - the new enabled state
  16934. */
  16935. setEnabled(value: boolean): void;
  16936. /**
  16937. * Returns the Light associated shadow generator if any.
  16938. * @return the associated shadow generator.
  16939. */
  16940. getShadowGenerator(): Nullable<IShadowGenerator>;
  16941. /**
  16942. * Returns a Vector3, the absolute light position in the World.
  16943. * @returns the world space position of the light
  16944. */
  16945. getAbsolutePosition(): Vector3;
  16946. /**
  16947. * Specifies if the light will affect the passed mesh.
  16948. * @param mesh The mesh to test against the light
  16949. * @return true the mesh is affected otherwise, false.
  16950. */
  16951. canAffectMesh(mesh: AbstractMesh): boolean;
  16952. /**
  16953. * Sort function to order lights for rendering.
  16954. * @param a First Light object to compare to second.
  16955. * @param b Second Light object to compare first.
  16956. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16957. */
  16958. static CompareLightsPriority(a: Light, b: Light): number;
  16959. /**
  16960. * Releases resources associated with this node.
  16961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16963. */
  16964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16965. /**
  16966. * Returns the light type ID (integer).
  16967. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16968. */
  16969. getTypeID(): number;
  16970. /**
  16971. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16972. * @returns the scaled intensity in intensity mode unit
  16973. */
  16974. getScaledIntensity(): number;
  16975. /**
  16976. * Returns a new Light object, named "name", from the current one.
  16977. * @param name The name of the cloned light
  16978. * @returns the new created light
  16979. */
  16980. clone(name: string): Nullable<Light>;
  16981. /**
  16982. * Serializes the current light into a Serialization object.
  16983. * @returns the serialized object.
  16984. */
  16985. serialize(): any;
  16986. /**
  16987. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16988. * This new light is named "name" and added to the passed scene.
  16989. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16990. * @param name The friendly name of the light
  16991. * @param scene The scene the new light will belong to
  16992. * @returns the constructor function
  16993. */
  16994. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16995. /**
  16996. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16997. * @param parsedLight The JSON representation of the light
  16998. * @param scene The scene to create the parsed light in
  16999. * @returns the created light after parsing
  17000. */
  17001. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17002. private _hookArrayForExcluded;
  17003. private _hookArrayForIncludedOnly;
  17004. private _resyncMeshes;
  17005. /**
  17006. * Forces the meshes to update their light related information in their rendering used effects
  17007. * @hidden Internal Use Only
  17008. */
  17009. _markMeshesAsLightDirty(): void;
  17010. /**
  17011. * Recomputes the cached photometric scale if needed.
  17012. */
  17013. private _computePhotometricScale;
  17014. /**
  17015. * Returns the Photometric Scale according to the light type and intensity mode.
  17016. */
  17017. private _getPhotometricScale;
  17018. /**
  17019. * Reorder the light in the scene according to their defined priority.
  17020. * @hidden Internal Use Only
  17021. */
  17022. _reorderLightsInScene(): void;
  17023. /**
  17024. * Prepares the list of defines specific to the light type.
  17025. * @param defines the list of defines
  17026. * @param lightIndex defines the index of the light for the effect
  17027. */
  17028. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17029. }
  17030. }
  17031. declare module BABYLON {
  17032. /**
  17033. * Interface used to define Action
  17034. */
  17035. export interface IAction {
  17036. /**
  17037. * Trigger for the action
  17038. */
  17039. trigger: number;
  17040. /** Options of the trigger */
  17041. triggerOptions: any;
  17042. /**
  17043. * Gets the trigger parameters
  17044. * @returns the trigger parameters
  17045. */
  17046. getTriggerParameter(): any;
  17047. /**
  17048. * Internal only - executes current action event
  17049. * @hidden
  17050. */
  17051. _executeCurrent(evt?: ActionEvent): void;
  17052. /**
  17053. * Serialize placeholder for child classes
  17054. * @param parent of child
  17055. * @returns the serialized object
  17056. */
  17057. serialize(parent: any): any;
  17058. /**
  17059. * Internal only
  17060. * @hidden
  17061. */
  17062. _prepare(): void;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: AbstractActionManager;
  17068. /**
  17069. * Adds action to chain of actions, may be a DoNothingAction
  17070. * @param action defines the next action to execute
  17071. * @returns The action passed in
  17072. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17073. */
  17074. then(action: IAction): IAction;
  17075. }
  17076. /**
  17077. * The action to be carried out following a trigger
  17078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17079. */
  17080. export class Action implements IAction {
  17081. /** the trigger, with or without parameters, for the action */
  17082. triggerOptions: any;
  17083. /**
  17084. * Trigger for the action
  17085. */
  17086. trigger: number;
  17087. /**
  17088. * Internal only - manager for action
  17089. * @hidden
  17090. */
  17091. _actionManager: ActionManager;
  17092. private _nextActiveAction;
  17093. private _child;
  17094. private _condition?;
  17095. private _triggerParameter;
  17096. /**
  17097. * An event triggered prior to action being executed.
  17098. */
  17099. onBeforeExecuteObservable: Observable<Action>;
  17100. /**
  17101. * Creates a new Action
  17102. * @param triggerOptions the trigger, with or without parameters, for the action
  17103. * @param condition an optional determinant of action
  17104. */
  17105. constructor(
  17106. /** the trigger, with or without parameters, for the action */
  17107. triggerOptions: any, condition?: Condition);
  17108. /**
  17109. * Internal only
  17110. * @hidden
  17111. */
  17112. _prepare(): void;
  17113. /**
  17114. * Gets the trigger parameters
  17115. * @returns the trigger parameters
  17116. */
  17117. getTriggerParameter(): any;
  17118. /**
  17119. * Internal only - executes current action event
  17120. * @hidden
  17121. */
  17122. _executeCurrent(evt?: ActionEvent): void;
  17123. /**
  17124. * Execute placeholder for child classes
  17125. * @param evt optional action event
  17126. */
  17127. execute(evt?: ActionEvent): void;
  17128. /**
  17129. * Skips to next active action
  17130. */
  17131. skipToNextActiveAction(): void;
  17132. /**
  17133. * Adds action to chain of actions, may be a DoNothingAction
  17134. * @param action defines the next action to execute
  17135. * @returns The action passed in
  17136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17137. */
  17138. then(action: Action): Action;
  17139. /**
  17140. * Internal only
  17141. * @hidden
  17142. */
  17143. _getProperty(propertyPath: string): string;
  17144. /**
  17145. * Internal only
  17146. * @hidden
  17147. */
  17148. _getEffectiveTarget(target: any, propertyPath: string): any;
  17149. /**
  17150. * Serialize placeholder for child classes
  17151. * @param parent of child
  17152. * @returns the serialized object
  17153. */
  17154. serialize(parent: any): any;
  17155. /**
  17156. * Internal only called by serialize
  17157. * @hidden
  17158. */
  17159. protected _serialize(serializedAction: any, parent?: any): any;
  17160. /**
  17161. * Internal only
  17162. * @hidden
  17163. */
  17164. static _SerializeValueAsString: (value: any) => string;
  17165. /**
  17166. * Internal only
  17167. * @hidden
  17168. */
  17169. static _GetTargetProperty: (target: Node | Scene) => {
  17170. name: string;
  17171. targetType: string;
  17172. value: string;
  17173. };
  17174. }
  17175. }
  17176. declare module BABYLON {
  17177. /**
  17178. * A Condition applied to an Action
  17179. */
  17180. export class Condition {
  17181. /**
  17182. * Internal only - manager for action
  17183. * @hidden
  17184. */
  17185. _actionManager: ActionManager;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _evaluationId: number;
  17191. /**
  17192. * Internal only
  17193. * @hidden
  17194. */
  17195. _currentResult: boolean;
  17196. /**
  17197. * Creates a new Condition
  17198. * @param actionManager the manager of the action the condition is applied to
  17199. */
  17200. constructor(actionManager: ActionManager);
  17201. /**
  17202. * Check if the current condition is valid
  17203. * @returns a boolean
  17204. */
  17205. isValid(): boolean;
  17206. /**
  17207. * Internal only
  17208. * @hidden
  17209. */
  17210. _getProperty(propertyPath: string): string;
  17211. /**
  17212. * Internal only
  17213. * @hidden
  17214. */
  17215. _getEffectiveTarget(target: any, propertyPath: string): any;
  17216. /**
  17217. * Serialize placeholder for child classes
  17218. * @returns the serialized object
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Internal only
  17223. * @hidden
  17224. */
  17225. protected _serialize(serializedCondition: any): any;
  17226. }
  17227. /**
  17228. * Defines specific conditional operators as extensions of Condition
  17229. */
  17230. export class ValueCondition extends Condition {
  17231. /** path to specify the property of the target the conditional operator uses */
  17232. propertyPath: string;
  17233. /** the value compared by the conditional operator against the current value of the property */
  17234. value: any;
  17235. /** the conditional operator, default ValueCondition.IsEqual */
  17236. operator: number;
  17237. /**
  17238. * Internal only
  17239. * @hidden
  17240. */
  17241. private static _IsEqual;
  17242. /**
  17243. * Internal only
  17244. * @hidden
  17245. */
  17246. private static _IsDifferent;
  17247. /**
  17248. * Internal only
  17249. * @hidden
  17250. */
  17251. private static _IsGreater;
  17252. /**
  17253. * Internal only
  17254. * @hidden
  17255. */
  17256. private static _IsLesser;
  17257. /**
  17258. * returns the number for IsEqual
  17259. */
  17260. static get IsEqual(): number;
  17261. /**
  17262. * Returns the number for IsDifferent
  17263. */
  17264. static get IsDifferent(): number;
  17265. /**
  17266. * Returns the number for IsGreater
  17267. */
  17268. static get IsGreater(): number;
  17269. /**
  17270. * Returns the number for IsLesser
  17271. */
  17272. static get IsLesser(): number;
  17273. /**
  17274. * Internal only The action manager for the condition
  17275. * @hidden
  17276. */
  17277. _actionManager: ActionManager;
  17278. /**
  17279. * Internal only
  17280. * @hidden
  17281. */
  17282. private _target;
  17283. /**
  17284. * Internal only
  17285. * @hidden
  17286. */
  17287. private _effectiveTarget;
  17288. /**
  17289. * Internal only
  17290. * @hidden
  17291. */
  17292. private _property;
  17293. /**
  17294. * Creates a new ValueCondition
  17295. * @param actionManager manager for the action the condition applies to
  17296. * @param target for the action
  17297. * @param propertyPath path to specify the property of the target the conditional operator uses
  17298. * @param value the value compared by the conditional operator against the current value of the property
  17299. * @param operator the conditional operator, default ValueCondition.IsEqual
  17300. */
  17301. constructor(actionManager: ActionManager, target: any,
  17302. /** path to specify the property of the target the conditional operator uses */
  17303. propertyPath: string,
  17304. /** the value compared by the conditional operator against the current value of the property */
  17305. value: any,
  17306. /** the conditional operator, default ValueCondition.IsEqual */
  17307. operator?: number);
  17308. /**
  17309. * Compares the given value with the property value for the specified conditional operator
  17310. * @returns the result of the comparison
  17311. */
  17312. isValid(): boolean;
  17313. /**
  17314. * Serialize the ValueCondition into a JSON compatible object
  17315. * @returns serialization object
  17316. */
  17317. serialize(): any;
  17318. /**
  17319. * Gets the name of the conditional operator for the ValueCondition
  17320. * @param operator the conditional operator
  17321. * @returns the name
  17322. */
  17323. static GetOperatorName(operator: number): string;
  17324. }
  17325. /**
  17326. * Defines a predicate condition as an extension of Condition
  17327. */
  17328. export class PredicateCondition extends Condition {
  17329. /** defines the predicate function used to validate the condition */
  17330. predicate: () => boolean;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Creates a new PredicateCondition
  17338. * @param actionManager manager for the action the condition applies to
  17339. * @param predicate defines the predicate function used to validate the condition
  17340. */
  17341. constructor(actionManager: ActionManager,
  17342. /** defines the predicate function used to validate the condition */
  17343. predicate: () => boolean);
  17344. /**
  17345. * @returns the validity of the predicate condition
  17346. */
  17347. isValid(): boolean;
  17348. }
  17349. /**
  17350. * Defines a state condition as an extension of Condition
  17351. */
  17352. export class StateCondition extends Condition {
  17353. /** Value to compare with target state */
  17354. value: string;
  17355. /**
  17356. * Internal only - manager for action
  17357. * @hidden
  17358. */
  17359. _actionManager: ActionManager;
  17360. /**
  17361. * Internal only
  17362. * @hidden
  17363. */
  17364. private _target;
  17365. /**
  17366. * Creates a new StateCondition
  17367. * @param actionManager manager for the action the condition applies to
  17368. * @param target of the condition
  17369. * @param value to compare with target state
  17370. */
  17371. constructor(actionManager: ActionManager, target: any,
  17372. /** Value to compare with target state */
  17373. value: string);
  17374. /**
  17375. * Gets a boolean indicating if the current condition is met
  17376. * @returns the validity of the state
  17377. */
  17378. isValid(): boolean;
  17379. /**
  17380. * Serialize the StateCondition into a JSON compatible object
  17381. * @returns serialization object
  17382. */
  17383. serialize(): any;
  17384. }
  17385. }
  17386. declare module BABYLON {
  17387. /**
  17388. * This defines an action responsible to toggle a boolean once triggered.
  17389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17390. */
  17391. export class SwitchBooleanAction extends Action {
  17392. /**
  17393. * The path to the boolean property in the target object
  17394. */
  17395. propertyPath: string;
  17396. private _target;
  17397. private _effectiveTarget;
  17398. private _property;
  17399. /**
  17400. * Instantiate the action
  17401. * @param triggerOptions defines the trigger options
  17402. * @param target defines the object containing the boolean
  17403. * @param propertyPath defines the path to the boolean property in the target object
  17404. * @param condition defines the trigger related conditions
  17405. */
  17406. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17407. /** @hidden */
  17408. _prepare(): void;
  17409. /**
  17410. * Execute the action toggle the boolean value.
  17411. */
  17412. execute(): void;
  17413. /**
  17414. * Serializes the actions and its related information.
  17415. * @param parent defines the object to serialize in
  17416. * @returns the serialized object
  17417. */
  17418. serialize(parent: any): any;
  17419. }
  17420. /**
  17421. * This defines an action responsible to set a the state field of the target
  17422. * to a desired value once triggered.
  17423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17424. */
  17425. export class SetStateAction extends Action {
  17426. /**
  17427. * The value to store in the state field.
  17428. */
  17429. value: string;
  17430. private _target;
  17431. /**
  17432. * Instantiate the action
  17433. * @param triggerOptions defines the trigger options
  17434. * @param target defines the object containing the state property
  17435. * @param value defines the value to store in the state field
  17436. * @param condition defines the trigger related conditions
  17437. */
  17438. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17439. /**
  17440. * Execute the action and store the value on the target state property.
  17441. */
  17442. execute(): void;
  17443. /**
  17444. * Serializes the actions and its related information.
  17445. * @param parent defines the object to serialize in
  17446. * @returns the serialized object
  17447. */
  17448. serialize(parent: any): any;
  17449. }
  17450. /**
  17451. * This defines an action responsible to set a property of the target
  17452. * to a desired value once triggered.
  17453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17454. */
  17455. export class SetValueAction extends Action {
  17456. /**
  17457. * The path of the property to set in the target.
  17458. */
  17459. propertyPath: string;
  17460. /**
  17461. * The value to set in the property
  17462. */
  17463. value: any;
  17464. private _target;
  17465. private _effectiveTarget;
  17466. private _property;
  17467. /**
  17468. * Instantiate the action
  17469. * @param triggerOptions defines the trigger options
  17470. * @param target defines the object containing the property
  17471. * @param propertyPath defines the path of the property to set in the target
  17472. * @param value defines the value to set in the property
  17473. * @param condition defines the trigger related conditions
  17474. */
  17475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17476. /** @hidden */
  17477. _prepare(): void;
  17478. /**
  17479. * Execute the action and set the targetted property to the desired value.
  17480. */
  17481. execute(): void;
  17482. /**
  17483. * Serializes the actions and its related information.
  17484. * @param parent defines the object to serialize in
  17485. * @returns the serialized object
  17486. */
  17487. serialize(parent: any): any;
  17488. }
  17489. /**
  17490. * This defines an action responsible to increment the target value
  17491. * to a desired value once triggered.
  17492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17493. */
  17494. export class IncrementValueAction extends Action {
  17495. /**
  17496. * The path of the property to increment in the target.
  17497. */
  17498. propertyPath: string;
  17499. /**
  17500. * The value we should increment the property by.
  17501. */
  17502. value: any;
  17503. private _target;
  17504. private _effectiveTarget;
  17505. private _property;
  17506. /**
  17507. * Instantiate the action
  17508. * @param triggerOptions defines the trigger options
  17509. * @param target defines the object containing the property
  17510. * @param propertyPath defines the path of the property to increment in the target
  17511. * @param value defines the value value we should increment the property by
  17512. * @param condition defines the trigger related conditions
  17513. */
  17514. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17515. /** @hidden */
  17516. _prepare(): void;
  17517. /**
  17518. * Execute the action and increment the target of the value amount.
  17519. */
  17520. execute(): void;
  17521. /**
  17522. * Serializes the actions and its related information.
  17523. * @param parent defines the object to serialize in
  17524. * @returns the serialized object
  17525. */
  17526. serialize(parent: any): any;
  17527. }
  17528. /**
  17529. * This defines an action responsible to start an animation once triggered.
  17530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17531. */
  17532. export class PlayAnimationAction extends Action {
  17533. /**
  17534. * Where the animation should start (animation frame)
  17535. */
  17536. from: number;
  17537. /**
  17538. * Where the animation should stop (animation frame)
  17539. */
  17540. to: number;
  17541. /**
  17542. * Define if the animation should loop or stop after the first play.
  17543. */
  17544. loop?: boolean;
  17545. private _target;
  17546. /**
  17547. * Instantiate the action
  17548. * @param triggerOptions defines the trigger options
  17549. * @param target defines the target animation or animation name
  17550. * @param from defines from where the animation should start (animation frame)
  17551. * @param end defines where the animation should stop (animation frame)
  17552. * @param loop defines if the animation should loop or stop after the first play
  17553. * @param condition defines the trigger related conditions
  17554. */
  17555. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17556. /** @hidden */
  17557. _prepare(): void;
  17558. /**
  17559. * Execute the action and play the animation.
  17560. */
  17561. execute(): void;
  17562. /**
  17563. * Serializes the actions and its related information.
  17564. * @param parent defines the object to serialize in
  17565. * @returns the serialized object
  17566. */
  17567. serialize(parent: any): any;
  17568. }
  17569. /**
  17570. * This defines an action responsible to stop an animation once triggered.
  17571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17572. */
  17573. export class StopAnimationAction extends Action {
  17574. private _target;
  17575. /**
  17576. * Instantiate the action
  17577. * @param triggerOptions defines the trigger options
  17578. * @param target defines the target animation or animation name
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions: any, target: any, condition?: Condition);
  17582. /** @hidden */
  17583. _prepare(): void;
  17584. /**
  17585. * Execute the action and stop the animation.
  17586. */
  17587. execute(): void;
  17588. /**
  17589. * Serializes the actions and its related information.
  17590. * @param parent defines the object to serialize in
  17591. * @returns the serialized object
  17592. */
  17593. serialize(parent: any): any;
  17594. }
  17595. /**
  17596. * This defines an action responsible that does nothing once triggered.
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17598. */
  17599. export class DoNothingAction extends Action {
  17600. /**
  17601. * Instantiate the action
  17602. * @param triggerOptions defines the trigger options
  17603. * @param condition defines the trigger related conditions
  17604. */
  17605. constructor(triggerOptions?: any, condition?: Condition);
  17606. /**
  17607. * Execute the action and do nothing.
  17608. */
  17609. execute(): void;
  17610. /**
  17611. * Serializes the actions and its related information.
  17612. * @param parent defines the object to serialize in
  17613. * @returns the serialized object
  17614. */
  17615. serialize(parent: any): any;
  17616. }
  17617. /**
  17618. * This defines an action responsible to trigger several actions once triggered.
  17619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17620. */
  17621. export class CombineAction extends Action {
  17622. /**
  17623. * The list of aggregated animations to run.
  17624. */
  17625. children: Action[];
  17626. /**
  17627. * Instantiate the action
  17628. * @param triggerOptions defines the trigger options
  17629. * @param children defines the list of aggregated animations to run
  17630. * @param condition defines the trigger related conditions
  17631. */
  17632. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17633. /** @hidden */
  17634. _prepare(): void;
  17635. /**
  17636. * Execute the action and executes all the aggregated actions.
  17637. */
  17638. execute(evt: ActionEvent): void;
  17639. /**
  17640. * Serializes the actions and its related information.
  17641. * @param parent defines the object to serialize in
  17642. * @returns the serialized object
  17643. */
  17644. serialize(parent: any): any;
  17645. }
  17646. /**
  17647. * This defines an action responsible to run code (external event) once triggered.
  17648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17649. */
  17650. export class ExecuteCodeAction extends Action {
  17651. /**
  17652. * The callback function to run.
  17653. */
  17654. func: (evt: ActionEvent) => void;
  17655. /**
  17656. * Instantiate the action
  17657. * @param triggerOptions defines the trigger options
  17658. * @param func defines the callback function to run
  17659. * @param condition defines the trigger related conditions
  17660. */
  17661. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17662. /**
  17663. * Execute the action and run the attached code.
  17664. */
  17665. execute(evt: ActionEvent): void;
  17666. }
  17667. /**
  17668. * This defines an action responsible to set the parent property of the target once triggered.
  17669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17670. */
  17671. export class SetParentAction extends Action {
  17672. private _parent;
  17673. private _target;
  17674. /**
  17675. * Instantiate the action
  17676. * @param triggerOptions defines the trigger options
  17677. * @param target defines the target containing the parent property
  17678. * @param parent defines from where the animation should start (animation frame)
  17679. * @param condition defines the trigger related conditions
  17680. */
  17681. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17682. /** @hidden */
  17683. _prepare(): void;
  17684. /**
  17685. * Execute the action and set the parent property.
  17686. */
  17687. execute(): void;
  17688. /**
  17689. * Serializes the actions and its related information.
  17690. * @param parent defines the object to serialize in
  17691. * @returns the serialized object
  17692. */
  17693. serialize(parent: any): any;
  17694. }
  17695. }
  17696. declare module BABYLON {
  17697. /**
  17698. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17699. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17701. */
  17702. export class ActionManager extends AbstractActionManager {
  17703. /**
  17704. * Nothing
  17705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17706. */
  17707. static readonly NothingTrigger: number;
  17708. /**
  17709. * On pick
  17710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17711. */
  17712. static readonly OnPickTrigger: number;
  17713. /**
  17714. * On left pick
  17715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17716. */
  17717. static readonly OnLeftPickTrigger: number;
  17718. /**
  17719. * On right pick
  17720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17721. */
  17722. static readonly OnRightPickTrigger: number;
  17723. /**
  17724. * On center pick
  17725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17726. */
  17727. static readonly OnCenterPickTrigger: number;
  17728. /**
  17729. * On pick down
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17731. */
  17732. static readonly OnPickDownTrigger: number;
  17733. /**
  17734. * On double pick
  17735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17736. */
  17737. static readonly OnDoublePickTrigger: number;
  17738. /**
  17739. * On pick up
  17740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17741. */
  17742. static readonly OnPickUpTrigger: number;
  17743. /**
  17744. * On pick out.
  17745. * This trigger will only be raised if you also declared a OnPickDown
  17746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17747. */
  17748. static readonly OnPickOutTrigger: number;
  17749. /**
  17750. * On long press
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17752. */
  17753. static readonly OnLongPressTrigger: number;
  17754. /**
  17755. * On pointer over
  17756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17757. */
  17758. static readonly OnPointerOverTrigger: number;
  17759. /**
  17760. * On pointer out
  17761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17762. */
  17763. static readonly OnPointerOutTrigger: number;
  17764. /**
  17765. * On every frame
  17766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17767. */
  17768. static readonly OnEveryFrameTrigger: number;
  17769. /**
  17770. * On intersection enter
  17771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17772. */
  17773. static readonly OnIntersectionEnterTrigger: number;
  17774. /**
  17775. * On intersection exit
  17776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17777. */
  17778. static readonly OnIntersectionExitTrigger: number;
  17779. /**
  17780. * On key down
  17781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17782. */
  17783. static readonly OnKeyDownTrigger: number;
  17784. /**
  17785. * On key up
  17786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17787. */
  17788. static readonly OnKeyUpTrigger: number;
  17789. private _scene;
  17790. /**
  17791. * Creates a new action manager
  17792. * @param scene defines the hosting scene
  17793. */
  17794. constructor(scene: Scene);
  17795. /**
  17796. * Releases all associated resources
  17797. */
  17798. dispose(): void;
  17799. /**
  17800. * Gets hosting scene
  17801. * @returns the hosting scene
  17802. */
  17803. getScene(): Scene;
  17804. /**
  17805. * Does this action manager handles actions of any of the given triggers
  17806. * @param triggers defines the triggers to be tested
  17807. * @return a boolean indicating whether one (or more) of the triggers is handled
  17808. */
  17809. hasSpecificTriggers(triggers: number[]): boolean;
  17810. /**
  17811. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17812. * speed.
  17813. * @param triggerA defines the trigger to be tested
  17814. * @param triggerB defines the trigger to be tested
  17815. * @return a boolean indicating whether one (or more) of the triggers is handled
  17816. */
  17817. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17818. /**
  17819. * Does this action manager handles actions of a given trigger
  17820. * @param trigger defines the trigger to be tested
  17821. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17822. * @return whether the trigger is handled
  17823. */
  17824. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17825. /**
  17826. * Does this action manager has pointer triggers
  17827. */
  17828. get hasPointerTriggers(): boolean;
  17829. /**
  17830. * Does this action manager has pick triggers
  17831. */
  17832. get hasPickTriggers(): boolean;
  17833. /**
  17834. * Registers an action to this action manager
  17835. * @param action defines the action to be registered
  17836. * @return the action amended (prepared) after registration
  17837. */
  17838. registerAction(action: IAction): Nullable<IAction>;
  17839. /**
  17840. * Unregisters an action to this action manager
  17841. * @param action defines the action to be unregistered
  17842. * @return a boolean indicating whether the action has been unregistered
  17843. */
  17844. unregisterAction(action: IAction): Boolean;
  17845. /**
  17846. * Process a specific trigger
  17847. * @param trigger defines the trigger to process
  17848. * @param evt defines the event details to be processed
  17849. */
  17850. processTrigger(trigger: number, evt?: IActionEvent): void;
  17851. /** @hidden */
  17852. _getEffectiveTarget(target: any, propertyPath: string): any;
  17853. /** @hidden */
  17854. _getProperty(propertyPath: string): string;
  17855. /**
  17856. * Serialize this manager to a JSON object
  17857. * @param name defines the property name to store this manager
  17858. * @returns a JSON representation of this manager
  17859. */
  17860. serialize(name: string): any;
  17861. /**
  17862. * Creates a new ActionManager from a JSON data
  17863. * @param parsedActions defines the JSON data to read from
  17864. * @param object defines the hosting mesh
  17865. * @param scene defines the hosting scene
  17866. */
  17867. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17868. /**
  17869. * Get a trigger name by index
  17870. * @param trigger defines the trigger index
  17871. * @returns a trigger name
  17872. */
  17873. static GetTriggerName(trigger: number): string;
  17874. }
  17875. }
  17876. declare module BABYLON {
  17877. /**
  17878. * Class used to represent a sprite
  17879. * @see http://doc.babylonjs.com/babylon101/sprites
  17880. */
  17881. export class Sprite {
  17882. /** defines the name */
  17883. name: string;
  17884. /** Gets or sets the current world position */
  17885. position: Vector3;
  17886. /** Gets or sets the main color */
  17887. color: Color4;
  17888. /** Gets or sets the width */
  17889. width: number;
  17890. /** Gets or sets the height */
  17891. height: number;
  17892. /** Gets or sets rotation angle */
  17893. angle: number;
  17894. /** Gets or sets the cell index in the sprite sheet */
  17895. cellIndex: number;
  17896. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17897. cellRef: string;
  17898. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17899. invertU: number;
  17900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17901. invertV: number;
  17902. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17903. disposeWhenFinishedAnimating: boolean;
  17904. /** Gets the list of attached animations */
  17905. animations: Animation[];
  17906. /** Gets or sets a boolean indicating if the sprite can be picked */
  17907. isPickable: boolean;
  17908. /**
  17909. * Gets or sets the associated action manager
  17910. */
  17911. actionManager: Nullable<ActionManager>;
  17912. private _animationStarted;
  17913. private _loopAnimation;
  17914. private _fromIndex;
  17915. private _toIndex;
  17916. private _delay;
  17917. private _direction;
  17918. private _manager;
  17919. private _time;
  17920. private _onAnimationEnd;
  17921. /**
  17922. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17923. */
  17924. isVisible: boolean;
  17925. /**
  17926. * Gets or sets the sprite size
  17927. */
  17928. get size(): number;
  17929. set size(value: number);
  17930. /**
  17931. * Creates a new Sprite
  17932. * @param name defines the name
  17933. * @param manager defines the manager
  17934. */
  17935. constructor(
  17936. /** defines the name */
  17937. name: string, manager: ISpriteManager);
  17938. /**
  17939. * Starts an animation
  17940. * @param from defines the initial key
  17941. * @param to defines the end key
  17942. * @param loop defines if the animation must loop
  17943. * @param delay defines the start delay (in ms)
  17944. * @param onAnimationEnd defines a callback to call when animation ends
  17945. */
  17946. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17947. /** Stops current animation (if any) */
  17948. stopAnimation(): void;
  17949. /** @hidden */
  17950. _animate(deltaTime: number): void;
  17951. /** Release associated resources */
  17952. dispose(): void;
  17953. }
  17954. }
  17955. declare module BABYLON {
  17956. /**
  17957. * Information about the result of picking within a scene
  17958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17959. */
  17960. export class PickingInfo {
  17961. /** @hidden */
  17962. _pickingUnavailable: boolean;
  17963. /**
  17964. * If the pick collided with an object
  17965. */
  17966. hit: boolean;
  17967. /**
  17968. * Distance away where the pick collided
  17969. */
  17970. distance: number;
  17971. /**
  17972. * The location of pick collision
  17973. */
  17974. pickedPoint: Nullable<Vector3>;
  17975. /**
  17976. * The mesh corresponding the the pick collision
  17977. */
  17978. pickedMesh: Nullable<AbstractMesh>;
  17979. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17980. bu: number;
  17981. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17982. bv: number;
  17983. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17984. faceId: number;
  17985. /** Id of the the submesh that was picked */
  17986. subMeshId: number;
  17987. /** If a sprite was picked, this will be the sprite the pick collided with */
  17988. pickedSprite: Nullable<Sprite>;
  17989. /**
  17990. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17991. */
  17992. originMesh: Nullable<AbstractMesh>;
  17993. /**
  17994. * The ray that was used to perform the picking.
  17995. */
  17996. ray: Nullable<Ray>;
  17997. /**
  17998. * Gets the normal correspodning to the face the pick collided with
  17999. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18000. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18001. * @returns The normal correspodning to the face the pick collided with
  18002. */
  18003. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18004. /**
  18005. * Gets the texture coordinates of where the pick occured
  18006. * @returns the vector containing the coordnates of the texture
  18007. */
  18008. getTextureCoordinates(): Nullable<Vector2>;
  18009. }
  18010. }
  18011. declare module BABYLON {
  18012. /**
  18013. * Gather the list of pointer event types as constants.
  18014. */
  18015. export class PointerEventTypes {
  18016. /**
  18017. * 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.
  18018. */
  18019. static readonly POINTERDOWN: number;
  18020. /**
  18021. * The pointerup event is fired when a pointer is no longer active.
  18022. */
  18023. static readonly POINTERUP: number;
  18024. /**
  18025. * The pointermove event is fired when a pointer changes coordinates.
  18026. */
  18027. static readonly POINTERMOVE: number;
  18028. /**
  18029. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18030. */
  18031. static readonly POINTERWHEEL: number;
  18032. /**
  18033. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18034. */
  18035. static readonly POINTERPICK: number;
  18036. /**
  18037. * The pointertap event is fired when a the object has been touched and released without drag.
  18038. */
  18039. static readonly POINTERTAP: number;
  18040. /**
  18041. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18042. */
  18043. static readonly POINTERDOUBLETAP: number;
  18044. }
  18045. /**
  18046. * Base class of pointer info types.
  18047. */
  18048. export class PointerInfoBase {
  18049. /**
  18050. * Defines the type of event (PointerEventTypes)
  18051. */
  18052. type: number;
  18053. /**
  18054. * Defines the related dom event
  18055. */
  18056. event: PointerEvent | MouseWheelEvent;
  18057. /**
  18058. * Instantiates the base class of pointers info.
  18059. * @param type Defines the type of event (PointerEventTypes)
  18060. * @param event Defines the related dom event
  18061. */
  18062. constructor(
  18063. /**
  18064. * Defines the type of event (PointerEventTypes)
  18065. */
  18066. type: number,
  18067. /**
  18068. * Defines the related dom event
  18069. */
  18070. event: PointerEvent | MouseWheelEvent);
  18071. }
  18072. /**
  18073. * This class is used to store pointer related info for the onPrePointerObservable event.
  18074. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18075. */
  18076. export class PointerInfoPre extends PointerInfoBase {
  18077. /**
  18078. * Ray from a pointer if availible (eg. 6dof controller)
  18079. */
  18080. ray: Nullable<Ray>;
  18081. /**
  18082. * Defines the local position of the pointer on the canvas.
  18083. */
  18084. localPosition: Vector2;
  18085. /**
  18086. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18087. */
  18088. skipOnPointerObservable: boolean;
  18089. /**
  18090. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18091. * @param type Defines the type of event (PointerEventTypes)
  18092. * @param event Defines the related dom event
  18093. * @param localX Defines the local x coordinates of the pointer when the event occured
  18094. * @param localY Defines the local y coordinates of the pointer when the event occured
  18095. */
  18096. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18097. }
  18098. /**
  18099. * This type contains all the data related to a pointer event in Babylon.js.
  18100. * 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.
  18101. */
  18102. export class PointerInfo extends PointerInfoBase {
  18103. /**
  18104. * Defines the picking info associated to the info (if any)\
  18105. */
  18106. pickInfo: Nullable<PickingInfo>;
  18107. /**
  18108. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18109. * @param type Defines the type of event (PointerEventTypes)
  18110. * @param event Defines the related dom event
  18111. * @param pickInfo Defines the picking info associated to the info (if any)\
  18112. */
  18113. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18114. /**
  18115. * Defines the picking info associated to the info (if any)\
  18116. */
  18117. pickInfo: Nullable<PickingInfo>);
  18118. }
  18119. /**
  18120. * Data relating to a touch event on the screen.
  18121. */
  18122. export interface PointerTouch {
  18123. /**
  18124. * X coordinate of touch.
  18125. */
  18126. x: number;
  18127. /**
  18128. * Y coordinate of touch.
  18129. */
  18130. y: number;
  18131. /**
  18132. * Id of touch. Unique for each finger.
  18133. */
  18134. pointerId: number;
  18135. /**
  18136. * Event type passed from DOM.
  18137. */
  18138. type: any;
  18139. }
  18140. }
  18141. declare module BABYLON {
  18142. /**
  18143. * Manage the mouse inputs to control the movement of a free camera.
  18144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18145. */
  18146. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18147. /**
  18148. * Define if touch is enabled in the mouse input
  18149. */
  18150. touchEnabled: boolean;
  18151. /**
  18152. * Defines the camera the input is attached to.
  18153. */
  18154. camera: FreeCamera;
  18155. /**
  18156. * Defines the buttons associated with the input to handle camera move.
  18157. */
  18158. buttons: number[];
  18159. /**
  18160. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18161. */
  18162. angularSensibility: number;
  18163. private _pointerInput;
  18164. private _onMouseMove;
  18165. private _observer;
  18166. private previousPosition;
  18167. /**
  18168. * Observable for when a pointer move event occurs containing the move offset
  18169. */
  18170. onPointerMovedObservable: Observable<{
  18171. offsetX: number;
  18172. offsetY: number;
  18173. }>;
  18174. /**
  18175. * @hidden
  18176. * If the camera should be rotated automatically based on pointer movement
  18177. */
  18178. _allowCameraRotation: boolean;
  18179. /**
  18180. * Manage the mouse inputs to control the movement of a free camera.
  18181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18182. * @param touchEnabled Defines if touch is enabled or not
  18183. */
  18184. constructor(
  18185. /**
  18186. * Define if touch is enabled in the mouse input
  18187. */
  18188. touchEnabled?: boolean);
  18189. /**
  18190. * Attach the input controls to a specific dom element to get the input from.
  18191. * @param element Defines the element the controls should be listened from
  18192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18193. */
  18194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18195. /**
  18196. * Called on JS contextmenu event.
  18197. * Override this method to provide functionality.
  18198. */
  18199. protected onContextMenu(evt: PointerEvent): void;
  18200. /**
  18201. * Detach the current controls from the specified dom element.
  18202. * @param element Defines the element to stop listening the inputs from
  18203. */
  18204. detachControl(element: Nullable<HTMLElement>): void;
  18205. /**
  18206. * Gets the class name of the current intput.
  18207. * @returns the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Get the friendly name associated with the input class.
  18212. * @returns the input friendly name
  18213. */
  18214. getSimpleName(): string;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. /**
  18219. * Manage the touch inputs to control the movement of a free camera.
  18220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18221. */
  18222. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18223. /**
  18224. * Defines the camera the input is attached to.
  18225. */
  18226. camera: FreeCamera;
  18227. /**
  18228. * Defines the touch sensibility for rotation.
  18229. * The higher the faster.
  18230. */
  18231. touchAngularSensibility: number;
  18232. /**
  18233. * Defines the touch sensibility for move.
  18234. * The higher the faster.
  18235. */
  18236. touchMoveSensibility: number;
  18237. private _offsetX;
  18238. private _offsetY;
  18239. private _pointerPressed;
  18240. private _pointerInput;
  18241. private _observer;
  18242. private _onLostFocus;
  18243. /**
  18244. * Attach the input controls to a specific dom element to get the input from.
  18245. * @param element Defines the element the controls should be listened from
  18246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18247. */
  18248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18249. /**
  18250. * Detach the current controls from the specified dom element.
  18251. * @param element Defines the element to stop listening the inputs from
  18252. */
  18253. detachControl(element: Nullable<HTMLElement>): void;
  18254. /**
  18255. * Update the current camera state depending on the inputs that have been used this frame.
  18256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18257. */
  18258. checkInputs(): void;
  18259. /**
  18260. * Gets the class name of the current intput.
  18261. * @returns the class name
  18262. */
  18263. getClassName(): string;
  18264. /**
  18265. * Get the friendly name associated with the input class.
  18266. * @returns the input friendly name
  18267. */
  18268. getSimpleName(): string;
  18269. }
  18270. }
  18271. declare module BABYLON {
  18272. /**
  18273. * Default Inputs manager for the FreeCamera.
  18274. * It groups all the default supported inputs for ease of use.
  18275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18276. */
  18277. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18278. /**
  18279. * @hidden
  18280. */
  18281. _mouseInput: Nullable<FreeCameraMouseInput>;
  18282. /**
  18283. * Instantiates a new FreeCameraInputsManager.
  18284. * @param camera Defines the camera the inputs belong to
  18285. */
  18286. constructor(camera: FreeCamera);
  18287. /**
  18288. * Add keyboard input support to the input manager.
  18289. * @returns the current input manager
  18290. */
  18291. addKeyboard(): FreeCameraInputsManager;
  18292. /**
  18293. * Add mouse input support to the input manager.
  18294. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18295. * @returns the current input manager
  18296. */
  18297. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18298. /**
  18299. * Removes the mouse input support from the manager
  18300. * @returns the current input manager
  18301. */
  18302. removeMouse(): FreeCameraInputsManager;
  18303. /**
  18304. * Add touch input support to the input manager.
  18305. * @returns the current input manager
  18306. */
  18307. addTouch(): FreeCameraInputsManager;
  18308. /**
  18309. * Remove all attached input methods from a camera
  18310. */
  18311. clear(): void;
  18312. }
  18313. }
  18314. declare module BABYLON {
  18315. /**
  18316. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18317. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18319. */
  18320. export class FreeCamera extends TargetCamera {
  18321. /**
  18322. * Define the collision ellipsoid of the camera.
  18323. * This is helpful to simulate a camera body like the player body around the camera
  18324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18325. */
  18326. ellipsoid: Vector3;
  18327. /**
  18328. * Define an offset for the position of the ellipsoid around the camera.
  18329. * This can be helpful to determine the center of the body near the gravity center of the body
  18330. * instead of its head.
  18331. */
  18332. ellipsoidOffset: Vector3;
  18333. /**
  18334. * Enable or disable collisions of the camera with the rest of the scene objects.
  18335. */
  18336. checkCollisions: boolean;
  18337. /**
  18338. * Enable or disable gravity on the camera.
  18339. */
  18340. applyGravity: boolean;
  18341. /**
  18342. * Define the input manager associated to the camera.
  18343. */
  18344. inputs: FreeCameraInputsManager;
  18345. /**
  18346. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18347. * Higher values reduce sensitivity.
  18348. */
  18349. get angularSensibility(): number;
  18350. /**
  18351. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18352. * Higher values reduce sensitivity.
  18353. */
  18354. set angularSensibility(value: number);
  18355. /**
  18356. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18357. */
  18358. get keysUp(): number[];
  18359. set keysUp(value: number[]);
  18360. /**
  18361. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18362. */
  18363. get keysDown(): number[];
  18364. set keysDown(value: number[]);
  18365. /**
  18366. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18367. */
  18368. get keysLeft(): number[];
  18369. set keysLeft(value: number[]);
  18370. /**
  18371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18372. */
  18373. get keysRight(): number[];
  18374. set keysRight(value: number[]);
  18375. /**
  18376. * Event raised when the camera collide with a mesh in the scene.
  18377. */
  18378. onCollide: (collidedMesh: AbstractMesh) => void;
  18379. private _collider;
  18380. private _needMoveForGravity;
  18381. private _oldPosition;
  18382. private _diffPosition;
  18383. private _newPosition;
  18384. /** @hidden */
  18385. _localDirection: Vector3;
  18386. /** @hidden */
  18387. _transformedDirection: Vector3;
  18388. /**
  18389. * Instantiates a Free Camera.
  18390. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18391. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18393. * @param name Define the name of the camera in the scene
  18394. * @param position Define the start position of the camera in the scene
  18395. * @param scene Define the scene the camera belongs to
  18396. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18397. */
  18398. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18399. /**
  18400. * Attached controls to the current camera.
  18401. * @param element Defines the element the controls should be listened from
  18402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18403. */
  18404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18405. /**
  18406. * Detach the current controls from the camera.
  18407. * The camera will stop reacting to inputs.
  18408. * @param element Defines the element to stop listening the inputs from
  18409. */
  18410. detachControl(element: HTMLElement): void;
  18411. private _collisionMask;
  18412. /**
  18413. * Define a collision mask to limit the list of object the camera can collide with
  18414. */
  18415. get collisionMask(): number;
  18416. set collisionMask(mask: number);
  18417. /** @hidden */
  18418. _collideWithWorld(displacement: Vector3): void;
  18419. private _onCollisionPositionChange;
  18420. /** @hidden */
  18421. _checkInputs(): void;
  18422. /** @hidden */
  18423. _decideIfNeedsToMove(): boolean;
  18424. /** @hidden */
  18425. _updatePosition(): void;
  18426. /**
  18427. * Destroy the camera and release the current resources hold by it.
  18428. */
  18429. dispose(): void;
  18430. /**
  18431. * Gets the current object class name.
  18432. * @return the class name
  18433. */
  18434. getClassName(): string;
  18435. }
  18436. }
  18437. declare module BABYLON {
  18438. /**
  18439. * Represents a gamepad control stick position
  18440. */
  18441. export class StickValues {
  18442. /**
  18443. * The x component of the control stick
  18444. */
  18445. x: number;
  18446. /**
  18447. * The y component of the control stick
  18448. */
  18449. y: number;
  18450. /**
  18451. * Initializes the gamepad x and y control stick values
  18452. * @param x The x component of the gamepad control stick value
  18453. * @param y The y component of the gamepad control stick value
  18454. */
  18455. constructor(
  18456. /**
  18457. * The x component of the control stick
  18458. */
  18459. x: number,
  18460. /**
  18461. * The y component of the control stick
  18462. */
  18463. y: number);
  18464. }
  18465. /**
  18466. * An interface which manages callbacks for gamepad button changes
  18467. */
  18468. export interface GamepadButtonChanges {
  18469. /**
  18470. * Called when a gamepad has been changed
  18471. */
  18472. changed: boolean;
  18473. /**
  18474. * Called when a gamepad press event has been triggered
  18475. */
  18476. pressChanged: boolean;
  18477. /**
  18478. * Called when a touch event has been triggered
  18479. */
  18480. touchChanged: boolean;
  18481. /**
  18482. * Called when a value has changed
  18483. */
  18484. valueChanged: boolean;
  18485. }
  18486. /**
  18487. * Represents a gamepad
  18488. */
  18489. export class Gamepad {
  18490. /**
  18491. * The id of the gamepad
  18492. */
  18493. id: string;
  18494. /**
  18495. * The index of the gamepad
  18496. */
  18497. index: number;
  18498. /**
  18499. * The browser gamepad
  18500. */
  18501. browserGamepad: any;
  18502. /**
  18503. * Specifies what type of gamepad this represents
  18504. */
  18505. type: number;
  18506. private _leftStick;
  18507. private _rightStick;
  18508. /** @hidden */
  18509. _isConnected: boolean;
  18510. private _leftStickAxisX;
  18511. private _leftStickAxisY;
  18512. private _rightStickAxisX;
  18513. private _rightStickAxisY;
  18514. /**
  18515. * Triggered when the left control stick has been changed
  18516. */
  18517. private _onleftstickchanged;
  18518. /**
  18519. * Triggered when the right control stick has been changed
  18520. */
  18521. private _onrightstickchanged;
  18522. /**
  18523. * Represents a gamepad controller
  18524. */
  18525. static GAMEPAD: number;
  18526. /**
  18527. * Represents a generic controller
  18528. */
  18529. static GENERIC: number;
  18530. /**
  18531. * Represents an XBox controller
  18532. */
  18533. static XBOX: number;
  18534. /**
  18535. * Represents a pose-enabled controller
  18536. */
  18537. static POSE_ENABLED: number;
  18538. /**
  18539. * Represents an Dual Shock controller
  18540. */
  18541. static DUALSHOCK: number;
  18542. /**
  18543. * Specifies whether the left control stick should be Y-inverted
  18544. */
  18545. protected _invertLeftStickY: boolean;
  18546. /**
  18547. * Specifies if the gamepad has been connected
  18548. */
  18549. get isConnected(): boolean;
  18550. /**
  18551. * Initializes the gamepad
  18552. * @param id The id of the gamepad
  18553. * @param index The index of the gamepad
  18554. * @param browserGamepad The browser gamepad
  18555. * @param leftStickX The x component of the left joystick
  18556. * @param leftStickY The y component of the left joystick
  18557. * @param rightStickX The x component of the right joystick
  18558. * @param rightStickY The y component of the right joystick
  18559. */
  18560. constructor(
  18561. /**
  18562. * The id of the gamepad
  18563. */
  18564. id: string,
  18565. /**
  18566. * The index of the gamepad
  18567. */
  18568. index: number,
  18569. /**
  18570. * The browser gamepad
  18571. */
  18572. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18573. /**
  18574. * Callback triggered when the left joystick has changed
  18575. * @param callback
  18576. */
  18577. onleftstickchanged(callback: (values: StickValues) => void): void;
  18578. /**
  18579. * Callback triggered when the right joystick has changed
  18580. * @param callback
  18581. */
  18582. onrightstickchanged(callback: (values: StickValues) => void): void;
  18583. /**
  18584. * Gets the left joystick
  18585. */
  18586. get leftStick(): StickValues;
  18587. /**
  18588. * Sets the left joystick values
  18589. */
  18590. set leftStick(newValues: StickValues);
  18591. /**
  18592. * Gets the right joystick
  18593. */
  18594. get rightStick(): StickValues;
  18595. /**
  18596. * Sets the right joystick value
  18597. */
  18598. set rightStick(newValues: StickValues);
  18599. /**
  18600. * Updates the gamepad joystick positions
  18601. */
  18602. update(): void;
  18603. /**
  18604. * Disposes the gamepad
  18605. */
  18606. dispose(): void;
  18607. }
  18608. /**
  18609. * Represents a generic gamepad
  18610. */
  18611. export class GenericPad extends Gamepad {
  18612. private _buttons;
  18613. private _onbuttondown;
  18614. private _onbuttonup;
  18615. /**
  18616. * Observable triggered when a button has been pressed
  18617. */
  18618. onButtonDownObservable: Observable<number>;
  18619. /**
  18620. * Observable triggered when a button has been released
  18621. */
  18622. onButtonUpObservable: Observable<number>;
  18623. /**
  18624. * Callback triggered when a button has been pressed
  18625. * @param callback Called when a button has been pressed
  18626. */
  18627. onbuttondown(callback: (buttonPressed: number) => void): void;
  18628. /**
  18629. * Callback triggered when a button has been released
  18630. * @param callback Called when a button has been released
  18631. */
  18632. onbuttonup(callback: (buttonReleased: number) => void): void;
  18633. /**
  18634. * Initializes the generic gamepad
  18635. * @param id The id of the generic gamepad
  18636. * @param index The index of the generic gamepad
  18637. * @param browserGamepad The browser gamepad
  18638. */
  18639. constructor(id: string, index: number, browserGamepad: any);
  18640. private _setButtonValue;
  18641. /**
  18642. * Updates the generic gamepad
  18643. */
  18644. update(): void;
  18645. /**
  18646. * Disposes the generic gamepad
  18647. */
  18648. dispose(): void;
  18649. }
  18650. }
  18651. declare module BABYLON {
  18652. /**
  18653. * Defines the types of pose enabled controllers that are supported
  18654. */
  18655. export enum PoseEnabledControllerType {
  18656. /**
  18657. * HTC Vive
  18658. */
  18659. VIVE = 0,
  18660. /**
  18661. * Oculus Rift
  18662. */
  18663. OCULUS = 1,
  18664. /**
  18665. * Windows mixed reality
  18666. */
  18667. WINDOWS = 2,
  18668. /**
  18669. * Samsung gear VR
  18670. */
  18671. GEAR_VR = 3,
  18672. /**
  18673. * Google Daydream
  18674. */
  18675. DAYDREAM = 4,
  18676. /**
  18677. * Generic
  18678. */
  18679. GENERIC = 5
  18680. }
  18681. /**
  18682. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18683. */
  18684. export interface MutableGamepadButton {
  18685. /**
  18686. * Value of the button/trigger
  18687. */
  18688. value: number;
  18689. /**
  18690. * If the button/trigger is currently touched
  18691. */
  18692. touched: boolean;
  18693. /**
  18694. * If the button/trigger is currently pressed
  18695. */
  18696. pressed: boolean;
  18697. }
  18698. /**
  18699. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18700. * @hidden
  18701. */
  18702. export interface ExtendedGamepadButton extends GamepadButton {
  18703. /**
  18704. * If the button/trigger is currently pressed
  18705. */
  18706. readonly pressed: boolean;
  18707. /**
  18708. * If the button/trigger is currently touched
  18709. */
  18710. readonly touched: boolean;
  18711. /**
  18712. * Value of the button/trigger
  18713. */
  18714. readonly value: number;
  18715. }
  18716. /** @hidden */
  18717. export interface _GamePadFactory {
  18718. /**
  18719. * Returns whether or not the current gamepad can be created for this type of controller.
  18720. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18721. * @returns true if it can be created, otherwise false
  18722. */
  18723. canCreate(gamepadInfo: any): boolean;
  18724. /**
  18725. * Creates a new instance of the Gamepad.
  18726. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18727. * @returns the new gamepad instance
  18728. */
  18729. create(gamepadInfo: any): Gamepad;
  18730. }
  18731. /**
  18732. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18733. */
  18734. export class PoseEnabledControllerHelper {
  18735. /** @hidden */
  18736. static _ControllerFactories: _GamePadFactory[];
  18737. /** @hidden */
  18738. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18739. /**
  18740. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18741. * @param vrGamepad the gamepad to initialized
  18742. * @returns a vr controller of the type the gamepad identified as
  18743. */
  18744. static InitiateController(vrGamepad: any): Gamepad;
  18745. }
  18746. /**
  18747. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18748. */
  18749. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18750. /**
  18751. * If the controller is used in a webXR session
  18752. */
  18753. isXR: boolean;
  18754. private _deviceRoomPosition;
  18755. private _deviceRoomRotationQuaternion;
  18756. /**
  18757. * The device position in babylon space
  18758. */
  18759. devicePosition: Vector3;
  18760. /**
  18761. * The device rotation in babylon space
  18762. */
  18763. deviceRotationQuaternion: Quaternion;
  18764. /**
  18765. * The scale factor of the device in babylon space
  18766. */
  18767. deviceScaleFactor: number;
  18768. /**
  18769. * (Likely devicePosition should be used instead) The device position in its room space
  18770. */
  18771. position: Vector3;
  18772. /**
  18773. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18774. */
  18775. rotationQuaternion: Quaternion;
  18776. /**
  18777. * The type of controller (Eg. Windows mixed reality)
  18778. */
  18779. controllerType: PoseEnabledControllerType;
  18780. protected _calculatedPosition: Vector3;
  18781. private _calculatedRotation;
  18782. /**
  18783. * The raw pose from the device
  18784. */
  18785. rawPose: DevicePose;
  18786. private _trackPosition;
  18787. private _maxRotationDistFromHeadset;
  18788. private _draggedRoomRotation;
  18789. /**
  18790. * @hidden
  18791. */
  18792. _disableTrackPosition(fixedPosition: Vector3): void;
  18793. /**
  18794. * Internal, the mesh attached to the controller
  18795. * @hidden
  18796. */
  18797. _mesh: Nullable<AbstractMesh>;
  18798. private _poseControlledCamera;
  18799. private _leftHandSystemQuaternion;
  18800. /**
  18801. * Internal, matrix used to convert room space to babylon space
  18802. * @hidden
  18803. */
  18804. _deviceToWorld: Matrix;
  18805. /**
  18806. * Node to be used when casting a ray from the controller
  18807. * @hidden
  18808. */
  18809. _pointingPoseNode: Nullable<TransformNode>;
  18810. /**
  18811. * Name of the child mesh that can be used to cast a ray from the controller
  18812. */
  18813. static readonly POINTING_POSE: string;
  18814. /**
  18815. * Creates a new PoseEnabledController from a gamepad
  18816. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18817. */
  18818. constructor(browserGamepad: any);
  18819. private _workingMatrix;
  18820. /**
  18821. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18822. */
  18823. update(): void;
  18824. /**
  18825. * Updates only the pose device and mesh without doing any button event checking
  18826. */
  18827. protected _updatePoseAndMesh(): void;
  18828. /**
  18829. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18830. * @param poseData raw pose fromthe device
  18831. */
  18832. updateFromDevice(poseData: DevicePose): void;
  18833. /**
  18834. * @hidden
  18835. */
  18836. _meshAttachedObservable: Observable<AbstractMesh>;
  18837. /**
  18838. * Attaches a mesh to the controller
  18839. * @param mesh the mesh to be attached
  18840. */
  18841. attachToMesh(mesh: AbstractMesh): void;
  18842. /**
  18843. * Attaches the controllers mesh to a camera
  18844. * @param camera the camera the mesh should be attached to
  18845. */
  18846. attachToPoseControlledCamera(camera: TargetCamera): void;
  18847. /**
  18848. * Disposes of the controller
  18849. */
  18850. dispose(): void;
  18851. /**
  18852. * The mesh that is attached to the controller
  18853. */
  18854. get mesh(): Nullable<AbstractMesh>;
  18855. /**
  18856. * Gets the ray of the controller in the direction the controller is pointing
  18857. * @param length the length the resulting ray should be
  18858. * @returns a ray in the direction the controller is pointing
  18859. */
  18860. getForwardRay(length?: number): Ray;
  18861. }
  18862. }
  18863. declare module BABYLON {
  18864. /**
  18865. * Defines the WebVRController object that represents controllers tracked in 3D space
  18866. */
  18867. export abstract class WebVRController extends PoseEnabledController {
  18868. /**
  18869. * Internal, the default controller model for the controller
  18870. */
  18871. protected _defaultModel: Nullable<AbstractMesh>;
  18872. /**
  18873. * Fired when the trigger state has changed
  18874. */
  18875. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18876. /**
  18877. * Fired when the main button state has changed
  18878. */
  18879. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18880. /**
  18881. * Fired when the secondary button state has changed
  18882. */
  18883. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18884. /**
  18885. * Fired when the pad state has changed
  18886. */
  18887. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18888. /**
  18889. * Fired when controllers stick values have changed
  18890. */
  18891. onPadValuesChangedObservable: Observable<StickValues>;
  18892. /**
  18893. * Array of button availible on the controller
  18894. */
  18895. protected _buttons: Array<MutableGamepadButton>;
  18896. private _onButtonStateChange;
  18897. /**
  18898. * Fired when a controller button's state has changed
  18899. * @param callback the callback containing the button that was modified
  18900. */
  18901. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18902. /**
  18903. * X and Y axis corresponding to the controllers joystick
  18904. */
  18905. pad: StickValues;
  18906. /**
  18907. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18908. */
  18909. hand: string;
  18910. /**
  18911. * The default controller model for the controller
  18912. */
  18913. get defaultModel(): Nullable<AbstractMesh>;
  18914. /**
  18915. * Creates a new WebVRController from a gamepad
  18916. * @param vrGamepad the gamepad that the WebVRController should be created from
  18917. */
  18918. constructor(vrGamepad: any);
  18919. /**
  18920. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18921. */
  18922. update(): void;
  18923. /**
  18924. * Function to be called when a button is modified
  18925. */
  18926. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18927. /**
  18928. * Loads a mesh and attaches it to the controller
  18929. * @param scene the scene the mesh should be added to
  18930. * @param meshLoaded callback for when the mesh has been loaded
  18931. */
  18932. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18933. private _setButtonValue;
  18934. private _changes;
  18935. private _checkChanges;
  18936. /**
  18937. * Disposes of th webVRCOntroller
  18938. */
  18939. dispose(): void;
  18940. }
  18941. }
  18942. declare module BABYLON {
  18943. /**
  18944. * The HemisphericLight simulates the ambient environment light,
  18945. * so the passed direction is the light reflection direction, not the incoming direction.
  18946. */
  18947. export class HemisphericLight extends Light {
  18948. /**
  18949. * The groundColor is the light in the opposite direction to the one specified during creation.
  18950. * 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.
  18951. */
  18952. groundColor: Color3;
  18953. /**
  18954. * The light reflection direction, not the incoming direction.
  18955. */
  18956. direction: Vector3;
  18957. /**
  18958. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18959. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18960. * The HemisphericLight can't cast shadows.
  18961. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18962. * @param name The friendly name of the light
  18963. * @param direction The direction of the light reflection
  18964. * @param scene The scene the light belongs to
  18965. */
  18966. constructor(name: string, direction: Vector3, scene: Scene);
  18967. protected _buildUniformLayout(): void;
  18968. /**
  18969. * Returns the string "HemisphericLight".
  18970. * @return The class name
  18971. */
  18972. getClassName(): string;
  18973. /**
  18974. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18975. * Returns the updated direction.
  18976. * @param target The target the direction should point to
  18977. * @return The computed direction
  18978. */
  18979. setDirectionToTarget(target: Vector3): Vector3;
  18980. /**
  18981. * Returns the shadow generator associated to the light.
  18982. * @returns Always null for hemispheric lights because it does not support shadows.
  18983. */
  18984. getShadowGenerator(): Nullable<IShadowGenerator>;
  18985. /**
  18986. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18987. * @param effect The effect to update
  18988. * @param lightIndex The index of the light in the effect to update
  18989. * @returns The hemispheric light
  18990. */
  18991. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18992. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18993. /**
  18994. * Computes the world matrix of the node
  18995. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18996. * @param useWasUpdatedFlag defines a reserved property
  18997. * @returns the world matrix
  18998. */
  18999. computeWorldMatrix(): Matrix;
  19000. /**
  19001. * Returns the integer 3.
  19002. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19003. */
  19004. getTypeID(): number;
  19005. /**
  19006. * Prepares the list of defines specific to the light type.
  19007. * @param defines the list of defines
  19008. * @param lightIndex defines the index of the light for the effect
  19009. */
  19010. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19011. }
  19012. }
  19013. declare module BABYLON {
  19014. /** @hidden */
  19015. export var vrMultiviewToSingleviewPixelShader: {
  19016. name: string;
  19017. shader: string;
  19018. };
  19019. }
  19020. declare module BABYLON {
  19021. /**
  19022. * Renders to multiple views with a single draw call
  19023. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19024. */
  19025. export class MultiviewRenderTarget extends RenderTargetTexture {
  19026. /**
  19027. * Creates a multiview render target
  19028. * @param scene scene used with the render target
  19029. * @param size the size of the render target (used for each view)
  19030. */
  19031. constructor(scene: Scene, size?: number | {
  19032. width: number;
  19033. height: number;
  19034. } | {
  19035. ratio: number;
  19036. });
  19037. /**
  19038. * @hidden
  19039. * @param faceIndex the face index, if its a cube texture
  19040. */
  19041. _bindFrameBuffer(faceIndex?: number): void;
  19042. /**
  19043. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19044. * @returns the view count
  19045. */
  19046. getViewCount(): number;
  19047. }
  19048. }
  19049. declare module BABYLON {
  19050. /**
  19051. * Represents a camera frustum
  19052. */
  19053. export class Frustum {
  19054. /**
  19055. * Gets the planes representing the frustum
  19056. * @param transform matrix to be applied to the returned planes
  19057. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19058. */
  19059. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19060. /**
  19061. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Gets the left frustum plane transformed by the transform matrix
  19074. * @param transform transformation matrix to be applied to the resulting frustum plane
  19075. * @param frustumPlane the resuling frustum plane
  19076. */
  19077. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19078. /**
  19079. * Gets the right frustum plane transformed by the transform matrix
  19080. * @param transform transformation matrix to be applied to the resulting frustum plane
  19081. * @param frustumPlane the resuling frustum plane
  19082. */
  19083. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19084. /**
  19085. * Gets the top frustum plane transformed by the transform matrix
  19086. * @param transform transformation matrix to be applied to the resulting frustum plane
  19087. * @param frustumPlane the resuling frustum plane
  19088. */
  19089. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19090. /**
  19091. * Gets the bottom frustum plane transformed by the transform matrix
  19092. * @param transform transformation matrix to be applied to the resulting frustum plane
  19093. * @param frustumPlane the resuling frustum plane
  19094. */
  19095. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19096. /**
  19097. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19098. * @param transform transformation matrix to be applied to the resulting frustum planes
  19099. * @param frustumPlanes the resuling frustum planes
  19100. */
  19101. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. interface Engine {
  19106. /**
  19107. * Creates a new multiview render target
  19108. * @param width defines the width of the texture
  19109. * @param height defines the height of the texture
  19110. * @returns the created multiview texture
  19111. */
  19112. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19113. /**
  19114. * Binds a multiview framebuffer to be drawn to
  19115. * @param multiviewTexture texture to bind
  19116. */
  19117. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19118. }
  19119. interface Camera {
  19120. /**
  19121. * @hidden
  19122. * 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)
  19123. */
  19124. _useMultiviewToSingleView: boolean;
  19125. /**
  19126. * @hidden
  19127. * 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)
  19128. */
  19129. _multiviewTexture: Nullable<RenderTargetTexture>;
  19130. /**
  19131. * @hidden
  19132. * ensures the multiview texture of the camera exists and has the specified width/height
  19133. * @param width height to set on the multiview texture
  19134. * @param height width to set on the multiview texture
  19135. */
  19136. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19137. }
  19138. interface Scene {
  19139. /** @hidden */
  19140. _transformMatrixR: Matrix;
  19141. /** @hidden */
  19142. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19143. /** @hidden */
  19144. _createMultiviewUbo(): void;
  19145. /** @hidden */
  19146. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19147. /** @hidden */
  19148. _renderMultiviewToSingleView(camera: Camera): void;
  19149. }
  19150. }
  19151. declare module BABYLON {
  19152. /**
  19153. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19154. * This will not be used for webXR as it supports displaying texture arrays directly
  19155. */
  19156. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19157. /**
  19158. * Initializes a VRMultiviewToSingleview
  19159. * @param name name of the post process
  19160. * @param camera camera to be applied to
  19161. * @param scaleFactor scaling factor to the size of the output texture
  19162. */
  19163. constructor(name: string, camera: Camera, scaleFactor: number);
  19164. }
  19165. }
  19166. declare module BABYLON {
  19167. /**
  19168. * Interface used to define additional presentation attributes
  19169. */
  19170. export interface IVRPresentationAttributes {
  19171. /**
  19172. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19173. */
  19174. highRefreshRate: boolean;
  19175. /**
  19176. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19177. */
  19178. foveationLevel: number;
  19179. }
  19180. interface Engine {
  19181. /** @hidden */
  19182. _vrDisplay: any;
  19183. /** @hidden */
  19184. _vrSupported: boolean;
  19185. /** @hidden */
  19186. _oldSize: Size;
  19187. /** @hidden */
  19188. _oldHardwareScaleFactor: number;
  19189. /** @hidden */
  19190. _vrExclusivePointerMode: boolean;
  19191. /** @hidden */
  19192. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19193. /** @hidden */
  19194. _onVRDisplayPointerRestricted: () => void;
  19195. /** @hidden */
  19196. _onVRDisplayPointerUnrestricted: () => void;
  19197. /** @hidden */
  19198. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19199. /** @hidden */
  19200. _onVrDisplayDisconnect: Nullable<() => void>;
  19201. /** @hidden */
  19202. _onVrDisplayPresentChange: Nullable<() => void>;
  19203. /**
  19204. * Observable signaled when VR display mode changes
  19205. */
  19206. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19207. /**
  19208. * Observable signaled when VR request present is complete
  19209. */
  19210. onVRRequestPresentComplete: Observable<boolean>;
  19211. /**
  19212. * Observable signaled when VR request present starts
  19213. */
  19214. onVRRequestPresentStart: Observable<Engine>;
  19215. /**
  19216. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19217. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19218. */
  19219. isInVRExclusivePointerMode: boolean;
  19220. /**
  19221. * Gets a boolean indicating if a webVR device was detected
  19222. * @returns true if a webVR device was detected
  19223. */
  19224. isVRDevicePresent(): boolean;
  19225. /**
  19226. * Gets the current webVR device
  19227. * @returns the current webVR device (or null)
  19228. */
  19229. getVRDevice(): any;
  19230. /**
  19231. * Initializes a webVR display and starts listening to display change events
  19232. * The onVRDisplayChangedObservable will be notified upon these changes
  19233. * @returns A promise containing a VRDisplay and if vr is supported
  19234. */
  19235. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19236. /** @hidden */
  19237. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19238. /**
  19239. * Gets or sets the presentation attributes used to configure VR rendering
  19240. */
  19241. vrPresentationAttributes?: IVRPresentationAttributes;
  19242. /**
  19243. * Call this function to switch to webVR mode
  19244. * Will do nothing if webVR is not supported or if there is no webVR device
  19245. * @param options the webvr options provided to the camera. mainly used for multiview
  19246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19247. */
  19248. enableVR(options: WebVROptions): void;
  19249. /** @hidden */
  19250. _onVRFullScreenTriggered(): void;
  19251. }
  19252. }
  19253. declare module BABYLON {
  19254. /**
  19255. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19256. * IMPORTANT!! The data is right-hand data.
  19257. * @export
  19258. * @interface DevicePose
  19259. */
  19260. export interface DevicePose {
  19261. /**
  19262. * The position of the device, values in array are [x,y,z].
  19263. */
  19264. readonly position: Nullable<Float32Array>;
  19265. /**
  19266. * The linearVelocity of the device, values in array are [x,y,z].
  19267. */
  19268. readonly linearVelocity: Nullable<Float32Array>;
  19269. /**
  19270. * The linearAcceleration of the device, values in array are [x,y,z].
  19271. */
  19272. readonly linearAcceleration: Nullable<Float32Array>;
  19273. /**
  19274. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19275. */
  19276. readonly orientation: Nullable<Float32Array>;
  19277. /**
  19278. * The angularVelocity of the device, values in array are [x,y,z].
  19279. */
  19280. readonly angularVelocity: Nullable<Float32Array>;
  19281. /**
  19282. * The angularAcceleration of the device, values in array are [x,y,z].
  19283. */
  19284. readonly angularAcceleration: Nullable<Float32Array>;
  19285. }
  19286. /**
  19287. * Interface representing a pose controlled object in Babylon.
  19288. * A pose controlled object has both regular pose values as well as pose values
  19289. * from an external device such as a VR head mounted display
  19290. */
  19291. export interface PoseControlled {
  19292. /**
  19293. * The position of the object in babylon space.
  19294. */
  19295. position: Vector3;
  19296. /**
  19297. * The rotation quaternion of the object in babylon space.
  19298. */
  19299. rotationQuaternion: Quaternion;
  19300. /**
  19301. * The position of the device in babylon space.
  19302. */
  19303. devicePosition?: Vector3;
  19304. /**
  19305. * The rotation quaternion of the device in babylon space.
  19306. */
  19307. deviceRotationQuaternion: Quaternion;
  19308. /**
  19309. * The raw pose coming from the device.
  19310. */
  19311. rawPose: Nullable<DevicePose>;
  19312. /**
  19313. * The scale of the device to be used when translating from device space to babylon space.
  19314. */
  19315. deviceScaleFactor: number;
  19316. /**
  19317. * Updates the poseControlled values based on the input device pose.
  19318. * @param poseData the pose data to update the object with
  19319. */
  19320. updateFromDevice(poseData: DevicePose): void;
  19321. }
  19322. /**
  19323. * Set of options to customize the webVRCamera
  19324. */
  19325. export interface WebVROptions {
  19326. /**
  19327. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19328. */
  19329. trackPosition?: boolean;
  19330. /**
  19331. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19332. */
  19333. positionScale?: number;
  19334. /**
  19335. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19336. */
  19337. displayName?: string;
  19338. /**
  19339. * Should the native controller meshes be initialized. (default: true)
  19340. */
  19341. controllerMeshes?: boolean;
  19342. /**
  19343. * Creating a default HemiLight only on controllers. (default: true)
  19344. */
  19345. defaultLightingOnControllers?: boolean;
  19346. /**
  19347. * If you don't want to use the default VR button of the helper. (default: false)
  19348. */
  19349. useCustomVRButton?: boolean;
  19350. /**
  19351. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19352. */
  19353. customVRButton?: HTMLButtonElement;
  19354. /**
  19355. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19356. */
  19357. rayLength?: number;
  19358. /**
  19359. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19360. */
  19361. defaultHeight?: number;
  19362. /**
  19363. * If multiview should be used if availible (default: false)
  19364. */
  19365. useMultiview?: boolean;
  19366. }
  19367. /**
  19368. * This represents a WebVR camera.
  19369. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19370. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19371. */
  19372. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19373. private webVROptions;
  19374. /**
  19375. * @hidden
  19376. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19377. */
  19378. _vrDevice: any;
  19379. /**
  19380. * The rawPose of the vrDevice.
  19381. */
  19382. rawPose: Nullable<DevicePose>;
  19383. private _onVREnabled;
  19384. private _specsVersion;
  19385. private _attached;
  19386. private _frameData;
  19387. protected _descendants: Array<Node>;
  19388. private _deviceRoomPosition;
  19389. /** @hidden */
  19390. _deviceRoomRotationQuaternion: Quaternion;
  19391. private _standingMatrix;
  19392. /**
  19393. * Represents device position in babylon space.
  19394. */
  19395. devicePosition: Vector3;
  19396. /**
  19397. * Represents device rotation in babylon space.
  19398. */
  19399. deviceRotationQuaternion: Quaternion;
  19400. /**
  19401. * The scale of the device to be used when translating from device space to babylon space.
  19402. */
  19403. deviceScaleFactor: number;
  19404. private _deviceToWorld;
  19405. private _worldToDevice;
  19406. /**
  19407. * References to the webVR controllers for the vrDevice.
  19408. */
  19409. controllers: Array<WebVRController>;
  19410. /**
  19411. * Emits an event when a controller is attached.
  19412. */
  19413. onControllersAttachedObservable: Observable<WebVRController[]>;
  19414. /**
  19415. * Emits an event when a controller's mesh has been loaded;
  19416. */
  19417. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19418. /**
  19419. * Emits an event when the HMD's pose has been updated.
  19420. */
  19421. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19422. private _poseSet;
  19423. /**
  19424. * If the rig cameras be used as parent instead of this camera.
  19425. */
  19426. rigParenting: boolean;
  19427. private _lightOnControllers;
  19428. private _defaultHeight?;
  19429. /**
  19430. * Instantiates a WebVRFreeCamera.
  19431. * @param name The name of the WebVRFreeCamera
  19432. * @param position The starting anchor position for the camera
  19433. * @param scene The scene the camera belongs to
  19434. * @param webVROptions a set of customizable options for the webVRCamera
  19435. */
  19436. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19437. /**
  19438. * Gets the device distance from the ground in meters.
  19439. * @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.
  19440. */
  19441. deviceDistanceToRoomGround(): number;
  19442. /**
  19443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19444. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19445. */
  19446. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19447. /**
  19448. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19449. * @returns A promise with a boolean set to if the standing matrix is supported.
  19450. */
  19451. useStandingMatrixAsync(): Promise<boolean>;
  19452. /**
  19453. * Disposes the camera
  19454. */
  19455. dispose(): void;
  19456. /**
  19457. * Gets a vrController by name.
  19458. * @param name The name of the controller to retreive
  19459. * @returns the controller matching the name specified or null if not found
  19460. */
  19461. getControllerByName(name: string): Nullable<WebVRController>;
  19462. private _leftController;
  19463. /**
  19464. * The controller corresponding to the users left hand.
  19465. */
  19466. get leftController(): Nullable<WebVRController>;
  19467. private _rightController;
  19468. /**
  19469. * The controller corresponding to the users right hand.
  19470. */
  19471. get rightController(): Nullable<WebVRController>;
  19472. /**
  19473. * Casts a ray forward from the vrCamera's gaze.
  19474. * @param length Length of the ray (default: 100)
  19475. * @returns the ray corresponding to the gaze
  19476. */
  19477. getForwardRay(length?: number): Ray;
  19478. /**
  19479. * @hidden
  19480. * Updates the camera based on device's frame data
  19481. */
  19482. _checkInputs(): void;
  19483. /**
  19484. * Updates the poseControlled values based on the input device pose.
  19485. * @param poseData Pose coming from the device
  19486. */
  19487. updateFromDevice(poseData: DevicePose): void;
  19488. private _htmlElementAttached;
  19489. private _detachIfAttached;
  19490. /**
  19491. * WebVR's attach control will start broadcasting frames to the device.
  19492. * Note that in certain browsers (chrome for example) this function must be called
  19493. * within a user-interaction callback. Example:
  19494. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19495. *
  19496. * @param element html element to attach the vrDevice to
  19497. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19498. */
  19499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19500. /**
  19501. * Detaches the camera from the html element and disables VR
  19502. *
  19503. * @param element html element to detach from
  19504. */
  19505. detachControl(element: HTMLElement): void;
  19506. /**
  19507. * @returns the name of this class
  19508. */
  19509. getClassName(): string;
  19510. /**
  19511. * Calls resetPose on the vrDisplay
  19512. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19513. */
  19514. resetToCurrentRotation(): void;
  19515. /**
  19516. * @hidden
  19517. * Updates the rig cameras (left and right eye)
  19518. */
  19519. _updateRigCameras(): void;
  19520. private _workingVector;
  19521. private _oneVector;
  19522. private _workingMatrix;
  19523. private updateCacheCalled;
  19524. private _correctPositionIfNotTrackPosition;
  19525. /**
  19526. * @hidden
  19527. * Updates the cached values of the camera
  19528. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19529. */
  19530. _updateCache(ignoreParentClass?: boolean): void;
  19531. /**
  19532. * @hidden
  19533. * Get current device position in babylon world
  19534. */
  19535. _computeDevicePosition(): void;
  19536. /**
  19537. * Updates the current device position and rotation in the babylon world
  19538. */
  19539. update(): void;
  19540. /**
  19541. * @hidden
  19542. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19543. * @returns an identity matrix
  19544. */
  19545. _getViewMatrix(): Matrix;
  19546. private _tmpMatrix;
  19547. /**
  19548. * This function is called by the two RIG cameras.
  19549. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19550. * @hidden
  19551. */
  19552. _getWebVRViewMatrix(): Matrix;
  19553. /** @hidden */
  19554. _getWebVRProjectionMatrix(): Matrix;
  19555. private _onGamepadConnectedObserver;
  19556. private _onGamepadDisconnectedObserver;
  19557. private _updateCacheWhenTrackingDisabledObserver;
  19558. /**
  19559. * Initializes the controllers and their meshes
  19560. */
  19561. initControllers(): void;
  19562. }
  19563. }
  19564. declare module BABYLON {
  19565. /**
  19566. * Size options for a post process
  19567. */
  19568. export type PostProcessOptions = {
  19569. width: number;
  19570. height: number;
  19571. };
  19572. /**
  19573. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19574. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19575. */
  19576. export class PostProcess {
  19577. /** Name of the PostProcess. */
  19578. name: string;
  19579. /**
  19580. * Gets or sets the unique id of the post process
  19581. */
  19582. uniqueId: number;
  19583. /**
  19584. * Width of the texture to apply the post process on
  19585. */
  19586. width: number;
  19587. /**
  19588. * Height of the texture to apply the post process on
  19589. */
  19590. height: number;
  19591. /**
  19592. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19593. * @hidden
  19594. */
  19595. _outputTexture: Nullable<InternalTexture>;
  19596. /**
  19597. * Sampling mode used by the shader
  19598. * See https://doc.babylonjs.com/classes/3.1/texture
  19599. */
  19600. renderTargetSamplingMode: number;
  19601. /**
  19602. * Clear color to use when screen clearing
  19603. */
  19604. clearColor: Color4;
  19605. /**
  19606. * If the buffer needs to be cleared before applying the post process. (default: true)
  19607. * Should be set to false if shader will overwrite all previous pixels.
  19608. */
  19609. autoClear: boolean;
  19610. /**
  19611. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19612. */
  19613. alphaMode: number;
  19614. /**
  19615. * Sets the setAlphaBlendConstants of the babylon engine
  19616. */
  19617. alphaConstants: Color4;
  19618. /**
  19619. * Animations to be used for the post processing
  19620. */
  19621. animations: Animation[];
  19622. /**
  19623. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19624. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19625. */
  19626. enablePixelPerfectMode: boolean;
  19627. /**
  19628. * Force the postprocess to be applied without taking in account viewport
  19629. */
  19630. forceFullscreenViewport: boolean;
  19631. /**
  19632. * List of inspectable custom properties (used by the Inspector)
  19633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19634. */
  19635. inspectableCustomProperties: IInspectable[];
  19636. /**
  19637. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19638. *
  19639. * | Value | Type | Description |
  19640. * | ----- | ----------------------------------- | ----------- |
  19641. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19642. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19643. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19644. *
  19645. */
  19646. scaleMode: number;
  19647. /**
  19648. * Force textures to be a power of two (default: false)
  19649. */
  19650. alwaysForcePOT: boolean;
  19651. private _samples;
  19652. /**
  19653. * Number of sample textures (default: 1)
  19654. */
  19655. get samples(): number;
  19656. set samples(n: number);
  19657. /**
  19658. * Modify the scale of the post process to be the same as the viewport (default: false)
  19659. */
  19660. adaptScaleToCurrentViewport: boolean;
  19661. private _camera;
  19662. private _scene;
  19663. private _engine;
  19664. private _options;
  19665. private _reusable;
  19666. private _textureType;
  19667. private _textureFormat;
  19668. /**
  19669. * Smart array of input and output textures for the post process.
  19670. * @hidden
  19671. */
  19672. _textures: SmartArray<InternalTexture>;
  19673. /**
  19674. * The index in _textures that corresponds to the output texture.
  19675. * @hidden
  19676. */
  19677. _currentRenderTextureInd: number;
  19678. private _effect;
  19679. private _samplers;
  19680. private _fragmentUrl;
  19681. private _vertexUrl;
  19682. private _parameters;
  19683. private _scaleRatio;
  19684. protected _indexParameters: any;
  19685. private _shareOutputWithPostProcess;
  19686. private _texelSize;
  19687. private _forcedOutputTexture;
  19688. /**
  19689. * Returns the fragment url or shader name used in the post process.
  19690. * @returns the fragment url or name in the shader store.
  19691. */
  19692. getEffectName(): string;
  19693. /**
  19694. * An event triggered when the postprocess is activated.
  19695. */
  19696. onActivateObservable: Observable<Camera>;
  19697. private _onActivateObserver;
  19698. /**
  19699. * A function that is added to the onActivateObservable
  19700. */
  19701. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19702. /**
  19703. * An event triggered when the postprocess changes its size.
  19704. */
  19705. onSizeChangedObservable: Observable<PostProcess>;
  19706. private _onSizeChangedObserver;
  19707. /**
  19708. * A function that is added to the onSizeChangedObservable
  19709. */
  19710. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19711. /**
  19712. * An event triggered when the postprocess applies its effect.
  19713. */
  19714. onApplyObservable: Observable<Effect>;
  19715. private _onApplyObserver;
  19716. /**
  19717. * A function that is added to the onApplyObservable
  19718. */
  19719. set onApply(callback: (effect: Effect) => void);
  19720. /**
  19721. * An event triggered before rendering the postprocess
  19722. */
  19723. onBeforeRenderObservable: Observable<Effect>;
  19724. private _onBeforeRenderObserver;
  19725. /**
  19726. * A function that is added to the onBeforeRenderObservable
  19727. */
  19728. set onBeforeRender(callback: (effect: Effect) => void);
  19729. /**
  19730. * An event triggered after rendering the postprocess
  19731. */
  19732. onAfterRenderObservable: Observable<Effect>;
  19733. private _onAfterRenderObserver;
  19734. /**
  19735. * A function that is added to the onAfterRenderObservable
  19736. */
  19737. set onAfterRender(callback: (efect: Effect) => void);
  19738. /**
  19739. * 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
  19740. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19741. */
  19742. get inputTexture(): InternalTexture;
  19743. set inputTexture(value: InternalTexture);
  19744. /**
  19745. * Gets the camera which post process is applied to.
  19746. * @returns The camera the post process is applied to.
  19747. */
  19748. getCamera(): Camera;
  19749. /**
  19750. * Gets the texel size of the postprocess.
  19751. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19752. */
  19753. get texelSize(): Vector2;
  19754. /**
  19755. * Creates a new instance PostProcess
  19756. * @param name The name of the PostProcess.
  19757. * @param fragmentUrl The url of the fragment shader to be used.
  19758. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19759. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19760. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19761. * @param camera The camera to apply the render pass to.
  19762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19763. * @param engine The engine which the post process will be applied. (default: current engine)
  19764. * @param reusable If the post process can be reused on the same frame. (default: false)
  19765. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19766. * @param textureType Type of textures used when performing the post process. (default: 0)
  19767. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19768. * @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
  19769. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19770. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19771. */
  19772. constructor(
  19773. /** Name of the PostProcess. */
  19774. 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);
  19775. /**
  19776. * Gets a string idenfifying the name of the class
  19777. * @returns "PostProcess" string
  19778. */
  19779. getClassName(): string;
  19780. /**
  19781. * Gets the engine which this post process belongs to.
  19782. * @returns The engine the post process was enabled with.
  19783. */
  19784. getEngine(): Engine;
  19785. /**
  19786. * The effect that is created when initializing the post process.
  19787. * @returns The created effect corresponding the the postprocess.
  19788. */
  19789. getEffect(): Effect;
  19790. /**
  19791. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19792. * @param postProcess The post process to share the output with.
  19793. * @returns This post process.
  19794. */
  19795. shareOutputWith(postProcess: PostProcess): PostProcess;
  19796. /**
  19797. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19798. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19799. */
  19800. useOwnOutput(): void;
  19801. /**
  19802. * Updates the effect with the current post process compile time values and recompiles the shader.
  19803. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19804. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19805. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19806. * @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
  19807. * @param onCompiled Called when the shader has been compiled.
  19808. * @param onError Called if there is an error when compiling a shader.
  19809. */
  19810. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19811. /**
  19812. * The post process is reusable if it can be used multiple times within one frame.
  19813. * @returns If the post process is reusable
  19814. */
  19815. isReusable(): boolean;
  19816. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19817. markTextureDirty(): void;
  19818. /**
  19819. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19820. * 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.
  19821. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19822. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19823. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19824. * @returns The target texture that was bound to be written to.
  19825. */
  19826. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19827. /**
  19828. * If the post process is supported.
  19829. */
  19830. get isSupported(): boolean;
  19831. /**
  19832. * The aspect ratio of the output texture.
  19833. */
  19834. get aspectRatio(): number;
  19835. /**
  19836. * Get a value indicating if the post-process is ready to be used
  19837. * @returns true if the post-process is ready (shader is compiled)
  19838. */
  19839. isReady(): boolean;
  19840. /**
  19841. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19842. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19843. */
  19844. apply(): Nullable<Effect>;
  19845. private _disposeTextures;
  19846. /**
  19847. * Disposes the post process.
  19848. * @param camera The camera to dispose the post process on.
  19849. */
  19850. dispose(camera?: Camera): void;
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /** @hidden */
  19855. export var kernelBlurVaryingDeclaration: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module BABYLON {
  19861. /** @hidden */
  19862. export var kernelBlurFragment: {
  19863. name: string;
  19864. shader: string;
  19865. };
  19866. }
  19867. declare module BABYLON {
  19868. /** @hidden */
  19869. export var kernelBlurFragment2: {
  19870. name: string;
  19871. shader: string;
  19872. };
  19873. }
  19874. declare module BABYLON {
  19875. /** @hidden */
  19876. export var kernelBlurPixelShader: {
  19877. name: string;
  19878. shader: string;
  19879. };
  19880. }
  19881. declare module BABYLON {
  19882. /** @hidden */
  19883. export var kernelBlurVertex: {
  19884. name: string;
  19885. shader: string;
  19886. };
  19887. }
  19888. declare module BABYLON {
  19889. /** @hidden */
  19890. export var kernelBlurVertexShader: {
  19891. name: string;
  19892. shader: string;
  19893. };
  19894. }
  19895. declare module BABYLON {
  19896. /**
  19897. * The Blur Post Process which blurs an image based on a kernel and direction.
  19898. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19899. */
  19900. export class BlurPostProcess extends PostProcess {
  19901. /** The direction in which to blur the image. */
  19902. direction: Vector2;
  19903. private blockCompilation;
  19904. protected _kernel: number;
  19905. protected _idealKernel: number;
  19906. protected _packedFloat: boolean;
  19907. private _staticDefines;
  19908. /**
  19909. * Sets the length in pixels of the blur sample region
  19910. */
  19911. set kernel(v: number);
  19912. /**
  19913. * Gets the length in pixels of the blur sample region
  19914. */
  19915. get kernel(): number;
  19916. /**
  19917. * Sets wether or not the blur needs to unpack/repack floats
  19918. */
  19919. set packedFloat(v: boolean);
  19920. /**
  19921. * Gets wether or not the blur is unpacking/repacking floats
  19922. */
  19923. get packedFloat(): boolean;
  19924. /**
  19925. * Creates a new instance BlurPostProcess
  19926. * @param name The name of the effect.
  19927. * @param direction The direction in which to blur the image.
  19928. * @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.
  19929. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19930. * @param camera The camera to apply the render pass to.
  19931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19932. * @param engine The engine which the post process will be applied. (default: current engine)
  19933. * @param reusable If the post process can be reused on the same frame. (default: false)
  19934. * @param textureType Type of textures used when performing the post process. (default: 0)
  19935. * @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)
  19936. */
  19937. constructor(name: string,
  19938. /** The direction in which to blur the image. */
  19939. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19940. /**
  19941. * Updates the effect with the current post process compile time values and recompiles the shader.
  19942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19945. * @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
  19946. * @param onCompiled Called when the shader has been compiled.
  19947. * @param onError Called if there is an error when compiling a shader.
  19948. */
  19949. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19950. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19951. /**
  19952. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19953. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19954. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19955. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19956. * The gaps between physical kernels are compensated for in the weighting of the samples
  19957. * @param idealKernel Ideal blur kernel.
  19958. * @return Nearest best kernel.
  19959. */
  19960. protected _nearestBestKernel(idealKernel: number): number;
  19961. /**
  19962. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19963. * @param x The point on the Gaussian distribution to sample.
  19964. * @return the value of the Gaussian function at x.
  19965. */
  19966. protected _gaussianWeight(x: number): number;
  19967. /**
  19968. * Generates a string that can be used as a floating point number in GLSL.
  19969. * @param x Value to print.
  19970. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19971. * @return GLSL float string.
  19972. */
  19973. protected _glslFloat(x: number, decimalFigures?: number): string;
  19974. }
  19975. }
  19976. declare module BABYLON {
  19977. /**
  19978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19980. * You can then easily use it as a reflectionTexture on a flat surface.
  19981. * In case the surface is not a plane, please consider relying on reflection probes.
  19982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19983. */
  19984. export class MirrorTexture extends RenderTargetTexture {
  19985. private scene;
  19986. /**
  19987. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19988. * 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.
  19989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19990. */
  19991. mirrorPlane: Plane;
  19992. /**
  19993. * Define the blur ratio used to blur the reflection if needed.
  19994. */
  19995. set blurRatio(value: number);
  19996. get blurRatio(): number;
  19997. /**
  19998. * Define the adaptive blur kernel used to blur the reflection if needed.
  19999. * This will autocompute the closest best match for the `blurKernel`
  20000. */
  20001. set adaptiveBlurKernel(value: number);
  20002. /**
  20003. * Define the blur kernel used to blur the reflection if needed.
  20004. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20005. */
  20006. set blurKernel(value: number);
  20007. /**
  20008. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20009. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20010. */
  20011. set blurKernelX(value: number);
  20012. get blurKernelX(): number;
  20013. /**
  20014. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20015. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20016. */
  20017. set blurKernelY(value: number);
  20018. get blurKernelY(): number;
  20019. private _autoComputeBlurKernel;
  20020. protected _onRatioRescale(): void;
  20021. private _updateGammaSpace;
  20022. private _imageProcessingConfigChangeObserver;
  20023. private _transformMatrix;
  20024. private _mirrorMatrix;
  20025. private _savedViewMatrix;
  20026. private _blurX;
  20027. private _blurY;
  20028. private _adaptiveBlurKernel;
  20029. private _blurKernelX;
  20030. private _blurKernelY;
  20031. private _blurRatio;
  20032. /**
  20033. * Instantiates a Mirror Texture.
  20034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20036. * You can then easily use it as a reflectionTexture on a flat surface.
  20037. * In case the surface is not a plane, please consider relying on reflection probes.
  20038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20039. * @param name
  20040. * @param size
  20041. * @param scene
  20042. * @param generateMipMaps
  20043. * @param type
  20044. * @param samplingMode
  20045. * @param generateDepthBuffer
  20046. */
  20047. constructor(name: string, size: number | {
  20048. width: number;
  20049. height: number;
  20050. } | {
  20051. ratio: number;
  20052. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20053. private _preparePostProcesses;
  20054. /**
  20055. * Clone the mirror texture.
  20056. * @returns the cloned texture
  20057. */
  20058. clone(): MirrorTexture;
  20059. /**
  20060. * Serialize the texture to a JSON representation you could use in Parse later on
  20061. * @returns the serialized JSON representation
  20062. */
  20063. serialize(): any;
  20064. /**
  20065. * Dispose the texture and release its associated resources.
  20066. */
  20067. dispose(): void;
  20068. }
  20069. }
  20070. declare module BABYLON {
  20071. /**
  20072. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20073. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20074. */
  20075. export class Texture extends BaseTexture {
  20076. /**
  20077. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20078. */
  20079. static SerializeBuffers: boolean;
  20080. /** @hidden */
  20081. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20082. /** @hidden */
  20083. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20084. /** @hidden */
  20085. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20086. /** nearest is mag = nearest and min = nearest and mip = linear */
  20087. static readonly NEAREST_SAMPLINGMODE: number;
  20088. /** nearest is mag = nearest and min = nearest and mip = linear */
  20089. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20091. static readonly BILINEAR_SAMPLINGMODE: number;
  20092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20093. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20094. /** Trilinear is mag = linear and min = linear and mip = linear */
  20095. static readonly TRILINEAR_SAMPLINGMODE: number;
  20096. /** Trilinear is mag = linear and min = linear and mip = linear */
  20097. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20098. /** mag = nearest and min = nearest and mip = nearest */
  20099. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20100. /** mag = nearest and min = linear and mip = nearest */
  20101. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20102. /** mag = nearest and min = linear and mip = linear */
  20103. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20104. /** mag = nearest and min = linear and mip = none */
  20105. static readonly NEAREST_LINEAR: number;
  20106. /** mag = nearest and min = nearest and mip = none */
  20107. static readonly NEAREST_NEAREST: number;
  20108. /** mag = linear and min = nearest and mip = nearest */
  20109. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20110. /** mag = linear and min = nearest and mip = linear */
  20111. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20112. /** mag = linear and min = linear and mip = none */
  20113. static readonly LINEAR_LINEAR: number;
  20114. /** mag = linear and min = nearest and mip = none */
  20115. static readonly LINEAR_NEAREST: number;
  20116. /** Explicit coordinates mode */
  20117. static readonly EXPLICIT_MODE: number;
  20118. /** Spherical coordinates mode */
  20119. static readonly SPHERICAL_MODE: number;
  20120. /** Planar coordinates mode */
  20121. static readonly PLANAR_MODE: number;
  20122. /** Cubic coordinates mode */
  20123. static readonly CUBIC_MODE: number;
  20124. /** Projection coordinates mode */
  20125. static readonly PROJECTION_MODE: number;
  20126. /** Inverse Cubic coordinates mode */
  20127. static readonly SKYBOX_MODE: number;
  20128. /** Inverse Cubic coordinates mode */
  20129. static readonly INVCUBIC_MODE: number;
  20130. /** Equirectangular coordinates mode */
  20131. static readonly EQUIRECTANGULAR_MODE: number;
  20132. /** Equirectangular Fixed coordinates mode */
  20133. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20134. /** Equirectangular Fixed Mirrored coordinates mode */
  20135. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20136. /** Texture is not repeating outside of 0..1 UVs */
  20137. static readonly CLAMP_ADDRESSMODE: number;
  20138. /** Texture is repeating outside of 0..1 UVs */
  20139. static readonly WRAP_ADDRESSMODE: number;
  20140. /** Texture is repeating and mirrored */
  20141. static readonly MIRROR_ADDRESSMODE: number;
  20142. /**
  20143. * 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
  20144. */
  20145. static UseSerializedUrlIfAny: boolean;
  20146. /**
  20147. * Define the url of the texture.
  20148. */
  20149. url: Nullable<string>;
  20150. /**
  20151. * Define an offset on the texture to offset the u coordinates of the UVs
  20152. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20153. */
  20154. uOffset: number;
  20155. /**
  20156. * Define an offset on the texture to offset the v coordinates of the UVs
  20157. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20158. */
  20159. vOffset: number;
  20160. /**
  20161. * Define an offset on the texture to scale the u coordinates of the UVs
  20162. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20163. */
  20164. uScale: number;
  20165. /**
  20166. * Define an offset on the texture to scale the v coordinates of the UVs
  20167. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20168. */
  20169. vScale: number;
  20170. /**
  20171. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20172. * @see http://doc.babylonjs.com/how_to/more_materials
  20173. */
  20174. uAng: number;
  20175. /**
  20176. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20177. * @see http://doc.babylonjs.com/how_to/more_materials
  20178. */
  20179. vAng: number;
  20180. /**
  20181. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20182. * @see http://doc.babylonjs.com/how_to/more_materials
  20183. */
  20184. wAng: number;
  20185. /**
  20186. * Defines the center of rotation (U)
  20187. */
  20188. uRotationCenter: number;
  20189. /**
  20190. * Defines the center of rotation (V)
  20191. */
  20192. vRotationCenter: number;
  20193. /**
  20194. * Defines the center of rotation (W)
  20195. */
  20196. wRotationCenter: number;
  20197. /**
  20198. * Are mip maps generated for this texture or not.
  20199. */
  20200. get noMipmap(): boolean;
  20201. /**
  20202. * List of inspectable custom properties (used by the Inspector)
  20203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20204. */
  20205. inspectableCustomProperties: Nullable<IInspectable[]>;
  20206. private _noMipmap;
  20207. /** @hidden */
  20208. _invertY: boolean;
  20209. private _rowGenerationMatrix;
  20210. private _cachedTextureMatrix;
  20211. private _projectionModeMatrix;
  20212. private _t0;
  20213. private _t1;
  20214. private _t2;
  20215. private _cachedUOffset;
  20216. private _cachedVOffset;
  20217. private _cachedUScale;
  20218. private _cachedVScale;
  20219. private _cachedUAng;
  20220. private _cachedVAng;
  20221. private _cachedWAng;
  20222. private _cachedProjectionMatrixId;
  20223. private _cachedCoordinatesMode;
  20224. /** @hidden */
  20225. protected _initialSamplingMode: number;
  20226. /** @hidden */
  20227. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20228. private _deleteBuffer;
  20229. protected _format: Nullable<number>;
  20230. private _delayedOnLoad;
  20231. private _delayedOnError;
  20232. private _mimeType?;
  20233. /**
  20234. * Observable triggered once the texture has been loaded.
  20235. */
  20236. onLoadObservable: Observable<Texture>;
  20237. protected _isBlocking: boolean;
  20238. /**
  20239. * Is the texture preventing material to render while loading.
  20240. * If false, a default texture will be used instead of the loading one during the preparation step.
  20241. */
  20242. set isBlocking(value: boolean);
  20243. get isBlocking(): boolean;
  20244. /**
  20245. * Get the current sampling mode associated with the texture.
  20246. */
  20247. get samplingMode(): number;
  20248. /**
  20249. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20250. */
  20251. get invertY(): boolean;
  20252. /**
  20253. * Instantiates a new texture.
  20254. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20255. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20256. * @param url defines the url of the picture to load as a texture
  20257. * @param scene defines the scene or engine the texture will belong to
  20258. * @param noMipmap defines if the texture will require mip maps or not
  20259. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20260. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20261. * @param onLoad defines a callback triggered when the texture has been loaded
  20262. * @param onError defines a callback triggered when an error occurred during the loading session
  20263. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20264. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20265. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20266. * @param mimeType defines an optional mime type information
  20267. */
  20268. 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);
  20269. /**
  20270. * Update the url (and optional buffer) of this texture if url was null during construction.
  20271. * @param url the url of the texture
  20272. * @param buffer the buffer of the texture (defaults to null)
  20273. * @param onLoad callback called when the texture is loaded (defaults to null)
  20274. */
  20275. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20276. /**
  20277. * Finish the loading sequence of a texture flagged as delayed load.
  20278. * @hidden
  20279. */
  20280. delayLoad(): void;
  20281. private _prepareRowForTextureGeneration;
  20282. /**
  20283. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20284. * @returns the transform matrix of the texture.
  20285. */
  20286. getTextureMatrix(uBase?: number): Matrix;
  20287. /**
  20288. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20289. * @returns The reflection texture transform
  20290. */
  20291. getReflectionTextureMatrix(): Matrix;
  20292. /**
  20293. * Clones the texture.
  20294. * @returns the cloned texture
  20295. */
  20296. clone(): Texture;
  20297. /**
  20298. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20299. * @returns The JSON representation of the texture
  20300. */
  20301. serialize(): any;
  20302. /**
  20303. * Get the current class name of the texture useful for serialization or dynamic coding.
  20304. * @returns "Texture"
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Dispose the texture and release its associated resources.
  20309. */
  20310. dispose(): void;
  20311. /**
  20312. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20313. * @param parsedTexture Define the JSON representation of the texture
  20314. * @param scene Define the scene the parsed texture should be instantiated in
  20315. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20316. * @returns The parsed texture if successful
  20317. */
  20318. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20319. /**
  20320. * Creates a texture from its base 64 representation.
  20321. * @param data Define the base64 payload without the data: prefix
  20322. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20323. * @param scene Define the scene the texture should belong to
  20324. * @param noMipmap Forces the texture to not create mip map information if true
  20325. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20326. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20327. * @param onLoad define a callback triggered when the texture has been loaded
  20328. * @param onError define a callback triggered when an error occurred during the loading session
  20329. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20330. * @returns the created texture
  20331. */
  20332. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20333. /**
  20334. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20335. * @param data Define the base64 payload without the data: prefix
  20336. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20337. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20338. * @param scene Define the scene the texture should belong to
  20339. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20340. * @param noMipmap Forces the texture to not create mip map information if true
  20341. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20342. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20343. * @param onLoad define a callback triggered when the texture has been loaded
  20344. * @param onError define a callback triggered when an error occurred during the loading session
  20345. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20346. * @returns the created texture
  20347. */
  20348. 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;
  20349. }
  20350. }
  20351. declare module BABYLON {
  20352. /**
  20353. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20354. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20355. */
  20356. export class PostProcessManager {
  20357. private _scene;
  20358. private _indexBuffer;
  20359. private _vertexBuffers;
  20360. /**
  20361. * Creates a new instance PostProcess
  20362. * @param scene The scene that the post process is associated with.
  20363. */
  20364. constructor(scene: Scene);
  20365. private _prepareBuffers;
  20366. private _buildIndexBuffer;
  20367. /**
  20368. * Rebuilds the vertex buffers of the manager.
  20369. * @hidden
  20370. */
  20371. _rebuild(): void;
  20372. /**
  20373. * Prepares a frame to be run through a post process.
  20374. * @param sourceTexture The input texture to the post procesess. (default: null)
  20375. * @param postProcesses An array of post processes to be run. (default: null)
  20376. * @returns True if the post processes were able to be run.
  20377. * @hidden
  20378. */
  20379. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20380. /**
  20381. * Manually render a set of post processes to a texture.
  20382. * @param postProcesses An array of post processes to be run.
  20383. * @param targetTexture The target texture to render to.
  20384. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20385. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20386. * @param lodLevel defines which lod of the texture to render to
  20387. */
  20388. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20389. /**
  20390. * Finalize the result of the output of the postprocesses.
  20391. * @param doNotPresent If true the result will not be displayed to the screen.
  20392. * @param targetTexture The target texture to render to.
  20393. * @param faceIndex The index of the face to bind the target texture to.
  20394. * @param postProcesses The array of post processes to render.
  20395. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20396. * @hidden
  20397. */
  20398. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20399. /**
  20400. * Disposes of the post process manager.
  20401. */
  20402. dispose(): void;
  20403. }
  20404. }
  20405. declare module BABYLON {
  20406. /**
  20407. * This Helps creating a texture that will be created from a camera in your scene.
  20408. * It is basically a dynamic texture that could be used to create special effects for instance.
  20409. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20410. */
  20411. export class RenderTargetTexture extends Texture {
  20412. isCube: boolean;
  20413. /**
  20414. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20415. */
  20416. static readonly REFRESHRATE_RENDER_ONCE: number;
  20417. /**
  20418. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20419. */
  20420. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20421. /**
  20422. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20423. * the central point of your effect and can save a lot of performances.
  20424. */
  20425. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20426. /**
  20427. * Use this predicate to dynamically define the list of mesh you want to render.
  20428. * If set, the renderList property will be overwritten.
  20429. */
  20430. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20431. private _renderList;
  20432. /**
  20433. * Use this list to define the list of mesh you want to render.
  20434. */
  20435. get renderList(): Nullable<Array<AbstractMesh>>;
  20436. set renderList(value: Nullable<Array<AbstractMesh>>);
  20437. /**
  20438. * Use this function to overload the renderList array at rendering time.
  20439. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20440. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20441. * the cube (if the RTT is a cube, else layerOrFace=0).
  20442. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20443. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20444. * hold dummy elements!
  20445. */
  20446. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20447. private _hookArray;
  20448. /**
  20449. * Define if particles should be rendered in your texture.
  20450. */
  20451. renderParticles: boolean;
  20452. /**
  20453. * Define if sprites should be rendered in your texture.
  20454. */
  20455. renderSprites: boolean;
  20456. /**
  20457. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20458. */
  20459. coordinatesMode: number;
  20460. /**
  20461. * Define the camera used to render the texture.
  20462. */
  20463. activeCamera: Nullable<Camera>;
  20464. /**
  20465. * Override the render function of the texture with your own one.
  20466. */
  20467. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20468. /**
  20469. * Define if camera post processes should be use while rendering the texture.
  20470. */
  20471. useCameraPostProcesses: boolean;
  20472. /**
  20473. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20474. */
  20475. ignoreCameraViewport: boolean;
  20476. private _postProcessManager;
  20477. private _postProcesses;
  20478. private _resizeObserver;
  20479. /**
  20480. * An event triggered when the texture is unbind.
  20481. */
  20482. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20483. /**
  20484. * An event triggered when the texture is unbind.
  20485. */
  20486. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20487. private _onAfterUnbindObserver;
  20488. /**
  20489. * Set a after unbind callback in the texture.
  20490. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20491. */
  20492. set onAfterUnbind(callback: () => void);
  20493. /**
  20494. * An event triggered before rendering the texture
  20495. */
  20496. onBeforeRenderObservable: Observable<number>;
  20497. private _onBeforeRenderObserver;
  20498. /**
  20499. * Set a before render callback in the texture.
  20500. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20501. */
  20502. set onBeforeRender(callback: (faceIndex: number) => void);
  20503. /**
  20504. * An event triggered after rendering the texture
  20505. */
  20506. onAfterRenderObservable: Observable<number>;
  20507. private _onAfterRenderObserver;
  20508. /**
  20509. * Set a after render callback in the texture.
  20510. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20511. */
  20512. set onAfterRender(callback: (faceIndex: number) => void);
  20513. /**
  20514. * An event triggered after the texture clear
  20515. */
  20516. onClearObservable: Observable<Engine>;
  20517. private _onClearObserver;
  20518. /**
  20519. * Set a clear callback in the texture.
  20520. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20521. */
  20522. set onClear(callback: (Engine: Engine) => void);
  20523. /**
  20524. * An event triggered when the texture is resized.
  20525. */
  20526. onResizeObservable: Observable<RenderTargetTexture>;
  20527. /**
  20528. * Define the clear color of the Render Target if it should be different from the scene.
  20529. */
  20530. clearColor: Color4;
  20531. protected _size: number | {
  20532. width: number;
  20533. height: number;
  20534. layers?: number;
  20535. };
  20536. protected _initialSizeParameter: number | {
  20537. width: number;
  20538. height: number;
  20539. } | {
  20540. ratio: number;
  20541. };
  20542. protected _sizeRatio: Nullable<number>;
  20543. /** @hidden */
  20544. _generateMipMaps: boolean;
  20545. protected _renderingManager: RenderingManager;
  20546. /** @hidden */
  20547. _waitingRenderList: string[];
  20548. protected _doNotChangeAspectRatio: boolean;
  20549. protected _currentRefreshId: number;
  20550. protected _refreshRate: number;
  20551. protected _textureMatrix: Matrix;
  20552. protected _samples: number;
  20553. protected _renderTargetOptions: RenderTargetCreationOptions;
  20554. /**
  20555. * Gets render target creation options that were used.
  20556. */
  20557. get renderTargetOptions(): RenderTargetCreationOptions;
  20558. protected _engine: Engine;
  20559. protected _onRatioRescale(): void;
  20560. /**
  20561. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20562. * It must define where the camera used to render the texture is set
  20563. */
  20564. boundingBoxPosition: Vector3;
  20565. private _boundingBoxSize;
  20566. /**
  20567. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20568. * When defined, the cubemap will switch to local mode
  20569. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20570. * @example https://www.babylonjs-playground.com/#RNASML
  20571. */
  20572. set boundingBoxSize(value: Vector3);
  20573. get boundingBoxSize(): Vector3;
  20574. /**
  20575. * In case the RTT has been created with a depth texture, get the associated
  20576. * depth texture.
  20577. * Otherwise, return null.
  20578. */
  20579. get depthStencilTexture(): Nullable<InternalTexture>;
  20580. /**
  20581. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20582. * or used a shadow, depth texture...
  20583. * @param name The friendly name of the texture
  20584. * @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)
  20585. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20586. * @param generateMipMaps True if mip maps need to be generated after render.
  20587. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20588. * @param type The type of the buffer in the RTT (int, half float, float...)
  20589. * @param isCube True if a cube texture needs to be created
  20590. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20591. * @param generateDepthBuffer True to generate a depth buffer
  20592. * @param generateStencilBuffer True to generate a stencil buffer
  20593. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20594. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20596. */
  20597. constructor(name: string, size: number | {
  20598. width: number;
  20599. height: number;
  20600. layers?: number;
  20601. } | {
  20602. ratio: number;
  20603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20604. /**
  20605. * Creates a depth stencil texture.
  20606. * This is only available in WebGL 2 or with the depth texture extension available.
  20607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20610. */
  20611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20612. private _processSizeParameter;
  20613. /**
  20614. * Define the number of samples to use in case of MSAA.
  20615. * It defaults to one meaning no MSAA has been enabled.
  20616. */
  20617. get samples(): number;
  20618. set samples(value: number);
  20619. /**
  20620. * Resets the refresh counter of the texture and start bak from scratch.
  20621. * Could be useful to regenerate the texture if it is setup to render only once.
  20622. */
  20623. resetRefreshCounter(): void;
  20624. /**
  20625. * Define the refresh rate of the texture or the rendering frequency.
  20626. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20627. */
  20628. get refreshRate(): number;
  20629. set refreshRate(value: number);
  20630. /**
  20631. * Adds a post process to the render target rendering passes.
  20632. * @param postProcess define the post process to add
  20633. */
  20634. addPostProcess(postProcess: PostProcess): void;
  20635. /**
  20636. * Clear all the post processes attached to the render target
  20637. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20638. */
  20639. clearPostProcesses(dispose?: boolean): void;
  20640. /**
  20641. * Remove one of the post process from the list of attached post processes to the texture
  20642. * @param postProcess define the post process to remove from the list
  20643. */
  20644. removePostProcess(postProcess: PostProcess): void;
  20645. /** @hidden */
  20646. _shouldRender(): boolean;
  20647. /**
  20648. * Gets the actual render size of the texture.
  20649. * @returns the width of the render size
  20650. */
  20651. getRenderSize(): number;
  20652. /**
  20653. * Gets the actual render width of the texture.
  20654. * @returns the width of the render size
  20655. */
  20656. getRenderWidth(): number;
  20657. /**
  20658. * Gets the actual render height of the texture.
  20659. * @returns the height of the render size
  20660. */
  20661. getRenderHeight(): number;
  20662. /**
  20663. * Gets the actual number of layers of the texture.
  20664. * @returns the number of layers
  20665. */
  20666. getRenderLayers(): number;
  20667. /**
  20668. * Get if the texture can be rescaled or not.
  20669. */
  20670. get canRescale(): boolean;
  20671. /**
  20672. * Resize the texture using a ratio.
  20673. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20674. */
  20675. scale(ratio: number): void;
  20676. /**
  20677. * Get the texture reflection matrix used to rotate/transform the reflection.
  20678. * @returns the reflection matrix
  20679. */
  20680. getReflectionTextureMatrix(): Matrix;
  20681. /**
  20682. * Resize the texture to a new desired size.
  20683. * Be carrefull as it will recreate all the data in the new texture.
  20684. * @param size Define the new size. It can be:
  20685. * - a number for squared texture,
  20686. * - an object containing { width: number, height: number }
  20687. * - or an object containing a ratio { ratio: number }
  20688. */
  20689. resize(size: number | {
  20690. width: number;
  20691. height: number;
  20692. } | {
  20693. ratio: number;
  20694. }): void;
  20695. private _defaultRenderListPrepared;
  20696. /**
  20697. * Renders all the objects from the render list into the texture.
  20698. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20699. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20700. */
  20701. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20702. private _bestReflectionRenderTargetDimension;
  20703. private _prepareRenderingManager;
  20704. /**
  20705. * @hidden
  20706. * @param faceIndex face index to bind to if this is a cubetexture
  20707. * @param layer defines the index of the texture to bind in the array
  20708. */
  20709. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20711. private renderToTarget;
  20712. /**
  20713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20714. * This allowed control for front to back rendering or reversly depending of the special needs.
  20715. *
  20716. * @param renderingGroupId The rendering group id corresponding to its index
  20717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20720. */
  20721. 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;
  20722. /**
  20723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20724. *
  20725. * @param renderingGroupId The rendering group id corresponding to its index
  20726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20727. */
  20728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20729. /**
  20730. * Clones the texture.
  20731. * @returns the cloned texture
  20732. */
  20733. clone(): RenderTargetTexture;
  20734. /**
  20735. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20736. * @returns The JSON representation of the texture
  20737. */
  20738. serialize(): any;
  20739. /**
  20740. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20741. */
  20742. disposeFramebufferObjects(): void;
  20743. /**
  20744. * Dispose the texture and release its associated resources.
  20745. */
  20746. dispose(): void;
  20747. /** @hidden */
  20748. _rebuild(): void;
  20749. /**
  20750. * Clear the info related to rendering groups preventing retention point in material dispose.
  20751. */
  20752. freeRenderingGroups(): void;
  20753. /**
  20754. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20755. * @returns the view count
  20756. */
  20757. getViewCount(): number;
  20758. }
  20759. }
  20760. declare module BABYLON {
  20761. /**
  20762. * Options for compiling materials.
  20763. */
  20764. export interface IMaterialCompilationOptions {
  20765. /**
  20766. * Defines whether clip planes are enabled.
  20767. */
  20768. clipPlane: boolean;
  20769. /**
  20770. * Defines whether instances are enabled.
  20771. */
  20772. useInstances: boolean;
  20773. }
  20774. /**
  20775. * Base class for the main features of a material in Babylon.js
  20776. */
  20777. export class Material implements IAnimatable {
  20778. /**
  20779. * Returns the triangle fill mode
  20780. */
  20781. static readonly TriangleFillMode: number;
  20782. /**
  20783. * Returns the wireframe mode
  20784. */
  20785. static readonly WireFrameFillMode: number;
  20786. /**
  20787. * Returns the point fill mode
  20788. */
  20789. static readonly PointFillMode: number;
  20790. /**
  20791. * Returns the point list draw mode
  20792. */
  20793. static readonly PointListDrawMode: number;
  20794. /**
  20795. * Returns the line list draw mode
  20796. */
  20797. static readonly LineListDrawMode: number;
  20798. /**
  20799. * Returns the line loop draw mode
  20800. */
  20801. static readonly LineLoopDrawMode: number;
  20802. /**
  20803. * Returns the line strip draw mode
  20804. */
  20805. static readonly LineStripDrawMode: number;
  20806. /**
  20807. * Returns the triangle strip draw mode
  20808. */
  20809. static readonly TriangleStripDrawMode: number;
  20810. /**
  20811. * Returns the triangle fan draw mode
  20812. */
  20813. static readonly TriangleFanDrawMode: number;
  20814. /**
  20815. * Stores the clock-wise side orientation
  20816. */
  20817. static readonly ClockWiseSideOrientation: number;
  20818. /**
  20819. * Stores the counter clock-wise side orientation
  20820. */
  20821. static readonly CounterClockWiseSideOrientation: number;
  20822. /**
  20823. * The dirty texture flag value
  20824. */
  20825. static readonly TextureDirtyFlag: number;
  20826. /**
  20827. * The dirty light flag value
  20828. */
  20829. static readonly LightDirtyFlag: number;
  20830. /**
  20831. * The dirty fresnel flag value
  20832. */
  20833. static readonly FresnelDirtyFlag: number;
  20834. /**
  20835. * The dirty attribute flag value
  20836. */
  20837. static readonly AttributesDirtyFlag: number;
  20838. /**
  20839. * The dirty misc flag value
  20840. */
  20841. static readonly MiscDirtyFlag: number;
  20842. /**
  20843. * The all dirty flag value
  20844. */
  20845. static readonly AllDirtyFlag: number;
  20846. /**
  20847. * The ID of the material
  20848. */
  20849. id: string;
  20850. /**
  20851. * Gets or sets the unique id of the material
  20852. */
  20853. uniqueId: number;
  20854. /**
  20855. * The name of the material
  20856. */
  20857. name: string;
  20858. /**
  20859. * Gets or sets user defined metadata
  20860. */
  20861. metadata: any;
  20862. /**
  20863. * For internal use only. Please do not use.
  20864. */
  20865. reservedDataStore: any;
  20866. /**
  20867. * Specifies if the ready state should be checked on each call
  20868. */
  20869. checkReadyOnEveryCall: boolean;
  20870. /**
  20871. * Specifies if the ready state should be checked once
  20872. */
  20873. checkReadyOnlyOnce: boolean;
  20874. /**
  20875. * The state of the material
  20876. */
  20877. state: string;
  20878. /**
  20879. * The alpha value of the material
  20880. */
  20881. protected _alpha: number;
  20882. /**
  20883. * List of inspectable custom properties (used by the Inspector)
  20884. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20885. */
  20886. inspectableCustomProperties: IInspectable[];
  20887. /**
  20888. * Sets the alpha value of the material
  20889. */
  20890. set alpha(value: number);
  20891. /**
  20892. * Gets the alpha value of the material
  20893. */
  20894. get alpha(): number;
  20895. /**
  20896. * Specifies if back face culling is enabled
  20897. */
  20898. protected _backFaceCulling: boolean;
  20899. /**
  20900. * Sets the back-face culling state
  20901. */
  20902. set backFaceCulling(value: boolean);
  20903. /**
  20904. * Gets the back-face culling state
  20905. */
  20906. get backFaceCulling(): boolean;
  20907. /**
  20908. * Stores the value for side orientation
  20909. */
  20910. sideOrientation: number;
  20911. /**
  20912. * Callback triggered when the material is compiled
  20913. */
  20914. onCompiled: Nullable<(effect: Effect) => void>;
  20915. /**
  20916. * Callback triggered when an error occurs
  20917. */
  20918. onError: Nullable<(effect: Effect, errors: string) => void>;
  20919. /**
  20920. * Callback triggered to get the render target textures
  20921. */
  20922. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20923. /**
  20924. * Gets a boolean indicating that current material needs to register RTT
  20925. */
  20926. get hasRenderTargetTextures(): boolean;
  20927. /**
  20928. * Specifies if the material should be serialized
  20929. */
  20930. doNotSerialize: boolean;
  20931. /**
  20932. * @hidden
  20933. */
  20934. _storeEffectOnSubMeshes: boolean;
  20935. /**
  20936. * Stores the animations for the material
  20937. */
  20938. animations: Nullable<Array<Animation>>;
  20939. /**
  20940. * An event triggered when the material is disposed
  20941. */
  20942. onDisposeObservable: Observable<Material>;
  20943. /**
  20944. * An observer which watches for dispose events
  20945. */
  20946. private _onDisposeObserver;
  20947. private _onUnBindObservable;
  20948. /**
  20949. * Called during a dispose event
  20950. */
  20951. set onDispose(callback: () => void);
  20952. private _onBindObservable;
  20953. /**
  20954. * An event triggered when the material is bound
  20955. */
  20956. get onBindObservable(): Observable<AbstractMesh>;
  20957. /**
  20958. * An observer which watches for bind events
  20959. */
  20960. private _onBindObserver;
  20961. /**
  20962. * Called during a bind event
  20963. */
  20964. set onBind(callback: (Mesh: AbstractMesh) => void);
  20965. /**
  20966. * An event triggered when the material is unbound
  20967. */
  20968. get onUnBindObservable(): Observable<Material>;
  20969. /**
  20970. * Stores the value of the alpha mode
  20971. */
  20972. private _alphaMode;
  20973. /**
  20974. * Sets the value of the alpha mode.
  20975. *
  20976. * | Value | Type | Description |
  20977. * | --- | --- | --- |
  20978. * | 0 | ALPHA_DISABLE | |
  20979. * | 1 | ALPHA_ADD | |
  20980. * | 2 | ALPHA_COMBINE | |
  20981. * | 3 | ALPHA_SUBTRACT | |
  20982. * | 4 | ALPHA_MULTIPLY | |
  20983. * | 5 | ALPHA_MAXIMIZED | |
  20984. * | 6 | ALPHA_ONEONE | |
  20985. * | 7 | ALPHA_PREMULTIPLIED | |
  20986. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20987. * | 9 | ALPHA_INTERPOLATE | |
  20988. * | 10 | ALPHA_SCREENMODE | |
  20989. *
  20990. */
  20991. set alphaMode(value: number);
  20992. /**
  20993. * Gets the value of the alpha mode
  20994. */
  20995. get alphaMode(): number;
  20996. /**
  20997. * Stores the state of the need depth pre-pass value
  20998. */
  20999. private _needDepthPrePass;
  21000. /**
  21001. * Sets the need depth pre-pass value
  21002. */
  21003. set needDepthPrePass(value: boolean);
  21004. /**
  21005. * Gets the depth pre-pass value
  21006. */
  21007. get needDepthPrePass(): boolean;
  21008. /**
  21009. * Specifies if depth writing should be disabled
  21010. */
  21011. disableDepthWrite: boolean;
  21012. /**
  21013. * Specifies if depth writing should be forced
  21014. */
  21015. forceDepthWrite: boolean;
  21016. /**
  21017. * Specifies the depth function that should be used. 0 means the default engine function
  21018. */
  21019. depthFunction: number;
  21020. /**
  21021. * Specifies if there should be a separate pass for culling
  21022. */
  21023. separateCullingPass: boolean;
  21024. /**
  21025. * Stores the state specifing if fog should be enabled
  21026. */
  21027. private _fogEnabled;
  21028. /**
  21029. * Sets the state for enabling fog
  21030. */
  21031. set fogEnabled(value: boolean);
  21032. /**
  21033. * Gets the value of the fog enabled state
  21034. */
  21035. get fogEnabled(): boolean;
  21036. /**
  21037. * Stores the size of points
  21038. */
  21039. pointSize: number;
  21040. /**
  21041. * Stores the z offset value
  21042. */
  21043. zOffset: number;
  21044. /**
  21045. * Gets a value specifying if wireframe mode is enabled
  21046. */
  21047. get wireframe(): boolean;
  21048. /**
  21049. * Sets the state of wireframe mode
  21050. */
  21051. set wireframe(value: boolean);
  21052. /**
  21053. * Gets the value specifying if point clouds are enabled
  21054. */
  21055. get pointsCloud(): boolean;
  21056. /**
  21057. * Sets the state of point cloud mode
  21058. */
  21059. set pointsCloud(value: boolean);
  21060. /**
  21061. * Gets the material fill mode
  21062. */
  21063. get fillMode(): number;
  21064. /**
  21065. * Sets the material fill mode
  21066. */
  21067. set fillMode(value: number);
  21068. /**
  21069. * @hidden
  21070. * Stores the effects for the material
  21071. */
  21072. _effect: Nullable<Effect>;
  21073. /**
  21074. * Specifies if uniform buffers should be used
  21075. */
  21076. private _useUBO;
  21077. /**
  21078. * Stores a reference to the scene
  21079. */
  21080. private _scene;
  21081. /**
  21082. * Stores the fill mode state
  21083. */
  21084. private _fillMode;
  21085. /**
  21086. * Specifies if the depth write state should be cached
  21087. */
  21088. private _cachedDepthWriteState;
  21089. /**
  21090. * Specifies if the depth function state should be cached
  21091. */
  21092. private _cachedDepthFunctionState;
  21093. /**
  21094. * Stores the uniform buffer
  21095. */
  21096. protected _uniformBuffer: UniformBuffer;
  21097. /** @hidden */
  21098. _indexInSceneMaterialArray: number;
  21099. /** @hidden */
  21100. meshMap: Nullable<{
  21101. [id: string]: AbstractMesh | undefined;
  21102. }>;
  21103. /**
  21104. * Creates a material instance
  21105. * @param name defines the name of the material
  21106. * @param scene defines the scene to reference
  21107. * @param doNotAdd specifies if the material should be added to the scene
  21108. */
  21109. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21110. /**
  21111. * Returns a string representation of the current material
  21112. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21113. * @returns a string with material information
  21114. */
  21115. toString(fullDetails?: boolean): string;
  21116. /**
  21117. * Gets the class name of the material
  21118. * @returns a string with the class name of the material
  21119. */
  21120. getClassName(): string;
  21121. /**
  21122. * Specifies if updates for the material been locked
  21123. */
  21124. get isFrozen(): boolean;
  21125. /**
  21126. * Locks updates for the material
  21127. */
  21128. freeze(): void;
  21129. /**
  21130. * Unlocks updates for the material
  21131. */
  21132. unfreeze(): void;
  21133. /**
  21134. * Specifies if the material is ready to be used
  21135. * @param mesh defines the mesh to check
  21136. * @param useInstances specifies if instances should be used
  21137. * @returns a boolean indicating if the material is ready to be used
  21138. */
  21139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21140. /**
  21141. * Specifies that the submesh is ready to be used
  21142. * @param mesh defines the mesh to check
  21143. * @param subMesh defines which submesh to check
  21144. * @param useInstances specifies that instances should be used
  21145. * @returns a boolean indicating that the submesh is ready or not
  21146. */
  21147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21148. /**
  21149. * Returns the material effect
  21150. * @returns the effect associated with the material
  21151. */
  21152. getEffect(): Nullable<Effect>;
  21153. /**
  21154. * Returns the current scene
  21155. * @returns a Scene
  21156. */
  21157. getScene(): Scene;
  21158. /**
  21159. * Specifies if the material will require alpha blending
  21160. * @returns a boolean specifying if alpha blending is needed
  21161. */
  21162. needAlphaBlending(): boolean;
  21163. /**
  21164. * Specifies if the mesh will require alpha blending
  21165. * @param mesh defines the mesh to check
  21166. * @returns a boolean specifying if alpha blending is needed for the mesh
  21167. */
  21168. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21169. /**
  21170. * Specifies if this material should be rendered in alpha test mode
  21171. * @returns a boolean specifying if an alpha test is needed.
  21172. */
  21173. needAlphaTesting(): boolean;
  21174. /**
  21175. * Gets the texture used for the alpha test
  21176. * @returns the texture to use for alpha testing
  21177. */
  21178. getAlphaTestTexture(): Nullable<BaseTexture>;
  21179. /**
  21180. * Marks the material to indicate that it needs to be re-calculated
  21181. */
  21182. markDirty(): void;
  21183. /** @hidden */
  21184. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21185. /**
  21186. * Binds the material to the mesh
  21187. * @param world defines the world transformation matrix
  21188. * @param mesh defines the mesh to bind the material to
  21189. */
  21190. bind(world: Matrix, mesh?: Mesh): void;
  21191. /**
  21192. * Binds the submesh to the material
  21193. * @param world defines the world transformation matrix
  21194. * @param mesh defines the mesh containing the submesh
  21195. * @param subMesh defines the submesh to bind the material to
  21196. */
  21197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21198. /**
  21199. * Binds the world matrix to the material
  21200. * @param world defines the world transformation matrix
  21201. */
  21202. bindOnlyWorldMatrix(world: Matrix): void;
  21203. /**
  21204. * Binds the scene's uniform buffer to the effect.
  21205. * @param effect defines the effect to bind to the scene uniform buffer
  21206. * @param sceneUbo defines the uniform buffer storing scene data
  21207. */
  21208. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21209. /**
  21210. * Binds the view matrix to the effect
  21211. * @param effect defines the effect to bind the view matrix to
  21212. */
  21213. bindView(effect: Effect): void;
  21214. /**
  21215. * Binds the view projection matrix to the effect
  21216. * @param effect defines the effect to bind the view projection matrix to
  21217. */
  21218. bindViewProjection(effect: Effect): void;
  21219. /**
  21220. * Specifies if material alpha testing should be turned on for the mesh
  21221. * @param mesh defines the mesh to check
  21222. */
  21223. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21224. /**
  21225. * Processes to execute after binding the material to a mesh
  21226. * @param mesh defines the rendered mesh
  21227. */
  21228. protected _afterBind(mesh?: Mesh): void;
  21229. /**
  21230. * Unbinds the material from the mesh
  21231. */
  21232. unbind(): void;
  21233. /**
  21234. * Gets the active textures from the material
  21235. * @returns an array of textures
  21236. */
  21237. getActiveTextures(): BaseTexture[];
  21238. /**
  21239. * Specifies if the material uses a texture
  21240. * @param texture defines the texture to check against the material
  21241. * @returns a boolean specifying if the material uses the texture
  21242. */
  21243. hasTexture(texture: BaseTexture): boolean;
  21244. /**
  21245. * Makes a duplicate of the material, and gives it a new name
  21246. * @param name defines the new name for the duplicated material
  21247. * @returns the cloned material
  21248. */
  21249. clone(name: string): Nullable<Material>;
  21250. /**
  21251. * Gets the meshes bound to the material
  21252. * @returns an array of meshes bound to the material
  21253. */
  21254. getBindedMeshes(): AbstractMesh[];
  21255. /**
  21256. * Force shader compilation
  21257. * @param mesh defines the mesh associated with this material
  21258. * @param onCompiled defines a function to execute once the material is compiled
  21259. * @param options defines the options to configure the compilation
  21260. * @param onError defines a function to execute if the material fails compiling
  21261. */
  21262. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21263. /**
  21264. * Force shader compilation
  21265. * @param mesh defines the mesh that will use this material
  21266. * @param options defines additional options for compiling the shaders
  21267. * @returns a promise that resolves when the compilation completes
  21268. */
  21269. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21270. private static readonly _AllDirtyCallBack;
  21271. private static readonly _ImageProcessingDirtyCallBack;
  21272. private static readonly _TextureDirtyCallBack;
  21273. private static readonly _FresnelDirtyCallBack;
  21274. private static readonly _MiscDirtyCallBack;
  21275. private static readonly _LightsDirtyCallBack;
  21276. private static readonly _AttributeDirtyCallBack;
  21277. private static _FresnelAndMiscDirtyCallBack;
  21278. private static _TextureAndMiscDirtyCallBack;
  21279. private static readonly _DirtyCallbackArray;
  21280. private static readonly _RunDirtyCallBacks;
  21281. /**
  21282. * Marks a define in the material to indicate that it needs to be re-computed
  21283. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21284. */
  21285. markAsDirty(flag: number): void;
  21286. /**
  21287. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21288. * @param func defines a function which checks material defines against the submeshes
  21289. */
  21290. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21291. /**
  21292. * Indicates that we need to re-calculated for all submeshes
  21293. */
  21294. protected _markAllSubMeshesAsAllDirty(): void;
  21295. /**
  21296. * Indicates that image processing needs to be re-calculated for all submeshes
  21297. */
  21298. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21299. /**
  21300. * Indicates that textures need to be re-calculated for all submeshes
  21301. */
  21302. protected _markAllSubMeshesAsTexturesDirty(): void;
  21303. /**
  21304. * Indicates that fresnel needs to be re-calculated for all submeshes
  21305. */
  21306. protected _markAllSubMeshesAsFresnelDirty(): void;
  21307. /**
  21308. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21309. */
  21310. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21311. /**
  21312. * Indicates that lights need to be re-calculated for all submeshes
  21313. */
  21314. protected _markAllSubMeshesAsLightsDirty(): void;
  21315. /**
  21316. * Indicates that attributes need to be re-calculated for all submeshes
  21317. */
  21318. protected _markAllSubMeshesAsAttributesDirty(): void;
  21319. /**
  21320. * Indicates that misc needs to be re-calculated for all submeshes
  21321. */
  21322. protected _markAllSubMeshesAsMiscDirty(): void;
  21323. /**
  21324. * Indicates that textures and misc need to be re-calculated for all submeshes
  21325. */
  21326. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21327. /**
  21328. * Disposes the material
  21329. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21330. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21331. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21332. */
  21333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21334. /** @hidden */
  21335. private releaseVertexArrayObject;
  21336. /**
  21337. * Serializes this material
  21338. * @returns the serialized material object
  21339. */
  21340. serialize(): any;
  21341. /**
  21342. * Creates a material from parsed material data
  21343. * @param parsedMaterial defines parsed material data
  21344. * @param scene defines the hosting scene
  21345. * @param rootUrl defines the root URL to use to load textures
  21346. * @returns a new material
  21347. */
  21348. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21349. }
  21350. }
  21351. declare module BABYLON {
  21352. /**
  21353. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21354. * separate meshes. This can be use to improve performances.
  21355. * @see http://doc.babylonjs.com/how_to/multi_materials
  21356. */
  21357. export class MultiMaterial extends Material {
  21358. private _subMaterials;
  21359. /**
  21360. * Gets or Sets the list of Materials used within the multi material.
  21361. * They need to be ordered according to the submeshes order in the associated mesh
  21362. */
  21363. get subMaterials(): Nullable<Material>[];
  21364. set subMaterials(value: Nullable<Material>[]);
  21365. /**
  21366. * Function used to align with Node.getChildren()
  21367. * @returns the list of Materials used within the multi material
  21368. */
  21369. getChildren(): Nullable<Material>[];
  21370. /**
  21371. * Instantiates a new Multi Material
  21372. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21373. * separate meshes. This can be use to improve performances.
  21374. * @see http://doc.babylonjs.com/how_to/multi_materials
  21375. * @param name Define the name in the scene
  21376. * @param scene Define the scene the material belongs to
  21377. */
  21378. constructor(name: string, scene: Scene);
  21379. private _hookArray;
  21380. /**
  21381. * Get one of the submaterial by its index in the submaterials array
  21382. * @param index The index to look the sub material at
  21383. * @returns The Material if the index has been defined
  21384. */
  21385. getSubMaterial(index: number): Nullable<Material>;
  21386. /**
  21387. * Get the list of active textures for the whole sub materials list.
  21388. * @returns All the textures that will be used during the rendering
  21389. */
  21390. getActiveTextures(): BaseTexture[];
  21391. /**
  21392. * Gets the current class name of the material e.g. "MultiMaterial"
  21393. * Mainly use in serialization.
  21394. * @returns the class name
  21395. */
  21396. getClassName(): string;
  21397. /**
  21398. * Checks if the material is ready to render the requested sub mesh
  21399. * @param mesh Define the mesh the submesh belongs to
  21400. * @param subMesh Define the sub mesh to look readyness for
  21401. * @param useInstances Define whether or not the material is used with instances
  21402. * @returns true if ready, otherwise false
  21403. */
  21404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21405. /**
  21406. * Clones the current material and its related sub materials
  21407. * @param name Define the name of the newly cloned material
  21408. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21409. * @returns the cloned material
  21410. */
  21411. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21412. /**
  21413. * Serializes the materials into a JSON representation.
  21414. * @returns the JSON representation
  21415. */
  21416. serialize(): any;
  21417. /**
  21418. * Dispose the material and release its associated resources
  21419. * @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)
  21420. * @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)
  21421. * @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)
  21422. */
  21423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21424. /**
  21425. * Creates a MultiMaterial from parsed MultiMaterial data.
  21426. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21427. * @param scene defines the hosting scene
  21428. * @returns a new MultiMaterial
  21429. */
  21430. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21431. }
  21432. }
  21433. declare module BABYLON {
  21434. /**
  21435. * Base class for submeshes
  21436. */
  21437. export class BaseSubMesh {
  21438. /** @hidden */
  21439. _materialDefines: Nullable<MaterialDefines>;
  21440. /** @hidden */
  21441. _materialEffect: Nullable<Effect>;
  21442. /**
  21443. * Gets material defines used by the effect associated to the sub mesh
  21444. */
  21445. get materialDefines(): Nullable<MaterialDefines>;
  21446. /**
  21447. * Sets material defines used by the effect associated to the sub mesh
  21448. */
  21449. set materialDefines(defines: Nullable<MaterialDefines>);
  21450. /**
  21451. * Gets associated effect
  21452. */
  21453. get effect(): Nullable<Effect>;
  21454. /**
  21455. * Sets associated effect (effect used to render this submesh)
  21456. * @param effect defines the effect to associate with
  21457. * @param defines defines the set of defines used to compile this effect
  21458. */
  21459. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21460. }
  21461. /**
  21462. * Defines a subdivision inside a mesh
  21463. */
  21464. export class SubMesh extends BaseSubMesh implements ICullable {
  21465. /** the material index to use */
  21466. materialIndex: number;
  21467. /** vertex index start */
  21468. verticesStart: number;
  21469. /** vertices count */
  21470. verticesCount: number;
  21471. /** index start */
  21472. indexStart: number;
  21473. /** indices count */
  21474. indexCount: number;
  21475. /** @hidden */
  21476. _linesIndexCount: number;
  21477. private _mesh;
  21478. private _renderingMesh;
  21479. private _boundingInfo;
  21480. private _linesIndexBuffer;
  21481. /** @hidden */
  21482. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21483. /** @hidden */
  21484. _trianglePlanes: Plane[];
  21485. /** @hidden */
  21486. _lastColliderTransformMatrix: Nullable<Matrix>;
  21487. /** @hidden */
  21488. _renderId: number;
  21489. /** @hidden */
  21490. _alphaIndex: number;
  21491. /** @hidden */
  21492. _distanceToCamera: number;
  21493. /** @hidden */
  21494. _id: number;
  21495. private _currentMaterial;
  21496. /**
  21497. * Add a new submesh to a mesh
  21498. * @param materialIndex defines the material index to use
  21499. * @param verticesStart defines vertex index start
  21500. * @param verticesCount defines vertices count
  21501. * @param indexStart defines index start
  21502. * @param indexCount defines indices count
  21503. * @param mesh defines the parent mesh
  21504. * @param renderingMesh defines an optional rendering mesh
  21505. * @param createBoundingBox defines if bounding box should be created for this submesh
  21506. * @returns the new submesh
  21507. */
  21508. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21509. /**
  21510. * Creates a new submesh
  21511. * @param materialIndex defines the material index to use
  21512. * @param verticesStart defines vertex index start
  21513. * @param verticesCount defines vertices count
  21514. * @param indexStart defines index start
  21515. * @param indexCount defines indices count
  21516. * @param mesh defines the parent mesh
  21517. * @param renderingMesh defines an optional rendering mesh
  21518. * @param createBoundingBox defines if bounding box should be created for this submesh
  21519. */
  21520. constructor(
  21521. /** the material index to use */
  21522. materialIndex: number,
  21523. /** vertex index start */
  21524. verticesStart: number,
  21525. /** vertices count */
  21526. verticesCount: number,
  21527. /** index start */
  21528. indexStart: number,
  21529. /** indices count */
  21530. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21531. /**
  21532. * Returns true if this submesh covers the entire parent mesh
  21533. * @ignorenaming
  21534. */
  21535. get IsGlobal(): boolean;
  21536. /**
  21537. * Returns the submesh BoudingInfo object
  21538. * @returns current bounding info (or mesh's one if the submesh is global)
  21539. */
  21540. getBoundingInfo(): BoundingInfo;
  21541. /**
  21542. * Sets the submesh BoundingInfo
  21543. * @param boundingInfo defines the new bounding info to use
  21544. * @returns the SubMesh
  21545. */
  21546. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21547. /**
  21548. * Returns the mesh of the current submesh
  21549. * @return the parent mesh
  21550. */
  21551. getMesh(): AbstractMesh;
  21552. /**
  21553. * Returns the rendering mesh of the submesh
  21554. * @returns the rendering mesh (could be different from parent mesh)
  21555. */
  21556. getRenderingMesh(): Mesh;
  21557. /**
  21558. * Returns the submesh material
  21559. * @returns null or the current material
  21560. */
  21561. getMaterial(): Nullable<Material>;
  21562. /**
  21563. * Sets a new updated BoundingInfo object to the submesh
  21564. * @param data defines an optional position array to use to determine the bounding info
  21565. * @returns the SubMesh
  21566. */
  21567. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21568. /** @hidden */
  21569. _checkCollision(collider: Collider): boolean;
  21570. /**
  21571. * Updates the submesh BoundingInfo
  21572. * @param world defines the world matrix to use to update the bounding info
  21573. * @returns the submesh
  21574. */
  21575. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21576. /**
  21577. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21578. * @param frustumPlanes defines the frustum planes
  21579. * @returns true if the submesh is intersecting with the frustum
  21580. */
  21581. isInFrustum(frustumPlanes: Plane[]): boolean;
  21582. /**
  21583. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21584. * @param frustumPlanes defines the frustum planes
  21585. * @returns true if the submesh is inside the frustum
  21586. */
  21587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21588. /**
  21589. * Renders the submesh
  21590. * @param enableAlphaMode defines if alpha needs to be used
  21591. * @returns the submesh
  21592. */
  21593. render(enableAlphaMode: boolean): SubMesh;
  21594. /**
  21595. * @hidden
  21596. */
  21597. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21598. /**
  21599. * Checks if the submesh intersects with a ray
  21600. * @param ray defines the ray to test
  21601. * @returns true is the passed ray intersects the submesh bounding box
  21602. */
  21603. canIntersects(ray: Ray): boolean;
  21604. /**
  21605. * Intersects current submesh with a ray
  21606. * @param ray defines the ray to test
  21607. * @param positions defines mesh's positions array
  21608. * @param indices defines mesh's indices array
  21609. * @param fastCheck defines if only bounding info should be used
  21610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21611. * @returns intersection info or null if no intersection
  21612. */
  21613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21614. /** @hidden */
  21615. private _intersectLines;
  21616. /** @hidden */
  21617. private _intersectUnIndexedLines;
  21618. /** @hidden */
  21619. private _intersectTriangles;
  21620. /** @hidden */
  21621. private _intersectUnIndexedTriangles;
  21622. /** @hidden */
  21623. _rebuild(): void;
  21624. /**
  21625. * Creates a new submesh from the passed mesh
  21626. * @param newMesh defines the new hosting mesh
  21627. * @param newRenderingMesh defines an optional rendering mesh
  21628. * @returns the new submesh
  21629. */
  21630. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21631. /**
  21632. * Release associated resources
  21633. */
  21634. dispose(): void;
  21635. /**
  21636. * Gets the class name
  21637. * @returns the string "SubMesh".
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Creates a new submesh from indices data
  21642. * @param materialIndex the index of the main mesh material
  21643. * @param startIndex the index where to start the copy in the mesh indices array
  21644. * @param indexCount the number of indices to copy then from the startIndex
  21645. * @param mesh the main mesh to create the submesh from
  21646. * @param renderingMesh the optional rendering mesh
  21647. * @returns a new submesh
  21648. */
  21649. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21650. }
  21651. }
  21652. declare module BABYLON {
  21653. /**
  21654. * Class used to represent data loading progression
  21655. */
  21656. export class SceneLoaderFlags {
  21657. private static _ForceFullSceneLoadingForIncremental;
  21658. private static _ShowLoadingScreen;
  21659. private static _CleanBoneMatrixWeights;
  21660. private static _loggingLevel;
  21661. /**
  21662. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21663. */
  21664. static get ForceFullSceneLoadingForIncremental(): boolean;
  21665. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21666. /**
  21667. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21668. */
  21669. static get ShowLoadingScreen(): boolean;
  21670. static set ShowLoadingScreen(value: boolean);
  21671. /**
  21672. * Defines the current logging level (while loading the scene)
  21673. * @ignorenaming
  21674. */
  21675. static get loggingLevel(): number;
  21676. static set loggingLevel(value: number);
  21677. /**
  21678. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21679. */
  21680. static get CleanBoneMatrixWeights(): boolean;
  21681. static set CleanBoneMatrixWeights(value: boolean);
  21682. }
  21683. }
  21684. declare module BABYLON {
  21685. /**
  21686. * Class used to store geometry data (vertex buffers + index buffer)
  21687. */
  21688. export class Geometry implements IGetSetVerticesData {
  21689. /**
  21690. * Gets or sets the ID of the geometry
  21691. */
  21692. id: string;
  21693. /**
  21694. * Gets or sets the unique ID of the geometry
  21695. */
  21696. uniqueId: number;
  21697. /**
  21698. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21699. */
  21700. delayLoadState: number;
  21701. /**
  21702. * Gets the file containing the data to load when running in delay load state
  21703. */
  21704. delayLoadingFile: Nullable<string>;
  21705. /**
  21706. * Callback called when the geometry is updated
  21707. */
  21708. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21709. private _scene;
  21710. private _engine;
  21711. private _meshes;
  21712. private _totalVertices;
  21713. /** @hidden */
  21714. _indices: IndicesArray;
  21715. /** @hidden */
  21716. _vertexBuffers: {
  21717. [key: string]: VertexBuffer;
  21718. };
  21719. private _isDisposed;
  21720. private _extend;
  21721. private _boundingBias;
  21722. /** @hidden */
  21723. _delayInfo: Array<string>;
  21724. private _indexBuffer;
  21725. private _indexBufferIsUpdatable;
  21726. /** @hidden */
  21727. _boundingInfo: Nullable<BoundingInfo>;
  21728. /** @hidden */
  21729. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21730. /** @hidden */
  21731. _softwareSkinningFrameId: number;
  21732. private _vertexArrayObjects;
  21733. private _updatable;
  21734. /** @hidden */
  21735. _positions: Nullable<Vector3[]>;
  21736. /**
  21737. * 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
  21738. */
  21739. get boundingBias(): Vector2;
  21740. /**
  21741. * 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
  21742. */
  21743. set boundingBias(value: Vector2);
  21744. /**
  21745. * Static function used to attach a new empty geometry to a mesh
  21746. * @param mesh defines the mesh to attach the geometry to
  21747. * @returns the new Geometry
  21748. */
  21749. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21750. /**
  21751. * Creates a new geometry
  21752. * @param id defines the unique ID
  21753. * @param scene defines the hosting scene
  21754. * @param vertexData defines the VertexData used to get geometry data
  21755. * @param updatable defines if geometry must be updatable (false by default)
  21756. * @param mesh defines the mesh that will be associated with the geometry
  21757. */
  21758. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21759. /**
  21760. * Gets the current extend of the geometry
  21761. */
  21762. get extend(): {
  21763. minimum: Vector3;
  21764. maximum: Vector3;
  21765. };
  21766. /**
  21767. * Gets the hosting scene
  21768. * @returns the hosting Scene
  21769. */
  21770. getScene(): Scene;
  21771. /**
  21772. * Gets the hosting engine
  21773. * @returns the hosting Engine
  21774. */
  21775. getEngine(): Engine;
  21776. /**
  21777. * Defines if the geometry is ready to use
  21778. * @returns true if the geometry is ready to be used
  21779. */
  21780. isReady(): boolean;
  21781. /**
  21782. * Gets a value indicating that the geometry should not be serialized
  21783. */
  21784. get doNotSerialize(): boolean;
  21785. /** @hidden */
  21786. _rebuild(): void;
  21787. /**
  21788. * Affects all geometry data in one call
  21789. * @param vertexData defines the geometry data
  21790. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21791. */
  21792. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21793. /**
  21794. * Set specific vertex data
  21795. * @param kind defines the data kind (Position, normal, etc...)
  21796. * @param data defines the vertex data to use
  21797. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21798. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21799. */
  21800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21801. /**
  21802. * Removes a specific vertex data
  21803. * @param kind defines the data kind (Position, normal, etc...)
  21804. */
  21805. removeVerticesData(kind: string): void;
  21806. /**
  21807. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21808. * @param buffer defines the vertex buffer to use
  21809. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21810. */
  21811. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21812. /**
  21813. * Update a specific vertex buffer
  21814. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21815. * It will do nothing if the buffer is not updatable
  21816. * @param kind defines the data kind (Position, normal, etc...)
  21817. * @param data defines the data to use
  21818. * @param offset defines the offset in the target buffer where to store the data
  21819. * @param useBytes set to true if the offset is in bytes
  21820. */
  21821. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21822. /**
  21823. * Update a specific vertex buffer
  21824. * This function will create a new buffer if the current one is not updatable
  21825. * @param kind defines the data kind (Position, normal, etc...)
  21826. * @param data defines the data to use
  21827. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21828. */
  21829. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21830. private _updateBoundingInfo;
  21831. /** @hidden */
  21832. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21833. /**
  21834. * Gets total number of vertices
  21835. * @returns the total number of vertices
  21836. */
  21837. getTotalVertices(): number;
  21838. /**
  21839. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21840. * @param kind defines the data kind (Position, normal, etc...)
  21841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21843. * @returns a float array containing vertex data
  21844. */
  21845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21846. /**
  21847. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21848. * @param kind defines the data kind (Position, normal, etc...)
  21849. * @returns true if the vertex buffer with the specified kind is updatable
  21850. */
  21851. isVertexBufferUpdatable(kind: string): boolean;
  21852. /**
  21853. * Gets a specific vertex buffer
  21854. * @param kind defines the data kind (Position, normal, etc...)
  21855. * @returns a VertexBuffer
  21856. */
  21857. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21858. /**
  21859. * Returns all vertex buffers
  21860. * @return an object holding all vertex buffers indexed by kind
  21861. */
  21862. getVertexBuffers(): Nullable<{
  21863. [key: string]: VertexBuffer;
  21864. }>;
  21865. /**
  21866. * Gets a boolean indicating if specific vertex buffer is present
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @returns true if data is present
  21869. */
  21870. isVerticesDataPresent(kind: string): boolean;
  21871. /**
  21872. * Gets a list of all attached data kinds (Position, normal, etc...)
  21873. * @returns a list of string containing all kinds
  21874. */
  21875. getVerticesDataKinds(): string[];
  21876. /**
  21877. * Update index buffer
  21878. * @param indices defines the indices to store in the index buffer
  21879. * @param offset defines the offset in the target buffer where to store the data
  21880. * @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)
  21881. */
  21882. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21883. /**
  21884. * Creates a new index buffer
  21885. * @param indices defines the indices to store in the index buffer
  21886. * @param totalVertices defines the total number of vertices (could be null)
  21887. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21890. /**
  21891. * Return the total number of indices
  21892. * @returns the total number of indices
  21893. */
  21894. getTotalIndices(): number;
  21895. /**
  21896. * Gets the index buffer array
  21897. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21898. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21899. * @returns the index buffer array
  21900. */
  21901. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21902. /**
  21903. * Gets the index buffer
  21904. * @return the index buffer
  21905. */
  21906. getIndexBuffer(): Nullable<DataBuffer>;
  21907. /** @hidden */
  21908. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21909. /**
  21910. * Release the associated resources for a specific mesh
  21911. * @param mesh defines the source mesh
  21912. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21913. */
  21914. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21915. /**
  21916. * Apply current geometry to a given mesh
  21917. * @param mesh defines the mesh to apply geometry to
  21918. */
  21919. applyToMesh(mesh: Mesh): void;
  21920. private _updateExtend;
  21921. private _applyToMesh;
  21922. private notifyUpdate;
  21923. /**
  21924. * Load the geometry if it was flagged as delay loaded
  21925. * @param scene defines the hosting scene
  21926. * @param onLoaded defines a callback called when the geometry is loaded
  21927. */
  21928. load(scene: Scene, onLoaded?: () => void): void;
  21929. private _queueLoad;
  21930. /**
  21931. * Invert the geometry to move from a right handed system to a left handed one.
  21932. */
  21933. toLeftHanded(): void;
  21934. /** @hidden */
  21935. _resetPointsArrayCache(): void;
  21936. /** @hidden */
  21937. _generatePointsArray(): boolean;
  21938. /**
  21939. * Gets a value indicating if the geometry is disposed
  21940. * @returns true if the geometry was disposed
  21941. */
  21942. isDisposed(): boolean;
  21943. private _disposeVertexArrayObjects;
  21944. /**
  21945. * Free all associated resources
  21946. */
  21947. dispose(): void;
  21948. /**
  21949. * Clone the current geometry into a new geometry
  21950. * @param id defines the unique ID of the new geometry
  21951. * @returns a new geometry object
  21952. */
  21953. copy(id: string): Geometry;
  21954. /**
  21955. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21956. * @return a JSON representation of the current geometry data (without the vertices data)
  21957. */
  21958. serialize(): any;
  21959. private toNumberArray;
  21960. /**
  21961. * Serialize all vertices data into a JSON oject
  21962. * @returns a JSON representation of the current geometry data
  21963. */
  21964. serializeVerticeData(): any;
  21965. /**
  21966. * Extracts a clone of a mesh geometry
  21967. * @param mesh defines the source mesh
  21968. * @param id defines the unique ID of the new geometry object
  21969. * @returns the new geometry object
  21970. */
  21971. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21972. /**
  21973. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21974. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21975. * Be aware Math.random() could cause collisions, but:
  21976. * "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"
  21977. * @returns a string containing a new GUID
  21978. */
  21979. static RandomId(): string;
  21980. /** @hidden */
  21981. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21982. private static _CleanMatricesWeights;
  21983. /**
  21984. * Create a new geometry from persisted data (Using .babylon file format)
  21985. * @param parsedVertexData defines the persisted data
  21986. * @param scene defines the hosting scene
  21987. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21988. * @returns the new geometry object
  21989. */
  21990. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21991. }
  21992. }
  21993. declare module BABYLON {
  21994. /**
  21995. * Define an interface for all classes that will get and set the data on vertices
  21996. */
  21997. export interface IGetSetVerticesData {
  21998. /**
  21999. * Gets a boolean indicating if specific vertex data is present
  22000. * @param kind defines the vertex data kind to use
  22001. * @returns true is data kind is present
  22002. */
  22003. isVerticesDataPresent(kind: string): boolean;
  22004. /**
  22005. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22006. * @param kind defines the data kind (Position, normal, etc...)
  22007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22009. * @returns a float array containing vertex data
  22010. */
  22011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22012. /**
  22013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22014. * @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.
  22015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22016. * @returns the indices array or an empty array if the mesh has no geometry
  22017. */
  22018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22019. /**
  22020. * Set specific vertex data
  22021. * @param kind defines the data kind (Position, normal, etc...)
  22022. * @param data defines the vertex data to use
  22023. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22024. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22025. */
  22026. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22027. /**
  22028. * Update a specific associated vertex buffer
  22029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22030. * - VertexBuffer.PositionKind
  22031. * - VertexBuffer.UVKind
  22032. * - VertexBuffer.UV2Kind
  22033. * - VertexBuffer.UV3Kind
  22034. * - VertexBuffer.UV4Kind
  22035. * - VertexBuffer.UV5Kind
  22036. * - VertexBuffer.UV6Kind
  22037. * - VertexBuffer.ColorKind
  22038. * - VertexBuffer.MatricesIndicesKind
  22039. * - VertexBuffer.MatricesIndicesExtraKind
  22040. * - VertexBuffer.MatricesWeightsKind
  22041. * - VertexBuffer.MatricesWeightsExtraKind
  22042. * @param data defines the data source
  22043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22044. * @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)
  22045. */
  22046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22047. /**
  22048. * Creates a new index buffer
  22049. * @param indices defines the indices to store in the index buffer
  22050. * @param totalVertices defines the total number of vertices (could be null)
  22051. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22052. */
  22053. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22054. }
  22055. /**
  22056. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22057. */
  22058. export class VertexData {
  22059. /**
  22060. * Mesh side orientation : usually the external or front surface
  22061. */
  22062. static readonly FRONTSIDE: number;
  22063. /**
  22064. * Mesh side orientation : usually the internal or back surface
  22065. */
  22066. static readonly BACKSIDE: number;
  22067. /**
  22068. * Mesh side orientation : both internal and external or front and back surfaces
  22069. */
  22070. static readonly DOUBLESIDE: number;
  22071. /**
  22072. * Mesh side orientation : by default, `FRONTSIDE`
  22073. */
  22074. static readonly DEFAULTSIDE: number;
  22075. /**
  22076. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22077. */
  22078. positions: Nullable<FloatArray>;
  22079. /**
  22080. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22081. */
  22082. normals: Nullable<FloatArray>;
  22083. /**
  22084. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22085. */
  22086. tangents: Nullable<FloatArray>;
  22087. /**
  22088. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22089. */
  22090. uvs: Nullable<FloatArray>;
  22091. /**
  22092. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22093. */
  22094. uvs2: Nullable<FloatArray>;
  22095. /**
  22096. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22097. */
  22098. uvs3: Nullable<FloatArray>;
  22099. /**
  22100. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22101. */
  22102. uvs4: Nullable<FloatArray>;
  22103. /**
  22104. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22105. */
  22106. uvs5: Nullable<FloatArray>;
  22107. /**
  22108. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22109. */
  22110. uvs6: Nullable<FloatArray>;
  22111. /**
  22112. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22113. */
  22114. colors: Nullable<FloatArray>;
  22115. /**
  22116. * 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).
  22117. */
  22118. matricesIndices: Nullable<FloatArray>;
  22119. /**
  22120. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22121. */
  22122. matricesWeights: Nullable<FloatArray>;
  22123. /**
  22124. * An array extending the number of possible indices
  22125. */
  22126. matricesIndicesExtra: Nullable<FloatArray>;
  22127. /**
  22128. * An array extending the number of possible weights when the number of indices is extended
  22129. */
  22130. matricesWeightsExtra: Nullable<FloatArray>;
  22131. /**
  22132. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22133. */
  22134. indices: Nullable<IndicesArray>;
  22135. /**
  22136. * Uses the passed data array to set the set the values for the specified kind of data
  22137. * @param data a linear array of floating numbers
  22138. * @param kind the type of data that is being set, eg positions, colors etc
  22139. */
  22140. set(data: FloatArray, kind: string): void;
  22141. /**
  22142. * Associates the vertexData to the passed Mesh.
  22143. * Sets it as updatable or not (default `false`)
  22144. * @param mesh the mesh the vertexData is applied to
  22145. * @param updatable when used and having the value true allows new data to update the vertexData
  22146. * @returns the VertexData
  22147. */
  22148. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22149. /**
  22150. * Associates the vertexData to the passed Geometry.
  22151. * Sets it as updatable or not (default `false`)
  22152. * @param geometry the geometry the vertexData is applied to
  22153. * @param updatable when used and having the value true allows new data to update the vertexData
  22154. * @returns VertexData
  22155. */
  22156. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22157. /**
  22158. * Updates the associated mesh
  22159. * @param mesh the mesh to be updated
  22160. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22161. * @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
  22162. * @returns VertexData
  22163. */
  22164. updateMesh(mesh: Mesh): VertexData;
  22165. /**
  22166. * Updates the associated geometry
  22167. * @param geometry the geometry to be updated
  22168. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22169. * @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
  22170. * @returns VertexData.
  22171. */
  22172. updateGeometry(geometry: Geometry): VertexData;
  22173. private _applyTo;
  22174. private _update;
  22175. /**
  22176. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22177. * @param matrix the transforming matrix
  22178. * @returns the VertexData
  22179. */
  22180. transform(matrix: Matrix): VertexData;
  22181. /**
  22182. * Merges the passed VertexData into the current one
  22183. * @param other the VertexData to be merged into the current one
  22184. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22185. * @returns the modified VertexData
  22186. */
  22187. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22188. private _mergeElement;
  22189. private _validate;
  22190. /**
  22191. * Serializes the VertexData
  22192. * @returns a serialized object
  22193. */
  22194. serialize(): any;
  22195. /**
  22196. * Extracts the vertexData from a mesh
  22197. * @param mesh the mesh from which to extract the VertexData
  22198. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22199. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22200. * @returns the object VertexData associated to the passed mesh
  22201. */
  22202. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22203. /**
  22204. * Extracts the vertexData from the geometry
  22205. * @param geometry the geometry from which to extract the VertexData
  22206. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22207. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22208. * @returns the object VertexData associated to the passed mesh
  22209. */
  22210. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22211. private static _ExtractFrom;
  22212. /**
  22213. * Creates the VertexData for a Ribbon
  22214. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22215. * * pathArray array of paths, each of which an array of successive Vector3
  22216. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22217. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22218. * * 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
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22223. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22224. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22225. * @returns the VertexData of the ribbon
  22226. */
  22227. static CreateRibbon(options: {
  22228. pathArray: Vector3[][];
  22229. closeArray?: boolean;
  22230. closePath?: boolean;
  22231. offset?: number;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. invertUV?: boolean;
  22236. uvs?: Vector2[];
  22237. colors?: Color4[];
  22238. }): VertexData;
  22239. /**
  22240. * Creates the VertexData for a box
  22241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22242. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22243. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22244. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22245. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22246. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22247. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22249. * * 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)
  22250. * * 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)
  22251. * @returns the VertexData of the box
  22252. */
  22253. static CreateBox(options: {
  22254. size?: number;
  22255. width?: number;
  22256. height?: number;
  22257. depth?: number;
  22258. faceUV?: Vector4[];
  22259. faceColors?: Color4[];
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. }): VertexData;
  22264. /**
  22265. * Creates the VertexData for a tiled box
  22266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22267. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22268. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22269. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22271. * @returns the VertexData of the box
  22272. */
  22273. static CreateTiledBox(options: {
  22274. pattern?: number;
  22275. width?: number;
  22276. height?: number;
  22277. depth?: number;
  22278. tileSize?: number;
  22279. tileWidth?: number;
  22280. tileHeight?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. faceUV?: Vector4[];
  22284. faceColors?: Color4[];
  22285. sideOrientation?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a tiled plane
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * pattern a limited pattern arrangement depending on the number
  22291. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22292. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22293. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22295. * * 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)
  22296. * * 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)
  22297. * @returns the VertexData of the tiled plane
  22298. */
  22299. static CreateTiledPlane(options: {
  22300. pattern?: number;
  22301. tileSize?: number;
  22302. tileWidth?: number;
  22303. tileHeight?: number;
  22304. size?: number;
  22305. width?: number;
  22306. height?: number;
  22307. alignHorizontal?: number;
  22308. alignVertical?: number;
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22316. * * segments sets the number of horizontal strips optional, default 32
  22317. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22318. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22319. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22320. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22321. * * 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
  22322. * * 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
  22323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22324. * * 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)
  22325. * * 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)
  22326. * @returns the VertexData of the ellipsoid
  22327. */
  22328. static CreateSphere(options: {
  22329. segments?: number;
  22330. diameter?: number;
  22331. diameterX?: number;
  22332. diameterY?: number;
  22333. diameterZ?: number;
  22334. arc?: number;
  22335. slice?: number;
  22336. sideOrientation?: number;
  22337. frontUVs?: Vector4;
  22338. backUVs?: Vector4;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a cylinder, cone or prism
  22342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22343. * * height sets the height (y direction) of the cylinder, optional, default 2
  22344. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22345. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22346. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22347. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22348. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22349. * * 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
  22350. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22352. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22353. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22356. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22357. * @returns the VertexData of the cylinder, cone or prism
  22358. */
  22359. static CreateCylinder(options: {
  22360. height?: number;
  22361. diameterTop?: number;
  22362. diameterBottom?: number;
  22363. diameter?: number;
  22364. tessellation?: number;
  22365. subdivisions?: number;
  22366. arc?: number;
  22367. faceColors?: Color4[];
  22368. faceUV?: Vector4[];
  22369. hasRings?: boolean;
  22370. enclose?: boolean;
  22371. sideOrientation?: number;
  22372. frontUVs?: Vector4;
  22373. backUVs?: Vector4;
  22374. }): VertexData;
  22375. /**
  22376. * Creates the VertexData for a torus
  22377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22378. * * diameter the diameter of the torus, optional default 1
  22379. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22380. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * * 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)
  22383. * * 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)
  22384. * @returns the VertexData of the torus
  22385. */
  22386. static CreateTorus(options: {
  22387. diameter?: number;
  22388. thickness?: number;
  22389. tessellation?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData of the LineSystem
  22396. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22397. * - lines an array of lines, each line being an array of successive Vector3
  22398. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22399. * @returns the VertexData of the LineSystem
  22400. */
  22401. static CreateLineSystem(options: {
  22402. lines: Vector3[][];
  22403. colors?: Nullable<Color4[][]>;
  22404. }): VertexData;
  22405. /**
  22406. * Create the VertexData for a DashedLines
  22407. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22408. * - points an array successive Vector3
  22409. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22410. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22411. * - dashNb the intended total number of dashes, optional, default 200
  22412. * @returns the VertexData for the DashedLines
  22413. */
  22414. static CreateDashedLines(options: {
  22415. points: Vector3[];
  22416. dashSize?: number;
  22417. gapSize?: number;
  22418. dashNb?: number;
  22419. }): VertexData;
  22420. /**
  22421. * Creates the VertexData for a Ground
  22422. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22423. * - width the width (x direction) of the ground, optional, default 1
  22424. * - height the height (z direction) of the ground, optional, default 1
  22425. * - subdivisions the number of subdivisions per side, optional, default 1
  22426. * @returns the VertexData of the Ground
  22427. */
  22428. static CreateGround(options: {
  22429. width?: number;
  22430. height?: number;
  22431. subdivisions?: number;
  22432. subdivisionsX?: number;
  22433. subdivisionsY?: number;
  22434. }): VertexData;
  22435. /**
  22436. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22437. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22438. * * xmin the ground minimum X coordinate, optional, default -1
  22439. * * zmin the ground minimum Z coordinate, optional, default -1
  22440. * * xmax the ground maximum X coordinate, optional, default 1
  22441. * * zmax the ground maximum Z coordinate, optional, default 1
  22442. * * 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}
  22443. * * 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}
  22444. * @returns the VertexData of the TiledGround
  22445. */
  22446. static CreateTiledGround(options: {
  22447. xmin: number;
  22448. zmin: number;
  22449. xmax: number;
  22450. zmax: number;
  22451. subdivisions?: {
  22452. w: number;
  22453. h: number;
  22454. };
  22455. precision?: {
  22456. w: number;
  22457. h: number;
  22458. };
  22459. }): VertexData;
  22460. /**
  22461. * Creates the VertexData of the Ground designed from a heightmap
  22462. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22463. * * width the width (x direction) of the ground
  22464. * * height the height (z direction) of the ground
  22465. * * subdivisions the number of subdivisions per side
  22466. * * minHeight the minimum altitude on the ground, optional, default 0
  22467. * * maxHeight the maximum altitude on the ground, optional default 1
  22468. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22469. * * buffer the array holding the image color data
  22470. * * bufferWidth the width of image
  22471. * * bufferHeight the height of image
  22472. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22473. * @returns the VertexData of the Ground designed from a heightmap
  22474. */
  22475. static CreateGroundFromHeightMap(options: {
  22476. width: number;
  22477. height: number;
  22478. subdivisions: number;
  22479. minHeight: number;
  22480. maxHeight: number;
  22481. colorFilter: Color3;
  22482. buffer: Uint8Array;
  22483. bufferWidth: number;
  22484. bufferHeight: number;
  22485. alphaFilter: number;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a Plane
  22489. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22490. * * size sets the width and height of the plane to the value of size, optional default 1
  22491. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22492. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22494. * * 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)
  22495. * * 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)
  22496. * @returns the VertexData of the box
  22497. */
  22498. static CreatePlane(options: {
  22499. size?: number;
  22500. width?: number;
  22501. height?: number;
  22502. sideOrientation?: number;
  22503. frontUVs?: Vector4;
  22504. backUVs?: Vector4;
  22505. }): VertexData;
  22506. /**
  22507. * Creates the VertexData of the Disc or regular Polygon
  22508. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22509. * * radius the radius of the disc, optional default 0.5
  22510. * * tessellation the number of polygon sides, optional, default 64
  22511. * * 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
  22512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22513. * * 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)
  22514. * * 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)
  22515. * @returns the VertexData of the box
  22516. */
  22517. static CreateDisc(options: {
  22518. radius?: number;
  22519. tessellation?: number;
  22520. arc?: number;
  22521. sideOrientation?: number;
  22522. frontUVs?: Vector4;
  22523. backUVs?: Vector4;
  22524. }): VertexData;
  22525. /**
  22526. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22527. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22528. * @param polygon a mesh built from polygonTriangulation.build()
  22529. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22531. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22532. * @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)
  22533. * @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)
  22534. * @returns the VertexData of the Polygon
  22535. */
  22536. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22537. /**
  22538. * Creates the VertexData of the IcoSphere
  22539. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22540. * * radius the radius of the IcoSphere, optional default 1
  22541. * * radiusX allows stretching in the x direction, optional, default radius
  22542. * * radiusY allows stretching in the y direction, optional, default radius
  22543. * * radiusZ allows stretching in the z direction, optional, default radius
  22544. * * flat when true creates a flat shaded mesh, optional, default true
  22545. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22547. * * 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)
  22548. * * 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)
  22549. * @returns the VertexData of the IcoSphere
  22550. */
  22551. static CreateIcoSphere(options: {
  22552. radius?: number;
  22553. radiusX?: number;
  22554. radiusY?: number;
  22555. radiusZ?: number;
  22556. flat?: boolean;
  22557. subdivisions?: number;
  22558. sideOrientation?: number;
  22559. frontUVs?: Vector4;
  22560. backUVs?: Vector4;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a Polyhedron
  22564. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22565. * * type provided types are:
  22566. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22567. * * 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)
  22568. * * size the size of the IcoSphere, optional default 1
  22569. * * sizeX allows stretching in the x direction, optional, default size
  22570. * * sizeY allows stretching in the y direction, optional, default size
  22571. * * sizeZ allows stretching in the z direction, optional, default size
  22572. * * 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
  22573. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22574. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22575. * * flat when true creates a flat shaded mesh, optional, default true
  22576. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22578. * * 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)
  22579. * * 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)
  22580. * @returns the VertexData of the Polyhedron
  22581. */
  22582. static CreatePolyhedron(options: {
  22583. type?: number;
  22584. size?: number;
  22585. sizeX?: number;
  22586. sizeY?: number;
  22587. sizeZ?: number;
  22588. custom?: any;
  22589. faceUV?: Vector4[];
  22590. faceColors?: Color4[];
  22591. flat?: boolean;
  22592. sideOrientation?: number;
  22593. frontUVs?: Vector4;
  22594. backUVs?: Vector4;
  22595. }): VertexData;
  22596. /**
  22597. * Creates the VertexData for a TorusKnot
  22598. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22599. * * radius the radius of the torus knot, optional, default 2
  22600. * * tube the thickness of the tube, optional, default 0.5
  22601. * * radialSegments the number of sides on each tube segments, optional, default 32
  22602. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22603. * * p the number of windings around the z axis, optional, default 2
  22604. * * q the number of windings around the x axis, optional, default 3
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the Torus Knot
  22609. */
  22610. static CreateTorusKnot(options: {
  22611. radius?: number;
  22612. tube?: number;
  22613. radialSegments?: number;
  22614. tubularSegments?: number;
  22615. p?: number;
  22616. q?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Compute normals for given positions and indices
  22623. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22624. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22625. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22626. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22627. * * facetNormals : optional array of facet normals (vector3)
  22628. * * facetPositions : optional array of facet positions (vector3)
  22629. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22630. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22631. * * bInfo : optional bounding info, required for facetPartitioning computation
  22632. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22633. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22634. * * useRightHandedSystem: optional boolean to for right handed system computation
  22635. * * depthSort : optional boolean to enable the facet depth sort computation
  22636. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22637. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22638. */
  22639. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22640. facetNormals?: any;
  22641. facetPositions?: any;
  22642. facetPartitioning?: any;
  22643. ratio?: number;
  22644. bInfo?: any;
  22645. bbSize?: Vector3;
  22646. subDiv?: any;
  22647. useRightHandedSystem?: boolean;
  22648. depthSort?: boolean;
  22649. distanceTo?: Vector3;
  22650. depthSortedFacets?: any;
  22651. }): void;
  22652. /** @hidden */
  22653. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22654. /**
  22655. * Applies VertexData created from the imported parameters to the geometry
  22656. * @param parsedVertexData the parsed data from an imported file
  22657. * @param geometry the geometry to apply the VertexData to
  22658. */
  22659. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22660. }
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * Defines a target to use with MorphTargetManager
  22665. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22666. */
  22667. export class MorphTarget implements IAnimatable {
  22668. /** defines the name of the target */
  22669. name: string;
  22670. /**
  22671. * Gets or sets the list of animations
  22672. */
  22673. animations: Animation[];
  22674. private _scene;
  22675. private _positions;
  22676. private _normals;
  22677. private _tangents;
  22678. private _uvs;
  22679. private _influence;
  22680. private _uniqueId;
  22681. /**
  22682. * Observable raised when the influence changes
  22683. */
  22684. onInfluenceChanged: Observable<boolean>;
  22685. /** @hidden */
  22686. _onDataLayoutChanged: Observable<void>;
  22687. /**
  22688. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22689. */
  22690. get influence(): number;
  22691. set influence(influence: number);
  22692. /**
  22693. * Gets or sets the id of the morph Target
  22694. */
  22695. id: string;
  22696. private _animationPropertiesOverride;
  22697. /**
  22698. * Gets or sets the animation properties override
  22699. */
  22700. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22701. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22702. /**
  22703. * Creates a new MorphTarget
  22704. * @param name defines the name of the target
  22705. * @param influence defines the influence to use
  22706. * @param scene defines the scene the morphtarget belongs to
  22707. */
  22708. constructor(
  22709. /** defines the name of the target */
  22710. name: string, influence?: number, scene?: Nullable<Scene>);
  22711. /**
  22712. * Gets the unique ID of this manager
  22713. */
  22714. get uniqueId(): number;
  22715. /**
  22716. * Gets a boolean defining if the target contains position data
  22717. */
  22718. get hasPositions(): boolean;
  22719. /**
  22720. * Gets a boolean defining if the target contains normal data
  22721. */
  22722. get hasNormals(): boolean;
  22723. /**
  22724. * Gets a boolean defining if the target contains tangent data
  22725. */
  22726. get hasTangents(): boolean;
  22727. /**
  22728. * Gets a boolean defining if the target contains texture coordinates data
  22729. */
  22730. get hasUVs(): boolean;
  22731. /**
  22732. * Affects position data to this target
  22733. * @param data defines the position data to use
  22734. */
  22735. setPositions(data: Nullable<FloatArray>): void;
  22736. /**
  22737. * Gets the position data stored in this target
  22738. * @returns a FloatArray containing the position data (or null if not present)
  22739. */
  22740. getPositions(): Nullable<FloatArray>;
  22741. /**
  22742. * Affects normal data to this target
  22743. * @param data defines the normal data to use
  22744. */
  22745. setNormals(data: Nullable<FloatArray>): void;
  22746. /**
  22747. * Gets the normal data stored in this target
  22748. * @returns a FloatArray containing the normal data (or null if not present)
  22749. */
  22750. getNormals(): Nullable<FloatArray>;
  22751. /**
  22752. * Affects tangent data to this target
  22753. * @param data defines the tangent data to use
  22754. */
  22755. setTangents(data: Nullable<FloatArray>): void;
  22756. /**
  22757. * Gets the tangent data stored in this target
  22758. * @returns a FloatArray containing the tangent data (or null if not present)
  22759. */
  22760. getTangents(): Nullable<FloatArray>;
  22761. /**
  22762. * Affects texture coordinates data to this target
  22763. * @param data defines the texture coordinates data to use
  22764. */
  22765. setUVs(data: Nullable<FloatArray>): void;
  22766. /**
  22767. * Gets the texture coordinates data stored in this target
  22768. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22769. */
  22770. getUVs(): Nullable<FloatArray>;
  22771. /**
  22772. * Clone the current target
  22773. * @returns a new MorphTarget
  22774. */
  22775. clone(): MorphTarget;
  22776. /**
  22777. * Serializes the current target into a Serialization object
  22778. * @returns the serialized object
  22779. */
  22780. serialize(): any;
  22781. /**
  22782. * Returns the string "MorphTarget"
  22783. * @returns "MorphTarget"
  22784. */
  22785. getClassName(): string;
  22786. /**
  22787. * Creates a new target from serialized data
  22788. * @param serializationObject defines the serialized data to use
  22789. * @returns a new MorphTarget
  22790. */
  22791. static Parse(serializationObject: any): MorphTarget;
  22792. /**
  22793. * Creates a MorphTarget from mesh data
  22794. * @param mesh defines the source mesh
  22795. * @param name defines the name to use for the new target
  22796. * @param influence defines the influence to attach to the target
  22797. * @returns a new MorphTarget
  22798. */
  22799. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22800. }
  22801. }
  22802. declare module BABYLON {
  22803. /**
  22804. * This class is used to deform meshes using morphing between different targets
  22805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22806. */
  22807. export class MorphTargetManager {
  22808. private _targets;
  22809. private _targetInfluenceChangedObservers;
  22810. private _targetDataLayoutChangedObservers;
  22811. private _activeTargets;
  22812. private _scene;
  22813. private _influences;
  22814. private _supportsNormals;
  22815. private _supportsTangents;
  22816. private _supportsUVs;
  22817. private _vertexCount;
  22818. private _uniqueId;
  22819. private _tempInfluences;
  22820. /**
  22821. * Gets or sets a boolean indicating if normals must be morphed
  22822. */
  22823. enableNormalMorphing: boolean;
  22824. /**
  22825. * Gets or sets a boolean indicating if tangents must be morphed
  22826. */
  22827. enableTangentMorphing: boolean;
  22828. /**
  22829. * Gets or sets a boolean indicating if UV must be morphed
  22830. */
  22831. enableUVMorphing: boolean;
  22832. /**
  22833. * Creates a new MorphTargetManager
  22834. * @param scene defines the current scene
  22835. */
  22836. constructor(scene?: Nullable<Scene>);
  22837. /**
  22838. * Gets the unique ID of this manager
  22839. */
  22840. get uniqueId(): number;
  22841. /**
  22842. * Gets the number of vertices handled by this manager
  22843. */
  22844. get vertexCount(): number;
  22845. /**
  22846. * Gets a boolean indicating if this manager supports morphing of normals
  22847. */
  22848. get supportsNormals(): boolean;
  22849. /**
  22850. * Gets a boolean indicating if this manager supports morphing of tangents
  22851. */
  22852. get supportsTangents(): boolean;
  22853. /**
  22854. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22855. */
  22856. get supportsUVs(): boolean;
  22857. /**
  22858. * Gets the number of targets stored in this manager
  22859. */
  22860. get numTargets(): number;
  22861. /**
  22862. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22863. */
  22864. get numInfluencers(): number;
  22865. /**
  22866. * Gets the list of influences (one per target)
  22867. */
  22868. get influences(): Float32Array;
  22869. /**
  22870. * Gets the active target at specified index. An active target is a target with an influence > 0
  22871. * @param index defines the index to check
  22872. * @returns the requested target
  22873. */
  22874. getActiveTarget(index: number): MorphTarget;
  22875. /**
  22876. * Gets the target at specified index
  22877. * @param index defines the index to check
  22878. * @returns the requested target
  22879. */
  22880. getTarget(index: number): MorphTarget;
  22881. /**
  22882. * Add a new target to this manager
  22883. * @param target defines the target to add
  22884. */
  22885. addTarget(target: MorphTarget): void;
  22886. /**
  22887. * Removes a target from the manager
  22888. * @param target defines the target to remove
  22889. */
  22890. removeTarget(target: MorphTarget): void;
  22891. /**
  22892. * Clone the current manager
  22893. * @returns a new MorphTargetManager
  22894. */
  22895. clone(): MorphTargetManager;
  22896. /**
  22897. * Serializes the current manager into a Serialization object
  22898. * @returns the serialized object
  22899. */
  22900. serialize(): any;
  22901. private _syncActiveTargets;
  22902. /**
  22903. * Syncrhonize the targets with all the meshes using this morph target manager
  22904. */
  22905. synchronize(): void;
  22906. /**
  22907. * Creates a new MorphTargetManager from serialized data
  22908. * @param serializationObject defines the serialized data
  22909. * @param scene defines the hosting scene
  22910. * @returns the new MorphTargetManager
  22911. */
  22912. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22913. }
  22914. }
  22915. declare module BABYLON {
  22916. /**
  22917. * Class used to represent a specific level of detail of a mesh
  22918. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22919. */
  22920. export class MeshLODLevel {
  22921. /** Defines the distance where this level should start being displayed */
  22922. distance: number;
  22923. /** Defines the mesh to use to render this level */
  22924. mesh: Nullable<Mesh>;
  22925. /**
  22926. * Creates a new LOD level
  22927. * @param distance defines the distance where this level should star being displayed
  22928. * @param mesh defines the mesh to use to render this level
  22929. */
  22930. constructor(
  22931. /** Defines the distance where this level should start being displayed */
  22932. distance: number,
  22933. /** Defines the mesh to use to render this level */
  22934. mesh: Nullable<Mesh>);
  22935. }
  22936. }
  22937. declare module BABYLON {
  22938. /**
  22939. * Mesh representing the gorund
  22940. */
  22941. export class GroundMesh extends Mesh {
  22942. /** If octree should be generated */
  22943. generateOctree: boolean;
  22944. private _heightQuads;
  22945. /** @hidden */
  22946. _subdivisionsX: number;
  22947. /** @hidden */
  22948. _subdivisionsY: number;
  22949. /** @hidden */
  22950. _width: number;
  22951. /** @hidden */
  22952. _height: number;
  22953. /** @hidden */
  22954. _minX: number;
  22955. /** @hidden */
  22956. _maxX: number;
  22957. /** @hidden */
  22958. _minZ: number;
  22959. /** @hidden */
  22960. _maxZ: number;
  22961. constructor(name: string, scene: Scene);
  22962. /**
  22963. * "GroundMesh"
  22964. * @returns "GroundMesh"
  22965. */
  22966. getClassName(): string;
  22967. /**
  22968. * The minimum of x and y subdivisions
  22969. */
  22970. get subdivisions(): number;
  22971. /**
  22972. * X subdivisions
  22973. */
  22974. get subdivisionsX(): number;
  22975. /**
  22976. * Y subdivisions
  22977. */
  22978. get subdivisionsY(): number;
  22979. /**
  22980. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22981. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22982. * @param chunksCount the number of subdivisions for x and y
  22983. * @param octreeBlocksSize (Default: 32)
  22984. */
  22985. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22986. /**
  22987. * Returns a height (y) value in the Worl system :
  22988. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22989. * @param x x coordinate
  22990. * @param z z coordinate
  22991. * @returns the ground y position if (x, z) are outside the ground surface.
  22992. */
  22993. getHeightAtCoordinates(x: number, z: number): number;
  22994. /**
  22995. * Returns a normalized vector (Vector3) orthogonal to the ground
  22996. * at the ground coordinates (x, z) expressed in the World system.
  22997. * @param x x coordinate
  22998. * @param z z coordinate
  22999. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23000. */
  23001. getNormalAtCoordinates(x: number, z: number): Vector3;
  23002. /**
  23003. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23004. * at the ground coordinates (x, z) expressed in the World system.
  23005. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23006. * @param x x coordinate
  23007. * @param z z coordinate
  23008. * @param ref vector to store the result
  23009. * @returns the GroundMesh.
  23010. */
  23011. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23012. /**
  23013. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23014. * if the ground has been updated.
  23015. * This can be used in the render loop.
  23016. * @returns the GroundMesh.
  23017. */
  23018. updateCoordinateHeights(): GroundMesh;
  23019. private _getFacetAt;
  23020. private _initHeightQuads;
  23021. private _computeHeightQuads;
  23022. /**
  23023. * Serializes this ground mesh
  23024. * @param serializationObject object to write serialization to
  23025. */
  23026. serialize(serializationObject: any): void;
  23027. /**
  23028. * Parses a serialized ground mesh
  23029. * @param parsedMesh the serialized mesh
  23030. * @param scene the scene to create the ground mesh in
  23031. * @returns the created ground mesh
  23032. */
  23033. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23034. }
  23035. }
  23036. declare module BABYLON {
  23037. /**
  23038. * Interface for Physics-Joint data
  23039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23040. */
  23041. export interface PhysicsJointData {
  23042. /**
  23043. * The main pivot of the joint
  23044. */
  23045. mainPivot?: Vector3;
  23046. /**
  23047. * The connected pivot of the joint
  23048. */
  23049. connectedPivot?: Vector3;
  23050. /**
  23051. * The main axis of the joint
  23052. */
  23053. mainAxis?: Vector3;
  23054. /**
  23055. * The connected axis of the joint
  23056. */
  23057. connectedAxis?: Vector3;
  23058. /**
  23059. * The collision of the joint
  23060. */
  23061. collision?: boolean;
  23062. /**
  23063. * Native Oimo/Cannon/Energy data
  23064. */
  23065. nativeParams?: any;
  23066. }
  23067. /**
  23068. * This is a holder class for the physics joint created by the physics plugin
  23069. * It holds a set of functions to control the underlying joint
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class PhysicsJoint {
  23073. /**
  23074. * The type of the physics joint
  23075. */
  23076. type: number;
  23077. /**
  23078. * The data for the physics joint
  23079. */
  23080. jointData: PhysicsJointData;
  23081. private _physicsJoint;
  23082. protected _physicsPlugin: IPhysicsEnginePlugin;
  23083. /**
  23084. * Initializes the physics joint
  23085. * @param type The type of the physics joint
  23086. * @param jointData The data for the physics joint
  23087. */
  23088. constructor(
  23089. /**
  23090. * The type of the physics joint
  23091. */
  23092. type: number,
  23093. /**
  23094. * The data for the physics joint
  23095. */
  23096. jointData: PhysicsJointData);
  23097. /**
  23098. * Gets the physics joint
  23099. */
  23100. get physicsJoint(): any;
  23101. /**
  23102. * Sets the physics joint
  23103. */
  23104. set physicsJoint(newJoint: any);
  23105. /**
  23106. * Sets the physics plugin
  23107. */
  23108. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23109. /**
  23110. * Execute a function that is physics-plugin specific.
  23111. * @param {Function} func the function that will be executed.
  23112. * It accepts two parameters: the physics world and the physics joint
  23113. */
  23114. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23115. /**
  23116. * Distance-Joint type
  23117. */
  23118. static DistanceJoint: number;
  23119. /**
  23120. * Hinge-Joint type
  23121. */
  23122. static HingeJoint: number;
  23123. /**
  23124. * Ball-and-Socket joint type
  23125. */
  23126. static BallAndSocketJoint: number;
  23127. /**
  23128. * Wheel-Joint type
  23129. */
  23130. static WheelJoint: number;
  23131. /**
  23132. * Slider-Joint type
  23133. */
  23134. static SliderJoint: number;
  23135. /**
  23136. * Prismatic-Joint type
  23137. */
  23138. static PrismaticJoint: number;
  23139. /**
  23140. * Universal-Joint type
  23141. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23142. */
  23143. static UniversalJoint: number;
  23144. /**
  23145. * Hinge-Joint 2 type
  23146. */
  23147. static Hinge2Joint: number;
  23148. /**
  23149. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23150. */
  23151. static PointToPointJoint: number;
  23152. /**
  23153. * Spring-Joint type
  23154. */
  23155. static SpringJoint: number;
  23156. /**
  23157. * Lock-Joint type
  23158. */
  23159. static LockJoint: number;
  23160. }
  23161. /**
  23162. * A class representing a physics distance joint
  23163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23164. */
  23165. export class DistanceJoint extends PhysicsJoint {
  23166. /**
  23167. *
  23168. * @param jointData The data for the Distance-Joint
  23169. */
  23170. constructor(jointData: DistanceJointData);
  23171. /**
  23172. * Update the predefined distance.
  23173. * @param maxDistance The maximum preferred distance
  23174. * @param minDistance The minimum preferred distance
  23175. */
  23176. updateDistance(maxDistance: number, minDistance?: number): void;
  23177. }
  23178. /**
  23179. * Represents a Motor-Enabled Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23183. /**
  23184. * Initializes the Motor-Enabled Joint
  23185. * @param type The type of the joint
  23186. * @param jointData The physica joint data for the joint
  23187. */
  23188. constructor(type: number, jointData: PhysicsJointData);
  23189. /**
  23190. * Set the motor values.
  23191. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23192. * @param force the force to apply
  23193. * @param maxForce max force for this motor.
  23194. */
  23195. setMotor(force?: number, maxForce?: number): void;
  23196. /**
  23197. * Set the motor's limits.
  23198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23199. * @param upperLimit The upper limit of the motor
  23200. * @param lowerLimit The lower limit of the motor
  23201. */
  23202. setLimit(upperLimit: number, lowerLimit?: number): void;
  23203. }
  23204. /**
  23205. * This class represents a single physics Hinge-Joint
  23206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23207. */
  23208. export class HingeJoint extends MotorEnabledJoint {
  23209. /**
  23210. * Initializes the Hinge-Joint
  23211. * @param jointData The joint data for the Hinge-Joint
  23212. */
  23213. constructor(jointData: PhysicsJointData);
  23214. /**
  23215. * Set the motor values.
  23216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23217. * @param {number} force the force to apply
  23218. * @param {number} maxForce max force for this motor.
  23219. */
  23220. setMotor(force?: number, maxForce?: number): void;
  23221. /**
  23222. * Set the motor's limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param upperLimit The upper limit of the motor
  23225. * @param lowerLimit The lower limit of the motor
  23226. */
  23227. setLimit(upperLimit: number, lowerLimit?: number): void;
  23228. }
  23229. /**
  23230. * This class represents a dual hinge physics joint (same as wheel joint)
  23231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23232. */
  23233. export class Hinge2Joint extends MotorEnabledJoint {
  23234. /**
  23235. * Initializes the Hinge2-Joint
  23236. * @param jointData The joint data for the Hinge2-Joint
  23237. */
  23238. constructor(jointData: PhysicsJointData);
  23239. /**
  23240. * Set the motor values.
  23241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23242. * @param {number} targetSpeed the speed the motor is to reach
  23243. * @param {number} maxForce max force for this motor.
  23244. * @param {motorIndex} the motor's index, 0 or 1.
  23245. */
  23246. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23247. /**
  23248. * Set the motor limits.
  23249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23250. * @param {number} upperLimit the upper limit
  23251. * @param {number} lowerLimit lower limit
  23252. * @param {motorIndex} the motor's index, 0 or 1.
  23253. */
  23254. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23255. }
  23256. /**
  23257. * Interface for a motor enabled joint
  23258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23259. */
  23260. export interface IMotorEnabledJoint {
  23261. /**
  23262. * Physics joint
  23263. */
  23264. physicsJoint: any;
  23265. /**
  23266. * Sets the motor of the motor-enabled joint
  23267. * @param force The force of the motor
  23268. * @param maxForce The maximum force of the motor
  23269. * @param motorIndex The index of the motor
  23270. */
  23271. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23272. /**
  23273. * Sets the limit of the motor
  23274. * @param upperLimit The upper limit of the motor
  23275. * @param lowerLimit The lower limit of the motor
  23276. * @param motorIndex The index of the motor
  23277. */
  23278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23279. }
  23280. /**
  23281. * Joint data for a Distance-Joint
  23282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23283. */
  23284. export interface DistanceJointData extends PhysicsJointData {
  23285. /**
  23286. * Max distance the 2 joint objects can be apart
  23287. */
  23288. maxDistance: number;
  23289. }
  23290. /**
  23291. * Joint data from a spring joint
  23292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23293. */
  23294. export interface SpringJointData extends PhysicsJointData {
  23295. /**
  23296. * Length of the spring
  23297. */
  23298. length: number;
  23299. /**
  23300. * Stiffness of the spring
  23301. */
  23302. stiffness: number;
  23303. /**
  23304. * Damping of the spring
  23305. */
  23306. damping: number;
  23307. /** this callback will be called when applying the force to the impostors. */
  23308. forceApplicationCallback: () => void;
  23309. }
  23310. }
  23311. declare module BABYLON {
  23312. /**
  23313. * Holds the data for the raycast result
  23314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23315. */
  23316. export class PhysicsRaycastResult {
  23317. private _hasHit;
  23318. private _hitDistance;
  23319. private _hitNormalWorld;
  23320. private _hitPointWorld;
  23321. private _rayFromWorld;
  23322. private _rayToWorld;
  23323. /**
  23324. * Gets if there was a hit
  23325. */
  23326. get hasHit(): boolean;
  23327. /**
  23328. * Gets the distance from the hit
  23329. */
  23330. get hitDistance(): number;
  23331. /**
  23332. * Gets the hit normal/direction in the world
  23333. */
  23334. get hitNormalWorld(): Vector3;
  23335. /**
  23336. * Gets the hit point in the world
  23337. */
  23338. get hitPointWorld(): Vector3;
  23339. /**
  23340. * Gets the ray "start point" of the ray in the world
  23341. */
  23342. get rayFromWorld(): Vector3;
  23343. /**
  23344. * Gets the ray "end point" of the ray in the world
  23345. */
  23346. get rayToWorld(): Vector3;
  23347. /**
  23348. * Sets the hit data (normal & point in world space)
  23349. * @param hitNormalWorld defines the normal in world space
  23350. * @param hitPointWorld defines the point in world space
  23351. */
  23352. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23353. /**
  23354. * Sets the distance from the start point to the hit point
  23355. * @param distance
  23356. */
  23357. setHitDistance(distance: number): void;
  23358. /**
  23359. * Calculates the distance manually
  23360. */
  23361. calculateHitDistance(): void;
  23362. /**
  23363. * Resets all the values to default
  23364. * @param from The from point on world space
  23365. * @param to The to point on world space
  23366. */
  23367. reset(from?: Vector3, to?: Vector3): void;
  23368. }
  23369. /**
  23370. * Interface for the size containing width and height
  23371. */
  23372. interface IXYZ {
  23373. /**
  23374. * X
  23375. */
  23376. x: number;
  23377. /**
  23378. * Y
  23379. */
  23380. y: number;
  23381. /**
  23382. * Z
  23383. */
  23384. z: number;
  23385. }
  23386. }
  23387. declare module BABYLON {
  23388. /**
  23389. * Interface used to describe a physics joint
  23390. */
  23391. export interface PhysicsImpostorJoint {
  23392. /** Defines the main impostor to which the joint is linked */
  23393. mainImpostor: PhysicsImpostor;
  23394. /** Defines the impostor that is connected to the main impostor using this joint */
  23395. connectedImpostor: PhysicsImpostor;
  23396. /** Defines the joint itself */
  23397. joint: PhysicsJoint;
  23398. }
  23399. /** @hidden */
  23400. export interface IPhysicsEnginePlugin {
  23401. world: any;
  23402. name: string;
  23403. setGravity(gravity: Vector3): void;
  23404. setTimeStep(timeStep: number): void;
  23405. getTimeStep(): number;
  23406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23409. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23410. removePhysicsBody(impostor: PhysicsImpostor): void;
  23411. generateJoint(joint: PhysicsImpostorJoint): void;
  23412. removeJoint(joint: PhysicsImpostorJoint): void;
  23413. isSupported(): boolean;
  23414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23421. getBodyMass(impostor: PhysicsImpostor): number;
  23422. getBodyFriction(impostor: PhysicsImpostor): number;
  23423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23424. getBodyRestitution(impostor: PhysicsImpostor): number;
  23425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23426. getBodyPressure?(impostor: PhysicsImpostor): number;
  23427. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23428. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23429. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23430. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23431. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23432. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23433. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23434. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23435. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23436. sleepBody(impostor: PhysicsImpostor): void;
  23437. wakeUpBody(impostor: PhysicsImpostor): void;
  23438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23439. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23440. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23441. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23442. getRadius(impostor: PhysicsImpostor): number;
  23443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23444. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23445. dispose(): void;
  23446. }
  23447. /**
  23448. * Interface used to define a physics engine
  23449. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23450. */
  23451. export interface IPhysicsEngine {
  23452. /**
  23453. * Gets the gravity vector used by the simulation
  23454. */
  23455. gravity: Vector3;
  23456. /**
  23457. * Sets the gravity vector used by the simulation
  23458. * @param gravity defines the gravity vector to use
  23459. */
  23460. setGravity(gravity: Vector3): void;
  23461. /**
  23462. * Set the time step of the physics engine.
  23463. * Default is 1/60.
  23464. * To slow it down, enter 1/600 for example.
  23465. * To speed it up, 1/30
  23466. * @param newTimeStep the new timestep to apply to this world.
  23467. */
  23468. setTimeStep(newTimeStep: number): void;
  23469. /**
  23470. * Get the time step of the physics engine.
  23471. * @returns the current time step
  23472. */
  23473. getTimeStep(): number;
  23474. /**
  23475. * Set the sub time step of the physics engine.
  23476. * Default is 0 meaning there is no sub steps
  23477. * To increase physics resolution precision, set a small value (like 1 ms)
  23478. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23479. */
  23480. setSubTimeStep(subTimeStep: number): void;
  23481. /**
  23482. * Get the sub time step of the physics engine.
  23483. * @returns the current sub time step
  23484. */
  23485. getSubTimeStep(): number;
  23486. /**
  23487. * Release all resources
  23488. */
  23489. dispose(): void;
  23490. /**
  23491. * Gets the name of the current physics plugin
  23492. * @returns the name of the plugin
  23493. */
  23494. getPhysicsPluginName(): string;
  23495. /**
  23496. * Adding a new impostor for the impostor tracking.
  23497. * This will be done by the impostor itself.
  23498. * @param impostor the impostor to add
  23499. */
  23500. addImpostor(impostor: PhysicsImpostor): void;
  23501. /**
  23502. * Remove an impostor from the engine.
  23503. * This impostor and its mesh will not longer be updated by the physics engine.
  23504. * @param impostor the impostor to remove
  23505. */
  23506. removeImpostor(impostor: PhysicsImpostor): void;
  23507. /**
  23508. * Add a joint to the physics engine
  23509. * @param mainImpostor defines the main impostor to which the joint is added.
  23510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23511. * @param joint defines the joint that will connect both impostors.
  23512. */
  23513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23514. /**
  23515. * Removes a joint from the simulation
  23516. * @param mainImpostor defines the impostor used with the joint
  23517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23518. * @param joint defines the joint to remove
  23519. */
  23520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23521. /**
  23522. * Gets the current plugin used to run the simulation
  23523. * @returns current plugin
  23524. */
  23525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23526. /**
  23527. * Gets the list of physic impostors
  23528. * @returns an array of PhysicsImpostor
  23529. */
  23530. getImpostors(): Array<PhysicsImpostor>;
  23531. /**
  23532. * Gets the impostor for a physics enabled object
  23533. * @param object defines the object impersonated by the impostor
  23534. * @returns the PhysicsImpostor or null if not found
  23535. */
  23536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23537. /**
  23538. * Gets the impostor for a physics body object
  23539. * @param body defines physics body used by the impostor
  23540. * @returns the PhysicsImpostor or null if not found
  23541. */
  23542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23543. /**
  23544. * Does a raycast in the physics world
  23545. * @param from when should the ray start?
  23546. * @param to when should the ray end?
  23547. * @returns PhysicsRaycastResult
  23548. */
  23549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23550. /**
  23551. * Called by the scene. No need to call it.
  23552. * @param delta defines the timespam between frames
  23553. */
  23554. _step(delta: number): void;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. /**
  23559. * The interface for the physics imposter parameters
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface PhysicsImpostorParameters {
  23563. /**
  23564. * The mass of the physics imposter
  23565. */
  23566. mass: number;
  23567. /**
  23568. * The friction of the physics imposter
  23569. */
  23570. friction?: number;
  23571. /**
  23572. * The coefficient of restitution of the physics imposter
  23573. */
  23574. restitution?: number;
  23575. /**
  23576. * The native options of the physics imposter
  23577. */
  23578. nativeOptions?: any;
  23579. /**
  23580. * Specifies if the parent should be ignored
  23581. */
  23582. ignoreParent?: boolean;
  23583. /**
  23584. * Specifies if bi-directional transformations should be disabled
  23585. */
  23586. disableBidirectionalTransformation?: boolean;
  23587. /**
  23588. * The pressure inside the physics imposter, soft object only
  23589. */
  23590. pressure?: number;
  23591. /**
  23592. * The stiffness the physics imposter, soft object only
  23593. */
  23594. stiffness?: number;
  23595. /**
  23596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23597. */
  23598. velocityIterations?: number;
  23599. /**
  23600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23601. */
  23602. positionIterations?: number;
  23603. /**
  23604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23606. * Add to fix multiple points
  23607. */
  23608. fixedPoints?: number;
  23609. /**
  23610. * The collision margin around a soft object
  23611. */
  23612. margin?: number;
  23613. /**
  23614. * The collision margin around a soft object
  23615. */
  23616. damping?: number;
  23617. /**
  23618. * The path for a rope based on an extrusion
  23619. */
  23620. path?: any;
  23621. /**
  23622. * The shape of an extrusion used for a rope based on an extrusion
  23623. */
  23624. shape?: any;
  23625. }
  23626. /**
  23627. * Interface for a physics-enabled object
  23628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23629. */
  23630. export interface IPhysicsEnabledObject {
  23631. /**
  23632. * The position of the physics-enabled object
  23633. */
  23634. position: Vector3;
  23635. /**
  23636. * The rotation of the physics-enabled object
  23637. */
  23638. rotationQuaternion: Nullable<Quaternion>;
  23639. /**
  23640. * The scale of the physics-enabled object
  23641. */
  23642. scaling: Vector3;
  23643. /**
  23644. * The rotation of the physics-enabled object
  23645. */
  23646. rotation?: Vector3;
  23647. /**
  23648. * The parent of the physics-enabled object
  23649. */
  23650. parent?: any;
  23651. /**
  23652. * The bounding info of the physics-enabled object
  23653. * @returns The bounding info of the physics-enabled object
  23654. */
  23655. getBoundingInfo(): BoundingInfo;
  23656. /**
  23657. * Computes the world matrix
  23658. * @param force Specifies if the world matrix should be computed by force
  23659. * @returns A world matrix
  23660. */
  23661. computeWorldMatrix(force: boolean): Matrix;
  23662. /**
  23663. * Gets the world matrix
  23664. * @returns A world matrix
  23665. */
  23666. getWorldMatrix?(): Matrix;
  23667. /**
  23668. * Gets the child meshes
  23669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23670. * @returns An array of abstract meshes
  23671. */
  23672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23673. /**
  23674. * Gets the vertex data
  23675. * @param kind The type of vertex data
  23676. * @returns A nullable array of numbers, or a float32 array
  23677. */
  23678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23679. /**
  23680. * Gets the indices from the mesh
  23681. * @returns A nullable array of index arrays
  23682. */
  23683. getIndices?(): Nullable<IndicesArray>;
  23684. /**
  23685. * Gets the scene from the mesh
  23686. * @returns the indices array or null
  23687. */
  23688. getScene?(): Scene;
  23689. /**
  23690. * Gets the absolute position from the mesh
  23691. * @returns the absolute position
  23692. */
  23693. getAbsolutePosition(): Vector3;
  23694. /**
  23695. * Gets the absolute pivot point from the mesh
  23696. * @returns the absolute pivot point
  23697. */
  23698. getAbsolutePivotPoint(): Vector3;
  23699. /**
  23700. * Rotates the mesh
  23701. * @param axis The axis of rotation
  23702. * @param amount The amount of rotation
  23703. * @param space The space of the rotation
  23704. * @returns The rotation transform node
  23705. */
  23706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23707. /**
  23708. * Translates the mesh
  23709. * @param axis The axis of translation
  23710. * @param distance The distance of translation
  23711. * @param space The space of the translation
  23712. * @returns The transform node
  23713. */
  23714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23715. /**
  23716. * Sets the absolute position of the mesh
  23717. * @param absolutePosition The absolute position of the mesh
  23718. * @returns The transform node
  23719. */
  23720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23721. /**
  23722. * Gets the class name of the mesh
  23723. * @returns The class name
  23724. */
  23725. getClassName(): string;
  23726. }
  23727. /**
  23728. * Represents a physics imposter
  23729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23730. */
  23731. export class PhysicsImpostor {
  23732. /**
  23733. * The physics-enabled object used as the physics imposter
  23734. */
  23735. object: IPhysicsEnabledObject;
  23736. /**
  23737. * The type of the physics imposter
  23738. */
  23739. type: number;
  23740. private _options;
  23741. private _scene?;
  23742. /**
  23743. * The default object size of the imposter
  23744. */
  23745. static DEFAULT_OBJECT_SIZE: Vector3;
  23746. /**
  23747. * The identity quaternion of the imposter
  23748. */
  23749. static IDENTITY_QUATERNION: Quaternion;
  23750. /** @hidden */
  23751. _pluginData: any;
  23752. private _physicsEngine;
  23753. private _physicsBody;
  23754. private _bodyUpdateRequired;
  23755. private _onBeforePhysicsStepCallbacks;
  23756. private _onAfterPhysicsStepCallbacks;
  23757. /** @hidden */
  23758. _onPhysicsCollideCallbacks: Array<{
  23759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23760. otherImpostors: Array<PhysicsImpostor>;
  23761. }>;
  23762. private _deltaPosition;
  23763. private _deltaRotation;
  23764. private _deltaRotationConjugated;
  23765. /** @hidden */
  23766. _isFromLine: boolean;
  23767. private _parent;
  23768. private _isDisposed;
  23769. private static _tmpVecs;
  23770. private static _tmpQuat;
  23771. /**
  23772. * Specifies if the physics imposter is disposed
  23773. */
  23774. get isDisposed(): boolean;
  23775. /**
  23776. * Gets the mass of the physics imposter
  23777. */
  23778. get mass(): number;
  23779. set mass(value: number);
  23780. /**
  23781. * Gets the coefficient of friction
  23782. */
  23783. get friction(): number;
  23784. /**
  23785. * Sets the coefficient of friction
  23786. */
  23787. set friction(value: number);
  23788. /**
  23789. * Gets the coefficient of restitution
  23790. */
  23791. get restitution(): number;
  23792. /**
  23793. * Sets the coefficient of restitution
  23794. */
  23795. set restitution(value: number);
  23796. /**
  23797. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23798. */
  23799. get pressure(): number;
  23800. /**
  23801. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23802. */
  23803. set pressure(value: number);
  23804. /**
  23805. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23806. */
  23807. get stiffness(): number;
  23808. /**
  23809. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23810. */
  23811. set stiffness(value: number);
  23812. /**
  23813. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23814. */
  23815. get velocityIterations(): number;
  23816. /**
  23817. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23818. */
  23819. set velocityIterations(value: number);
  23820. /**
  23821. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23822. */
  23823. get positionIterations(): number;
  23824. /**
  23825. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23826. */
  23827. set positionIterations(value: number);
  23828. /**
  23829. * The unique id of the physics imposter
  23830. * set by the physics engine when adding this impostor to the array
  23831. */
  23832. uniqueId: number;
  23833. /**
  23834. * @hidden
  23835. */
  23836. soft: boolean;
  23837. /**
  23838. * @hidden
  23839. */
  23840. segments: number;
  23841. private _joints;
  23842. /**
  23843. * Initializes the physics imposter
  23844. * @param object The physics-enabled object used as the physics imposter
  23845. * @param type The type of the physics imposter
  23846. * @param _options The options for the physics imposter
  23847. * @param _scene The Babylon scene
  23848. */
  23849. constructor(
  23850. /**
  23851. * The physics-enabled object used as the physics imposter
  23852. */
  23853. object: IPhysicsEnabledObject,
  23854. /**
  23855. * The type of the physics imposter
  23856. */
  23857. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23858. /**
  23859. * This function will completly initialize this impostor.
  23860. * It will create a new body - but only if this mesh has no parent.
  23861. * If it has, this impostor will not be used other than to define the impostor
  23862. * of the child mesh.
  23863. * @hidden
  23864. */
  23865. _init(): void;
  23866. private _getPhysicsParent;
  23867. /**
  23868. * Should a new body be generated.
  23869. * @returns boolean specifying if body initialization is required
  23870. */
  23871. isBodyInitRequired(): boolean;
  23872. /**
  23873. * Sets the updated scaling
  23874. * @param updated Specifies if the scaling is updated
  23875. */
  23876. setScalingUpdated(): void;
  23877. /**
  23878. * Force a regeneration of this or the parent's impostor's body.
  23879. * Use under cautious - This will remove all joints already implemented.
  23880. */
  23881. forceUpdate(): void;
  23882. /**
  23883. * Gets the body that holds this impostor. Either its own, or its parent.
  23884. */
  23885. get physicsBody(): any;
  23886. /**
  23887. * Get the parent of the physics imposter
  23888. * @returns Physics imposter or null
  23889. */
  23890. get parent(): Nullable<PhysicsImpostor>;
  23891. /**
  23892. * Sets the parent of the physics imposter
  23893. */
  23894. set parent(value: Nullable<PhysicsImpostor>);
  23895. /**
  23896. * Set the physics body. Used mainly by the physics engine/plugin
  23897. */
  23898. set physicsBody(physicsBody: any);
  23899. /**
  23900. * Resets the update flags
  23901. */
  23902. resetUpdateFlags(): void;
  23903. /**
  23904. * Gets the object extend size
  23905. * @returns the object extend size
  23906. */
  23907. getObjectExtendSize(): Vector3;
  23908. /**
  23909. * Gets the object center
  23910. * @returns The object center
  23911. */
  23912. getObjectCenter(): Vector3;
  23913. /**
  23914. * Get a specific parameter from the options parameters
  23915. * @param paramName The object parameter name
  23916. * @returns The object parameter
  23917. */
  23918. getParam(paramName: string): any;
  23919. /**
  23920. * Sets a specific parameter in the options given to the physics plugin
  23921. * @param paramName The parameter name
  23922. * @param value The value of the parameter
  23923. */
  23924. setParam(paramName: string, value: number): void;
  23925. /**
  23926. * Specifically change the body's mass option. Won't recreate the physics body object
  23927. * @param mass The mass of the physics imposter
  23928. */
  23929. setMass(mass: number): void;
  23930. /**
  23931. * Gets the linear velocity
  23932. * @returns linear velocity or null
  23933. */
  23934. getLinearVelocity(): Nullable<Vector3>;
  23935. /**
  23936. * Sets the linear velocity
  23937. * @param velocity linear velocity or null
  23938. */
  23939. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23940. /**
  23941. * Gets the angular velocity
  23942. * @returns angular velocity or null
  23943. */
  23944. getAngularVelocity(): Nullable<Vector3>;
  23945. /**
  23946. * Sets the angular velocity
  23947. * @param velocity The velocity or null
  23948. */
  23949. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23950. /**
  23951. * Execute a function with the physics plugin native code
  23952. * Provide a function the will have two variables - the world object and the physics body object
  23953. * @param func The function to execute with the physics plugin native code
  23954. */
  23955. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23956. /**
  23957. * Register a function that will be executed before the physics world is stepping forward
  23958. * @param func The function to execute before the physics world is stepped forward
  23959. */
  23960. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23961. /**
  23962. * Unregister a function that will be executed before the physics world is stepping forward
  23963. * @param func The function to execute before the physics world is stepped forward
  23964. */
  23965. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23966. /**
  23967. * Register a function that will be executed after the physics step
  23968. * @param func The function to execute after physics step
  23969. */
  23970. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23971. /**
  23972. * Unregisters a function that will be executed after the physics step
  23973. * @param func The function to execute after physics step
  23974. */
  23975. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23976. /**
  23977. * register a function that will be executed when this impostor collides against a different body
  23978. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23979. * @param func Callback that is executed on collision
  23980. */
  23981. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23982. /**
  23983. * Unregisters the physics imposter on contact
  23984. * @param collideAgainst The physics object to collide against
  23985. * @param func Callback to execute on collision
  23986. */
  23987. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23988. private _tmpQuat;
  23989. private _tmpQuat2;
  23990. /**
  23991. * Get the parent rotation
  23992. * @returns The parent rotation
  23993. */
  23994. getParentsRotation(): Quaternion;
  23995. /**
  23996. * this function is executed by the physics engine.
  23997. */
  23998. beforeStep: () => void;
  23999. /**
  24000. * this function is executed by the physics engine
  24001. */
  24002. afterStep: () => void;
  24003. /**
  24004. * Legacy collision detection event support
  24005. */
  24006. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24007. /**
  24008. * event and body object due to cannon's event-based architecture.
  24009. */
  24010. onCollide: (e: {
  24011. body: any;
  24012. }) => void;
  24013. /**
  24014. * Apply a force
  24015. * @param force The force to apply
  24016. * @param contactPoint The contact point for the force
  24017. * @returns The physics imposter
  24018. */
  24019. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24020. /**
  24021. * Apply an impulse
  24022. * @param force The impulse force
  24023. * @param contactPoint The contact point for the impulse force
  24024. * @returns The physics imposter
  24025. */
  24026. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24027. /**
  24028. * A help function to create a joint
  24029. * @param otherImpostor A physics imposter used to create a joint
  24030. * @param jointType The type of joint
  24031. * @param jointData The data for the joint
  24032. * @returns The physics imposter
  24033. */
  24034. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24035. /**
  24036. * Add a joint to this impostor with a different impostor
  24037. * @param otherImpostor A physics imposter used to add a joint
  24038. * @param joint The joint to add
  24039. * @returns The physics imposter
  24040. */
  24041. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24042. /**
  24043. * Add an anchor to a cloth impostor
  24044. * @param otherImpostor rigid impostor to anchor to
  24045. * @param width ratio across width from 0 to 1
  24046. * @param height ratio up height from 0 to 1
  24047. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24048. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24049. * @returns impostor the soft imposter
  24050. */
  24051. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24052. /**
  24053. * Add a hook to a rope impostor
  24054. * @param otherImpostor rigid impostor to anchor to
  24055. * @param length ratio across rope from 0 to 1
  24056. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24057. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24058. * @returns impostor the rope imposter
  24059. */
  24060. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24061. /**
  24062. * Will keep this body still, in a sleep mode.
  24063. * @returns the physics imposter
  24064. */
  24065. sleep(): PhysicsImpostor;
  24066. /**
  24067. * Wake the body up.
  24068. * @returns The physics imposter
  24069. */
  24070. wakeUp(): PhysicsImpostor;
  24071. /**
  24072. * Clones the physics imposter
  24073. * @param newObject The physics imposter clones to this physics-enabled object
  24074. * @returns A nullable physics imposter
  24075. */
  24076. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24077. /**
  24078. * Disposes the physics imposter
  24079. */
  24080. dispose(): void;
  24081. /**
  24082. * Sets the delta position
  24083. * @param position The delta position amount
  24084. */
  24085. setDeltaPosition(position: Vector3): void;
  24086. /**
  24087. * Sets the delta rotation
  24088. * @param rotation The delta rotation amount
  24089. */
  24090. setDeltaRotation(rotation: Quaternion): void;
  24091. /**
  24092. * Gets the box size of the physics imposter and stores the result in the input parameter
  24093. * @param result Stores the box size
  24094. * @returns The physics imposter
  24095. */
  24096. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24097. /**
  24098. * Gets the radius of the physics imposter
  24099. * @returns Radius of the physics imposter
  24100. */
  24101. getRadius(): number;
  24102. /**
  24103. * Sync a bone with this impostor
  24104. * @param bone The bone to sync to the impostor.
  24105. * @param boneMesh The mesh that the bone is influencing.
  24106. * @param jointPivot The pivot of the joint / bone in local space.
  24107. * @param distToJoint Optional distance from the impostor to the joint.
  24108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24109. */
  24110. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24111. /**
  24112. * Sync impostor to a bone
  24113. * @param bone The bone that the impostor will be synced to.
  24114. * @param boneMesh The mesh that the bone is influencing.
  24115. * @param jointPivot The pivot of the joint / bone in local space.
  24116. * @param distToJoint Optional distance from the impostor to the joint.
  24117. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24118. * @param boneAxis Optional vector3 axis the bone is aligned with
  24119. */
  24120. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24121. /**
  24122. * No-Imposter type
  24123. */
  24124. static NoImpostor: number;
  24125. /**
  24126. * Sphere-Imposter type
  24127. */
  24128. static SphereImpostor: number;
  24129. /**
  24130. * Box-Imposter type
  24131. */
  24132. static BoxImpostor: number;
  24133. /**
  24134. * Plane-Imposter type
  24135. */
  24136. static PlaneImpostor: number;
  24137. /**
  24138. * Mesh-imposter type
  24139. */
  24140. static MeshImpostor: number;
  24141. /**
  24142. * Capsule-Impostor type (Ammo.js plugin only)
  24143. */
  24144. static CapsuleImpostor: number;
  24145. /**
  24146. * Cylinder-Imposter type
  24147. */
  24148. static CylinderImpostor: number;
  24149. /**
  24150. * Particle-Imposter type
  24151. */
  24152. static ParticleImpostor: number;
  24153. /**
  24154. * Heightmap-Imposter type
  24155. */
  24156. static HeightmapImpostor: number;
  24157. /**
  24158. * ConvexHull-Impostor type (Ammo.js plugin only)
  24159. */
  24160. static ConvexHullImpostor: number;
  24161. /**
  24162. * Custom-Imposter type (Ammo.js plugin only)
  24163. */
  24164. static CustomImpostor: number;
  24165. /**
  24166. * Rope-Imposter type
  24167. */
  24168. static RopeImpostor: number;
  24169. /**
  24170. * Cloth-Imposter type
  24171. */
  24172. static ClothImpostor: number;
  24173. /**
  24174. * Softbody-Imposter type
  24175. */
  24176. static SoftbodyImpostor: number;
  24177. }
  24178. }
  24179. declare module BABYLON {
  24180. /**
  24181. * @hidden
  24182. **/
  24183. export class _CreationDataStorage {
  24184. closePath?: boolean;
  24185. closeArray?: boolean;
  24186. idx: number[];
  24187. dashSize: number;
  24188. gapSize: number;
  24189. path3D: Path3D;
  24190. pathArray: Vector3[][];
  24191. arc: number;
  24192. radius: number;
  24193. cap: number;
  24194. tessellation: number;
  24195. }
  24196. /**
  24197. * @hidden
  24198. **/
  24199. class _InstanceDataStorage {
  24200. visibleInstances: any;
  24201. batchCache: _InstancesBatch;
  24202. instancesBufferSize: number;
  24203. instancesBuffer: Nullable<Buffer>;
  24204. instancesData: Float32Array;
  24205. overridenInstanceCount: number;
  24206. isFrozen: boolean;
  24207. previousBatch: Nullable<_InstancesBatch>;
  24208. hardwareInstancedRendering: boolean;
  24209. sideOrientation: number;
  24210. manualUpdate: boolean;
  24211. }
  24212. /**
  24213. * @hidden
  24214. **/
  24215. export class _InstancesBatch {
  24216. mustReturn: boolean;
  24217. visibleInstances: Nullable<InstancedMesh[]>[];
  24218. renderSelf: boolean[];
  24219. hardwareInstancedRendering: boolean[];
  24220. }
  24221. /**
  24222. * Class used to represent renderable models
  24223. */
  24224. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24225. /**
  24226. * Mesh side orientation : usually the external or front surface
  24227. */
  24228. static readonly FRONTSIDE: number;
  24229. /**
  24230. * Mesh side orientation : usually the internal or back surface
  24231. */
  24232. static readonly BACKSIDE: number;
  24233. /**
  24234. * Mesh side orientation : both internal and external or front and back surfaces
  24235. */
  24236. static readonly DOUBLESIDE: number;
  24237. /**
  24238. * Mesh side orientation : by default, `FRONTSIDE`
  24239. */
  24240. static readonly DEFAULTSIDE: number;
  24241. /**
  24242. * Mesh cap setting : no cap
  24243. */
  24244. static readonly NO_CAP: number;
  24245. /**
  24246. * Mesh cap setting : one cap at the beginning of the mesh
  24247. */
  24248. static readonly CAP_START: number;
  24249. /**
  24250. * Mesh cap setting : one cap at the end of the mesh
  24251. */
  24252. static readonly CAP_END: number;
  24253. /**
  24254. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24255. */
  24256. static readonly CAP_ALL: number;
  24257. /**
  24258. * Mesh pattern setting : no flip or rotate
  24259. */
  24260. static readonly NO_FLIP: number;
  24261. /**
  24262. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24263. */
  24264. static readonly FLIP_TILE: number;
  24265. /**
  24266. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24267. */
  24268. static readonly ROTATE_TILE: number;
  24269. /**
  24270. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24271. */
  24272. static readonly FLIP_ROW: number;
  24273. /**
  24274. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24275. */
  24276. static readonly ROTATE_ROW: number;
  24277. /**
  24278. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24279. */
  24280. static readonly FLIP_N_ROTATE_TILE: number;
  24281. /**
  24282. * Mesh pattern setting : rotate pattern and rotate
  24283. */
  24284. static readonly FLIP_N_ROTATE_ROW: number;
  24285. /**
  24286. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24287. */
  24288. static readonly CENTER: number;
  24289. /**
  24290. * Mesh tile positioning : part tiles on left
  24291. */
  24292. static readonly LEFT: number;
  24293. /**
  24294. * Mesh tile positioning : part tiles on right
  24295. */
  24296. static readonly RIGHT: number;
  24297. /**
  24298. * Mesh tile positioning : part tiles on top
  24299. */
  24300. static readonly TOP: number;
  24301. /**
  24302. * Mesh tile positioning : part tiles on bottom
  24303. */
  24304. static readonly BOTTOM: number;
  24305. /**
  24306. * Gets the default side orientation.
  24307. * @param orientation the orientation to value to attempt to get
  24308. * @returns the default orientation
  24309. * @hidden
  24310. */
  24311. static _GetDefaultSideOrientation(orientation?: number): number;
  24312. private _internalMeshDataInfo;
  24313. /**
  24314. * An event triggered before rendering the mesh
  24315. */
  24316. get onBeforeRenderObservable(): Observable<Mesh>;
  24317. /**
  24318. * An event triggered before binding the mesh
  24319. */
  24320. get onBeforeBindObservable(): Observable<Mesh>;
  24321. /**
  24322. * An event triggered after rendering the mesh
  24323. */
  24324. get onAfterRenderObservable(): Observable<Mesh>;
  24325. /**
  24326. * An event triggered before drawing the mesh
  24327. */
  24328. get onBeforeDrawObservable(): Observable<Mesh>;
  24329. private _onBeforeDrawObserver;
  24330. /**
  24331. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24332. */
  24333. set onBeforeDraw(callback: () => void);
  24334. get hasInstances(): boolean;
  24335. /**
  24336. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24337. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24338. */
  24339. delayLoadState: number;
  24340. /**
  24341. * Gets the list of instances created from this mesh
  24342. * it is not supposed to be modified manually.
  24343. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24344. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24345. */
  24346. instances: InstancedMesh[];
  24347. /**
  24348. * Gets the file containing delay loading data for this mesh
  24349. */
  24350. delayLoadingFile: string;
  24351. /** @hidden */
  24352. _binaryInfo: any;
  24353. /**
  24354. * User defined function used to change how LOD level selection is done
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24356. */
  24357. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24358. /**
  24359. * Gets or sets the morph target manager
  24360. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24361. */
  24362. get morphTargetManager(): Nullable<MorphTargetManager>;
  24363. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24364. /** @hidden */
  24365. _creationDataStorage: Nullable<_CreationDataStorage>;
  24366. /** @hidden */
  24367. _geometry: Nullable<Geometry>;
  24368. /** @hidden */
  24369. _delayInfo: Array<string>;
  24370. /** @hidden */
  24371. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24372. /** @hidden */
  24373. _instanceDataStorage: _InstanceDataStorage;
  24374. private _effectiveMaterial;
  24375. /** @hidden */
  24376. _shouldGenerateFlatShading: boolean;
  24377. /** @hidden */
  24378. _originalBuilderSideOrientation: number;
  24379. /**
  24380. * Use this property to change the original side orientation defined at construction time
  24381. */
  24382. overrideMaterialSideOrientation: Nullable<number>;
  24383. /**
  24384. * Gets the source mesh (the one used to clone this one from)
  24385. */
  24386. get source(): Nullable<Mesh>;
  24387. /**
  24388. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24389. */
  24390. get isUnIndexed(): boolean;
  24391. set isUnIndexed(value: boolean);
  24392. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24393. get worldMatrixInstancedBuffer(): Float32Array;
  24394. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24395. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24396. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24397. /**
  24398. * @constructor
  24399. * @param name The value used by scene.getMeshByName() to do a lookup.
  24400. * @param scene The scene to add this mesh to.
  24401. * @param parent The parent of this mesh, if it has one
  24402. * @param source An optional Mesh from which geometry is shared, cloned.
  24403. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24404. * When false, achieved by calling a clone(), also passing False.
  24405. * This will make creation of children, recursive.
  24406. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24407. */
  24408. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24409. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24410. doNotInstantiate: boolean;
  24411. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24412. /**
  24413. * Gets the class name
  24414. * @returns the string "Mesh".
  24415. */
  24416. getClassName(): string;
  24417. /** @hidden */
  24418. get _isMesh(): boolean;
  24419. /**
  24420. * Returns a description of this mesh
  24421. * @param fullDetails define if full details about this mesh must be used
  24422. * @returns a descriptive string representing this mesh
  24423. */
  24424. toString(fullDetails?: boolean): string;
  24425. /** @hidden */
  24426. _unBindEffect(): void;
  24427. /**
  24428. * Gets a boolean indicating if this mesh has LOD
  24429. */
  24430. get hasLODLevels(): boolean;
  24431. /**
  24432. * Gets the list of MeshLODLevel associated with the current mesh
  24433. * @returns an array of MeshLODLevel
  24434. */
  24435. getLODLevels(): MeshLODLevel[];
  24436. private _sortLODLevels;
  24437. /**
  24438. * Add a mesh as LOD level triggered at the given distance.
  24439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24440. * @param distance The distance from the center of the object to show this level
  24441. * @param mesh The mesh to be added as LOD level (can be null)
  24442. * @return This mesh (for chaining)
  24443. */
  24444. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24445. /**
  24446. * Returns the LOD level mesh at the passed distance or null if not found.
  24447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24448. * @param distance The distance from the center of the object to show this level
  24449. * @returns a Mesh or `null`
  24450. */
  24451. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24452. /**
  24453. * Remove a mesh from the LOD array
  24454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24455. * @param mesh defines the mesh to be removed
  24456. * @return This mesh (for chaining)
  24457. */
  24458. removeLODLevel(mesh: Mesh): Mesh;
  24459. /**
  24460. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24462. * @param camera defines the camera to use to compute distance
  24463. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24464. * @return This mesh (for chaining)
  24465. */
  24466. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24467. /**
  24468. * Gets the mesh internal Geometry object
  24469. */
  24470. get geometry(): Nullable<Geometry>;
  24471. /**
  24472. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24473. * @returns the total number of vertices
  24474. */
  24475. getTotalVertices(): number;
  24476. /**
  24477. * Returns the content of an associated vertex buffer
  24478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24479. * - VertexBuffer.PositionKind
  24480. * - VertexBuffer.UVKind
  24481. * - VertexBuffer.UV2Kind
  24482. * - VertexBuffer.UV3Kind
  24483. * - VertexBuffer.UV4Kind
  24484. * - VertexBuffer.UV5Kind
  24485. * - VertexBuffer.UV6Kind
  24486. * - VertexBuffer.ColorKind
  24487. * - VertexBuffer.MatricesIndicesKind
  24488. * - VertexBuffer.MatricesIndicesExtraKind
  24489. * - VertexBuffer.MatricesWeightsKind
  24490. * - VertexBuffer.MatricesWeightsExtraKind
  24491. * @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
  24492. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24493. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24494. */
  24495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24496. /**
  24497. * Returns the mesh VertexBuffer object from the requested `kind`
  24498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24499. * - VertexBuffer.PositionKind
  24500. * - VertexBuffer.NormalKind
  24501. * - VertexBuffer.UVKind
  24502. * - VertexBuffer.UV2Kind
  24503. * - VertexBuffer.UV3Kind
  24504. * - VertexBuffer.UV4Kind
  24505. * - VertexBuffer.UV5Kind
  24506. * - VertexBuffer.UV6Kind
  24507. * - VertexBuffer.ColorKind
  24508. * - VertexBuffer.MatricesIndicesKind
  24509. * - VertexBuffer.MatricesIndicesExtraKind
  24510. * - VertexBuffer.MatricesWeightsKind
  24511. * - VertexBuffer.MatricesWeightsExtraKind
  24512. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24513. */
  24514. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24515. /**
  24516. * Tests if a specific vertex buffer is associated with this mesh
  24517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24518. * - VertexBuffer.PositionKind
  24519. * - VertexBuffer.NormalKind
  24520. * - VertexBuffer.UVKind
  24521. * - VertexBuffer.UV2Kind
  24522. * - VertexBuffer.UV3Kind
  24523. * - VertexBuffer.UV4Kind
  24524. * - VertexBuffer.UV5Kind
  24525. * - VertexBuffer.UV6Kind
  24526. * - VertexBuffer.ColorKind
  24527. * - VertexBuffer.MatricesIndicesKind
  24528. * - VertexBuffer.MatricesIndicesExtraKind
  24529. * - VertexBuffer.MatricesWeightsKind
  24530. * - VertexBuffer.MatricesWeightsExtraKind
  24531. * @returns a boolean
  24532. */
  24533. isVerticesDataPresent(kind: string): boolean;
  24534. /**
  24535. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @returns a boolean
  24550. */
  24551. isVertexBufferUpdatable(kind: string): boolean;
  24552. /**
  24553. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.NormalKind
  24557. * - VertexBuffer.UVKind
  24558. * - VertexBuffer.UV2Kind
  24559. * - VertexBuffer.UV3Kind
  24560. * - VertexBuffer.UV4Kind
  24561. * - VertexBuffer.UV5Kind
  24562. * - VertexBuffer.UV6Kind
  24563. * - VertexBuffer.ColorKind
  24564. * - VertexBuffer.MatricesIndicesKind
  24565. * - VertexBuffer.MatricesIndicesExtraKind
  24566. * - VertexBuffer.MatricesWeightsKind
  24567. * - VertexBuffer.MatricesWeightsExtraKind
  24568. * @returns an array of strings
  24569. */
  24570. getVerticesDataKinds(): string[];
  24571. /**
  24572. * Returns a positive integer : the total number of indices in this mesh geometry.
  24573. * @returns the numner of indices or zero if the mesh has no geometry.
  24574. */
  24575. getTotalIndices(): number;
  24576. /**
  24577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24578. * @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.
  24579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24580. * @returns the indices array or an empty array if the mesh has no geometry
  24581. */
  24582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24583. get isBlocked(): boolean;
  24584. /**
  24585. * Determine if the current mesh is ready to be rendered
  24586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24587. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24588. * @returns true if all associated assets are ready (material, textures, shaders)
  24589. */
  24590. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24591. /**
  24592. * 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.
  24593. */
  24594. get areNormalsFrozen(): boolean;
  24595. /**
  24596. * 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.
  24597. * @returns the current mesh
  24598. */
  24599. freezeNormals(): Mesh;
  24600. /**
  24601. * 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
  24602. * @returns the current mesh
  24603. */
  24604. unfreezeNormals(): Mesh;
  24605. /**
  24606. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24607. */
  24608. set overridenInstanceCount(count: number);
  24609. /** @hidden */
  24610. _preActivate(): Mesh;
  24611. /** @hidden */
  24612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24613. /** @hidden */
  24614. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24615. /**
  24616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24617. * This means the mesh underlying bounding box and sphere are recomputed.
  24618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24619. * @returns the current mesh
  24620. */
  24621. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24622. /** @hidden */
  24623. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24624. /**
  24625. * This function will subdivide the mesh into multiple submeshes
  24626. * @param count defines the expected number of submeshes
  24627. */
  24628. subdivide(count: number): void;
  24629. /**
  24630. * Copy a FloatArray into a specific associated vertex buffer
  24631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24632. * - VertexBuffer.PositionKind
  24633. * - VertexBuffer.UVKind
  24634. * - VertexBuffer.UV2Kind
  24635. * - VertexBuffer.UV3Kind
  24636. * - VertexBuffer.UV4Kind
  24637. * - VertexBuffer.UV5Kind
  24638. * - VertexBuffer.UV6Kind
  24639. * - VertexBuffer.ColorKind
  24640. * - VertexBuffer.MatricesIndicesKind
  24641. * - VertexBuffer.MatricesIndicesExtraKind
  24642. * - VertexBuffer.MatricesWeightsKind
  24643. * - VertexBuffer.MatricesWeightsExtraKind
  24644. * @param data defines the data source
  24645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24646. * @param stride defines the data stride size (can be null)
  24647. * @returns the current mesh
  24648. */
  24649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24650. /**
  24651. * Delete a vertex buffer associated with this mesh
  24652. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24653. * - VertexBuffer.PositionKind
  24654. * - VertexBuffer.UVKind
  24655. * - VertexBuffer.UV2Kind
  24656. * - VertexBuffer.UV3Kind
  24657. * - VertexBuffer.UV4Kind
  24658. * - VertexBuffer.UV5Kind
  24659. * - VertexBuffer.UV6Kind
  24660. * - VertexBuffer.ColorKind
  24661. * - VertexBuffer.MatricesIndicesKind
  24662. * - VertexBuffer.MatricesIndicesExtraKind
  24663. * - VertexBuffer.MatricesWeightsKind
  24664. * - VertexBuffer.MatricesWeightsExtraKind
  24665. */
  24666. removeVerticesData(kind: string): void;
  24667. /**
  24668. * Flags an associated vertex buffer as updatable
  24669. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24670. * - VertexBuffer.PositionKind
  24671. * - VertexBuffer.UVKind
  24672. * - VertexBuffer.UV2Kind
  24673. * - VertexBuffer.UV3Kind
  24674. * - VertexBuffer.UV4Kind
  24675. * - VertexBuffer.UV5Kind
  24676. * - VertexBuffer.UV6Kind
  24677. * - VertexBuffer.ColorKind
  24678. * - VertexBuffer.MatricesIndicesKind
  24679. * - VertexBuffer.MatricesIndicesExtraKind
  24680. * - VertexBuffer.MatricesWeightsKind
  24681. * - VertexBuffer.MatricesWeightsExtraKind
  24682. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24683. */
  24684. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24685. /**
  24686. * Sets the mesh global Vertex Buffer
  24687. * @param buffer defines the buffer to use
  24688. * @returns the current mesh
  24689. */
  24690. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24691. /**
  24692. * Update a specific associated vertex buffer
  24693. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24694. * - VertexBuffer.PositionKind
  24695. * - VertexBuffer.UVKind
  24696. * - VertexBuffer.UV2Kind
  24697. * - VertexBuffer.UV3Kind
  24698. * - VertexBuffer.UV4Kind
  24699. * - VertexBuffer.UV5Kind
  24700. * - VertexBuffer.UV6Kind
  24701. * - VertexBuffer.ColorKind
  24702. * - VertexBuffer.MatricesIndicesKind
  24703. * - VertexBuffer.MatricesIndicesExtraKind
  24704. * - VertexBuffer.MatricesWeightsKind
  24705. * - VertexBuffer.MatricesWeightsExtraKind
  24706. * @param data defines the data source
  24707. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24708. * @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)
  24709. * @returns the current mesh
  24710. */
  24711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24712. /**
  24713. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24714. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24715. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24716. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24717. * @returns the current mesh
  24718. */
  24719. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24720. /**
  24721. * Creates a un-shared specific occurence of the geometry for the mesh.
  24722. * @returns the current mesh
  24723. */
  24724. makeGeometryUnique(): Mesh;
  24725. /**
  24726. * Set the index buffer of this mesh
  24727. * @param indices defines the source data
  24728. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24729. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24730. * @returns the current mesh
  24731. */
  24732. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24733. /**
  24734. * Update the current index buffer
  24735. * @param indices defines the source data
  24736. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24737. * @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)
  24738. * @returns the current mesh
  24739. */
  24740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24741. /**
  24742. * Invert the geometry to move from a right handed system to a left handed one.
  24743. * @returns the current mesh
  24744. */
  24745. toLeftHanded(): Mesh;
  24746. /** @hidden */
  24747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24748. /** @hidden */
  24749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24750. /**
  24751. * Registers for this mesh a javascript function called just before the rendering process
  24752. * @param func defines the function to call before rendering this mesh
  24753. * @returns the current mesh
  24754. */
  24755. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24756. /**
  24757. * Disposes a previously registered javascript function called before the rendering
  24758. * @param func defines the function to remove
  24759. * @returns the current mesh
  24760. */
  24761. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24762. /**
  24763. * Registers for this mesh a javascript function called just after the rendering is complete
  24764. * @param func defines the function to call after rendering this mesh
  24765. * @returns the current mesh
  24766. */
  24767. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24768. /**
  24769. * Disposes a previously registered javascript function called after the rendering.
  24770. * @param func defines the function to remove
  24771. * @returns the current mesh
  24772. */
  24773. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24774. /** @hidden */
  24775. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24776. /** @hidden */
  24777. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24778. /** @hidden */
  24779. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24780. /** @hidden */
  24781. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24782. /** @hidden */
  24783. _rebuild(): void;
  24784. /** @hidden */
  24785. _freeze(): void;
  24786. /** @hidden */
  24787. _unFreeze(): void;
  24788. /**
  24789. * 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
  24790. * @param subMesh defines the subMesh to render
  24791. * @param enableAlphaMode defines if alpha mode can be changed
  24792. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24793. * @returns the current mesh
  24794. */
  24795. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24796. private _onBeforeDraw;
  24797. /**
  24798. * Renormalize the mesh and patch it up if there are no weights
  24799. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24800. * However in the case of zero weights then we set just a single influence to 1.
  24801. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24802. */
  24803. cleanMatrixWeights(): void;
  24804. private normalizeSkinFourWeights;
  24805. private normalizeSkinWeightsAndExtra;
  24806. /**
  24807. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24808. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24809. * the user know there was an issue with importing the mesh
  24810. * @returns a validation object with skinned, valid and report string
  24811. */
  24812. validateSkinning(): {
  24813. skinned: boolean;
  24814. valid: boolean;
  24815. report: string;
  24816. };
  24817. /** @hidden */
  24818. _checkDelayState(): Mesh;
  24819. private _queueLoad;
  24820. /**
  24821. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24822. * A mesh is in the frustum if its bounding box intersects the frustum
  24823. * @param frustumPlanes defines the frustum to test
  24824. * @returns true if the mesh is in the frustum planes
  24825. */
  24826. isInFrustum(frustumPlanes: Plane[]): boolean;
  24827. /**
  24828. * Sets the mesh material by the material or multiMaterial `id` property
  24829. * @param id is a string identifying the material or the multiMaterial
  24830. * @returns the current mesh
  24831. */
  24832. setMaterialByID(id: string): Mesh;
  24833. /**
  24834. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24835. * @returns an array of IAnimatable
  24836. */
  24837. getAnimatables(): IAnimatable[];
  24838. /**
  24839. * Modifies the mesh geometry according to the passed transformation matrix.
  24840. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24841. * The mesh normals are modified using the same transformation.
  24842. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24843. * @param transform defines the transform matrix to use
  24844. * @see http://doc.babylonjs.com/resources/baking_transformations
  24845. * @returns the current mesh
  24846. */
  24847. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24848. /**
  24849. * Modifies the mesh geometry according to its own current World Matrix.
  24850. * The mesh World Matrix is then reset.
  24851. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24852. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24853. * @see http://doc.babylonjs.com/resources/baking_transformations
  24854. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24855. * @returns the current mesh
  24856. */
  24857. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24858. /** @hidden */
  24859. get _positions(): Nullable<Vector3[]>;
  24860. /** @hidden */
  24861. _resetPointsArrayCache(): Mesh;
  24862. /** @hidden */
  24863. _generatePointsArray(): boolean;
  24864. /**
  24865. * Returns a new Mesh object generated from the current mesh properties.
  24866. * This method must not get confused with createInstance()
  24867. * @param name is a string, the name given to the new mesh
  24868. * @param newParent can be any Node object (default `null`)
  24869. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24870. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24871. * @returns a new mesh
  24872. */
  24873. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24874. /**
  24875. * Releases resources associated with this mesh.
  24876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24878. */
  24879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24880. /** @hidden */
  24881. _disposeInstanceSpecificData(): void;
  24882. /**
  24883. * Modifies the mesh geometry according to a displacement map.
  24884. * 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.
  24885. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24886. * @param url is a string, the URL from the image file is to be downloaded.
  24887. * @param minHeight is the lower limit of the displacement.
  24888. * @param maxHeight is the upper limit of the displacement.
  24889. * @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.
  24890. * @param uvOffset is an optional vector2 used to offset UV.
  24891. * @param uvScale is an optional vector2 used to scale UV.
  24892. * @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.
  24893. * @returns the Mesh.
  24894. */
  24895. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24896. /**
  24897. * Modifies the mesh geometry according to a displacementMap buffer.
  24898. * 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.
  24899. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24900. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24901. * @param heightMapWidth is the width of the buffer image.
  24902. * @param heightMapHeight is the height of the buffer image.
  24903. * @param minHeight is the lower limit of the displacement.
  24904. * @param maxHeight is the upper limit of the displacement.
  24905. * @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.
  24906. * @param uvOffset is an optional vector2 used to offset UV.
  24907. * @param uvScale is an optional vector2 used to scale UV.
  24908. * @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.
  24909. * @returns the Mesh.
  24910. */
  24911. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24912. /**
  24913. * Modify the mesh to get a flat shading rendering.
  24914. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24915. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24916. * @returns current mesh
  24917. */
  24918. convertToFlatShadedMesh(): Mesh;
  24919. /**
  24920. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24921. * In other words, more vertices, no more indices and a single bigger VBO.
  24922. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24923. * @returns current mesh
  24924. */
  24925. convertToUnIndexedMesh(): Mesh;
  24926. /**
  24927. * Inverses facet orientations.
  24928. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24929. * @param flipNormals will also inverts the normals
  24930. * @returns current mesh
  24931. */
  24932. flipFaces(flipNormals?: boolean): Mesh;
  24933. /**
  24934. * Increase the number of facets and hence vertices in a mesh
  24935. * Vertex normals are interpolated from existing vertex normals
  24936. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24937. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24938. */
  24939. increaseVertices(numberPerEdge: number): void;
  24940. /**
  24941. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24942. * This will undo any application of covertToFlatShadedMesh
  24943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24944. */
  24945. forceSharedVertices(): void;
  24946. /** @hidden */
  24947. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24948. /** @hidden */
  24949. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24950. /**
  24951. * Creates a new InstancedMesh object from the mesh model.
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24953. * @param name defines the name of the new instance
  24954. * @returns a new InstancedMesh
  24955. */
  24956. createInstance(name: string): InstancedMesh;
  24957. /**
  24958. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24959. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24960. * @returns the current mesh
  24961. */
  24962. synchronizeInstances(): Mesh;
  24963. /**
  24964. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24965. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24966. * This should be used together with the simplification to avoid disappearing triangles.
  24967. * @param successCallback an optional success callback to be called after the optimization finished.
  24968. * @returns the current mesh
  24969. */
  24970. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24971. /**
  24972. * Serialize current mesh
  24973. * @param serializationObject defines the object which will receive the serialization data
  24974. */
  24975. serialize(serializationObject: any): void;
  24976. /** @hidden */
  24977. _syncGeometryWithMorphTargetManager(): void;
  24978. /** @hidden */
  24979. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24980. /**
  24981. * Returns a new Mesh object parsed from the source provided.
  24982. * @param parsedMesh is the source
  24983. * @param scene defines the hosting scene
  24984. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24985. * @returns a new Mesh
  24986. */
  24987. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24988. /**
  24989. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24991. * @param name defines the name of the mesh to create
  24992. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24993. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24994. * @param closePath creates a seam between the first and the last points of each path of the path array
  24995. * @param offset is taken in account only if the `pathArray` is containing a single path
  24996. * @param scene defines the hosting scene
  24997. * @param updatable defines if the mesh must be flagged as updatable
  24998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24999. * @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)
  25000. * @returns a new Mesh
  25001. */
  25002. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25003. /**
  25004. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25005. * @param name defines the name of the mesh to create
  25006. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25007. * @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
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25014. /**
  25015. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25016. * @param name defines the name of the mesh to create
  25017. * @param size sets the size (float) of each box side (default 1)
  25018. * @param scene defines the hosting scene
  25019. * @param updatable defines if the mesh must be flagged as updatable
  25020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25021. * @returns a new Mesh
  25022. */
  25023. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25024. /**
  25025. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25026. * @param name defines the name of the mesh to create
  25027. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25028. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25035. /**
  25036. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25039. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25040. * @param scene defines the hosting scene
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25044. /**
  25045. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  25048. * @param diameterTop set the top cap diameter (floats, default 1)
  25049. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25050. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25051. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param diameter sets the diameter size (float) of the torus (default 1)
  25062. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25063. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25064. * @param scene defines the hosting scene
  25065. * @param updatable defines if the mesh must be flagged as updatable
  25066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25067. * @returns a new Mesh
  25068. */
  25069. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25070. /**
  25071. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25072. * @param name defines the name of the mesh to create
  25073. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25074. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25075. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25076. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25077. * @param p the number of windings on X axis (positive integers, default 2)
  25078. * @param q the number of windings on Y axis (positive integers, default 3)
  25079. * @param scene defines the hosting scene
  25080. * @param updatable defines if the mesh must be flagged as updatable
  25081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25082. * @returns a new Mesh
  25083. */
  25084. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25085. /**
  25086. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25087. * @param name defines the name of the mesh to create
  25088. * @param points is an array successive Vector3
  25089. * @param scene defines the hosting scene
  25090. * @param updatable defines if the mesh must be flagged as updatable
  25091. * @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).
  25092. * @returns a new Mesh
  25093. */
  25094. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25095. /**
  25096. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25097. * @param name defines the name of the mesh to create
  25098. * @param points is an array successive Vector3
  25099. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25100. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25101. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @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)
  25105. * @returns a new Mesh
  25106. */
  25107. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25108. /**
  25109. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25110. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25111. * 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.
  25112. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25113. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25114. * Remember you can only change the shape positions, not their number when updating a polygon.
  25115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25116. * @param name defines the name of the mesh to create
  25117. * @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
  25118. * @param scene defines the hosting scene
  25119. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25120. * @param updatable defines if the mesh must be flagged as updatable
  25121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25122. * @param earcutInjection can be used to inject your own earcut reference
  25123. * @returns a new Mesh
  25124. */
  25125. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25126. /**
  25127. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25128. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25129. * @param name defines the name of the mesh to create
  25130. * @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
  25131. * @param depth defines the height of extrusion
  25132. * @param scene defines the hosting scene
  25133. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25136. * @param earcutInjection can be used to inject your own earcut reference
  25137. * @returns a new Mesh
  25138. */
  25139. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25140. /**
  25141. * Creates an extruded shape mesh.
  25142. * 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
  25143. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25144. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25145. * @param name defines the name of the mesh to create
  25146. * @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
  25147. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25148. * @param scale is the value to scale the shape
  25149. * @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
  25150. * @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
  25151. * @param scene defines the hosting scene
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @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)
  25155. * @returns a new Mesh
  25156. */
  25157. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25158. /**
  25159. * Creates an custom extruded shape mesh.
  25160. * The custom extrusion is a parametric shape.
  25161. * It has no predefined shape. Its final shape will depend on the input parameters.
  25162. * Please consider using the same method from the MeshBuilder class instead
  25163. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25164. * @param name defines the name of the mesh to create
  25165. * @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
  25166. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25167. * @param scaleFunction is a custom Javascript function called on each path point
  25168. * @param rotationFunction is a custom Javascript function called on each path point
  25169. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25170. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @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)
  25176. * @returns a new Mesh
  25177. */
  25178. 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;
  25179. /**
  25180. * Creates lathe mesh.
  25181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25182. * Please consider using the same method from the MeshBuilder class instead
  25183. * @param name defines the name of the mesh to create
  25184. * @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
  25185. * @param radius is the radius value of the lathe
  25186. * @param tessellation is the side number of the lathe.
  25187. * @param scene defines the hosting scene
  25188. * @param updatable defines if the mesh must be flagged as updatable
  25189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25190. * @returns a new Mesh
  25191. */
  25192. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25193. /**
  25194. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25195. * @param name defines the name of the mesh to create
  25196. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25197. * @param scene defines the hosting scene
  25198. * @param updatable defines if the mesh must be flagged as updatable
  25199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25200. * @returns a new Mesh
  25201. */
  25202. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25203. /**
  25204. * Creates a ground mesh.
  25205. * Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param width set the width of the ground
  25208. * @param height set the height of the ground
  25209. * @param subdivisions sets the number of subdivisions per side
  25210. * @param scene defines the hosting scene
  25211. * @param updatable defines if the mesh must be flagged as updatable
  25212. * @returns a new Mesh
  25213. */
  25214. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25215. /**
  25216. * Creates a tiled ground mesh.
  25217. * Please consider using the same method from the MeshBuilder class instead
  25218. * @param name defines the name of the mesh to create
  25219. * @param xmin set the ground minimum X coordinate
  25220. * @param zmin set the ground minimum Y coordinate
  25221. * @param xmax set the ground maximum X coordinate
  25222. * @param zmax set the ground maximum Z coordinate
  25223. * @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
  25224. * @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
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @returns a new Mesh
  25228. */
  25229. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25230. w: number;
  25231. h: number;
  25232. }, precision: {
  25233. w: number;
  25234. h: number;
  25235. }, scene: Scene, updatable?: boolean): Mesh;
  25236. /**
  25237. * Creates a ground mesh from a height map.
  25238. * Please consider using the same method from the MeshBuilder class instead
  25239. * @see http://doc.babylonjs.com/babylon101/height_map
  25240. * @param name defines the name of the mesh to create
  25241. * @param url sets the URL of the height map image resource
  25242. * @param width set the ground width size
  25243. * @param height set the ground height size
  25244. * @param subdivisions sets the number of subdivision per side
  25245. * @param minHeight is the minimum altitude on the ground
  25246. * @param maxHeight is the maximum altitude on the ground
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25250. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25251. * @returns a new Mesh
  25252. */
  25253. 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;
  25254. /**
  25255. * Creates a tube mesh.
  25256. * The tube is a parametric shape.
  25257. * It has no predefined shape. Its final shape will depend on the input parameters.
  25258. * Please consider using the same method from the MeshBuilder class instead
  25259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25260. * @param name defines the name of the mesh to create
  25261. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25262. * @param radius sets the tube radius size
  25263. * @param tessellation is the number of sides on the tubular surface
  25264. * @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
  25265. * @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
  25266. * @param scene defines the hosting scene
  25267. * @param updatable defines if the mesh must be flagged as updatable
  25268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25269. * @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)
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25273. (i: number, distance: number): number;
  25274. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25275. /**
  25276. * Creates a polyhedron mesh.
  25277. * Please consider using the same method from the MeshBuilder class instead.
  25278. * * 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
  25279. * * The parameter `size` (positive float, default 1) sets the polygon size
  25280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25281. * * 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`
  25282. * * 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
  25283. * * 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)`)
  25284. * * 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
  25285. * * 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
  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 to create
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. */
  25294. static CreatePolyhedron(name: string, options: {
  25295. type?: number;
  25296. size?: number;
  25297. sizeX?: number;
  25298. sizeY?: number;
  25299. sizeZ?: number;
  25300. custom?: any;
  25301. faceUV?: Vector4[];
  25302. faceColors?: Color4[];
  25303. updatable?: boolean;
  25304. sideOrientation?: number;
  25305. }, scene: Scene): Mesh;
  25306. /**
  25307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25309. * * 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`)
  25310. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25311. * * 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
  25312. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25313. * * 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
  25314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25315. * @param name defines the name of the mesh
  25316. * @param options defines the options used to create the mesh
  25317. * @param scene defines the hosting scene
  25318. * @returns a new Mesh
  25319. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25320. */
  25321. static CreateIcoSphere(name: string, options: {
  25322. radius?: number;
  25323. flat?: boolean;
  25324. subdivisions?: number;
  25325. sideOrientation?: number;
  25326. updatable?: boolean;
  25327. }, scene: Scene): Mesh;
  25328. /**
  25329. * Creates a decal mesh.
  25330. * Please consider using the same method from the MeshBuilder class instead.
  25331. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25332. * @param name defines the name of the mesh
  25333. * @param sourceMesh defines the mesh receiving the decal
  25334. * @param position sets the position of the decal in world coordinates
  25335. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25336. * @param size sets the decal scaling
  25337. * @param angle sets the angle to rotate the decal
  25338. * @returns a new Mesh
  25339. */
  25340. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25341. /**
  25342. * Prepare internal position array for software CPU skinning
  25343. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25344. */
  25345. setPositionsForCPUSkinning(): Float32Array;
  25346. /**
  25347. * Prepare internal normal array for software CPU skinning
  25348. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25349. */
  25350. setNormalsForCPUSkinning(): Float32Array;
  25351. /**
  25352. * Updates the vertex buffer by applying transformation from the bones
  25353. * @param skeleton defines the skeleton to apply to current mesh
  25354. * @returns the current mesh
  25355. */
  25356. applySkeleton(skeleton: Skeleton): Mesh;
  25357. /**
  25358. * 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
  25359. * @param meshes defines the list of meshes to scan
  25360. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25361. */
  25362. static MinMax(meshes: AbstractMesh[]): {
  25363. min: Vector3;
  25364. max: Vector3;
  25365. };
  25366. /**
  25367. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25368. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25369. * @returns a vector3
  25370. */
  25371. static Center(meshesOrMinMaxVector: {
  25372. min: Vector3;
  25373. max: Vector3;
  25374. } | AbstractMesh[]): Vector3;
  25375. /**
  25376. * Merge the array of meshes into a single mesh for performance reasons.
  25377. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25378. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25379. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25380. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25381. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25382. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25383. * @returns a new mesh
  25384. */
  25385. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25386. /** @hidden */
  25387. addInstance(instance: InstancedMesh): void;
  25388. /** @hidden */
  25389. removeInstance(instance: InstancedMesh): void;
  25390. }
  25391. }
  25392. declare module BABYLON {
  25393. /**
  25394. * This is the base class of all the camera used in the application.
  25395. * @see http://doc.babylonjs.com/features/cameras
  25396. */
  25397. export class Camera extends Node {
  25398. /** @hidden */
  25399. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25400. /**
  25401. * This is the default projection mode used by the cameras.
  25402. * It helps recreating a feeling of perspective and better appreciate depth.
  25403. * This is the best way to simulate real life cameras.
  25404. */
  25405. static readonly PERSPECTIVE_CAMERA: number;
  25406. /**
  25407. * This helps creating camera with an orthographic mode.
  25408. * 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.
  25409. */
  25410. static readonly ORTHOGRAPHIC_CAMERA: number;
  25411. /**
  25412. * This is the default FOV mode for perspective cameras.
  25413. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25414. */
  25415. static readonly FOVMODE_VERTICAL_FIXED: number;
  25416. /**
  25417. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25418. */
  25419. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25420. /**
  25421. * This specifies ther is no need for a camera rig.
  25422. * Basically only one eye is rendered corresponding to the camera.
  25423. */
  25424. static readonly RIG_MODE_NONE: number;
  25425. /**
  25426. * Simulates a camera Rig with one blue eye and one red eye.
  25427. * This can be use with 3d blue and red glasses.
  25428. */
  25429. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25430. /**
  25431. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25432. */
  25433. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25434. /**
  25435. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25436. */
  25437. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25438. /**
  25439. * Defines that both eyes of the camera will be rendered over under each other.
  25440. */
  25441. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25442. /**
  25443. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25444. */
  25445. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25446. /**
  25447. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25448. */
  25449. static readonly RIG_MODE_VR: number;
  25450. /**
  25451. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25452. */
  25453. static readonly RIG_MODE_WEBVR: number;
  25454. /**
  25455. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25456. */
  25457. static readonly RIG_MODE_CUSTOM: number;
  25458. /**
  25459. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25460. */
  25461. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25462. /**
  25463. * Define the input manager associated with the camera.
  25464. */
  25465. inputs: CameraInputsManager<Camera>;
  25466. /** @hidden */
  25467. _position: Vector3;
  25468. /**
  25469. * Define the current local position of the camera in the scene
  25470. */
  25471. get position(): Vector3;
  25472. set position(newPosition: Vector3);
  25473. /**
  25474. * The vector the camera should consider as up.
  25475. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25476. */
  25477. upVector: Vector3;
  25478. /**
  25479. * Define the current limit on the left side for an orthographic camera
  25480. * In scene unit
  25481. */
  25482. orthoLeft: Nullable<number>;
  25483. /**
  25484. * Define the current limit on the right side for an orthographic camera
  25485. * In scene unit
  25486. */
  25487. orthoRight: Nullable<number>;
  25488. /**
  25489. * Define the current limit on the bottom side for an orthographic camera
  25490. * In scene unit
  25491. */
  25492. orthoBottom: Nullable<number>;
  25493. /**
  25494. * Define the current limit on the top side for an orthographic camera
  25495. * In scene unit
  25496. */
  25497. orthoTop: Nullable<number>;
  25498. /**
  25499. * Field Of View is set in Radians. (default is 0.8)
  25500. */
  25501. fov: number;
  25502. /**
  25503. * Define the minimum distance the camera can see from.
  25504. * This is important to note that the depth buffer are not infinite and the closer it starts
  25505. * the more your scene might encounter depth fighting issue.
  25506. */
  25507. minZ: number;
  25508. /**
  25509. * Define the maximum distance the camera can see to.
  25510. * This is important to note that the depth buffer are not infinite and the further it end
  25511. * the more your scene might encounter depth fighting issue.
  25512. */
  25513. maxZ: number;
  25514. /**
  25515. * Define the default inertia of the camera.
  25516. * This helps giving a smooth feeling to the camera movement.
  25517. */
  25518. inertia: number;
  25519. /**
  25520. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25521. */
  25522. mode: number;
  25523. /**
  25524. * Define whether the camera is intermediate.
  25525. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25526. */
  25527. isIntermediate: boolean;
  25528. /**
  25529. * Define the viewport of the camera.
  25530. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25531. */
  25532. viewport: Viewport;
  25533. /**
  25534. * Restricts the camera to viewing objects with the same layerMask.
  25535. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25536. */
  25537. layerMask: number;
  25538. /**
  25539. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25540. */
  25541. fovMode: number;
  25542. /**
  25543. * Rig mode of the camera.
  25544. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25545. * This is normally controlled byt the camera themselves as internal use.
  25546. */
  25547. cameraRigMode: number;
  25548. /**
  25549. * Defines the distance between both "eyes" in case of a RIG
  25550. */
  25551. interaxialDistance: number;
  25552. /**
  25553. * Defines if stereoscopic rendering is done side by side or over under.
  25554. */
  25555. isStereoscopicSideBySide: boolean;
  25556. /**
  25557. * 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
  25558. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25559. * else in the scene. (Eg. security camera)
  25560. *
  25561. * 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)
  25562. */
  25563. customRenderTargets: RenderTargetTexture[];
  25564. /**
  25565. * When set, the camera will render to this render target instead of the default canvas
  25566. *
  25567. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25568. */
  25569. outputRenderTarget: Nullable<RenderTargetTexture>;
  25570. /**
  25571. * Observable triggered when the camera view matrix has changed.
  25572. */
  25573. onViewMatrixChangedObservable: Observable<Camera>;
  25574. /**
  25575. * Observable triggered when the camera Projection matrix has changed.
  25576. */
  25577. onProjectionMatrixChangedObservable: Observable<Camera>;
  25578. /**
  25579. * Observable triggered when the inputs have been processed.
  25580. */
  25581. onAfterCheckInputsObservable: Observable<Camera>;
  25582. /**
  25583. * Observable triggered when reset has been called and applied to the camera.
  25584. */
  25585. onRestoreStateObservable: Observable<Camera>;
  25586. /**
  25587. * Is this camera a part of a rig system?
  25588. */
  25589. isRigCamera: boolean;
  25590. /**
  25591. * If isRigCamera set to true this will be set with the parent camera.
  25592. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25593. */
  25594. rigParent?: Camera;
  25595. /** @hidden */
  25596. _cameraRigParams: any;
  25597. /** @hidden */
  25598. _rigCameras: Camera[];
  25599. /** @hidden */
  25600. _rigPostProcess: Nullable<PostProcess>;
  25601. protected _webvrViewMatrix: Matrix;
  25602. /** @hidden */
  25603. _skipRendering: boolean;
  25604. /** @hidden */
  25605. _projectionMatrix: Matrix;
  25606. /** @hidden */
  25607. _postProcesses: Nullable<PostProcess>[];
  25608. /** @hidden */
  25609. _activeMeshes: SmartArray<AbstractMesh>;
  25610. protected _globalPosition: Vector3;
  25611. /** @hidden */
  25612. _computedViewMatrix: Matrix;
  25613. private _doNotComputeProjectionMatrix;
  25614. private _transformMatrix;
  25615. private _frustumPlanes;
  25616. private _refreshFrustumPlanes;
  25617. private _storedFov;
  25618. private _stateStored;
  25619. /**
  25620. * Instantiates a new camera object.
  25621. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25622. * @see http://doc.babylonjs.com/features/cameras
  25623. * @param name Defines the name of the camera in the scene
  25624. * @param position Defines the position of the camera
  25625. * @param scene Defines the scene the camera belongs too
  25626. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25627. */
  25628. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25629. /**
  25630. * Store current camera state (fov, position, etc..)
  25631. * @returns the camera
  25632. */
  25633. storeState(): Camera;
  25634. /**
  25635. * Restores the camera state values if it has been stored. You must call storeState() first
  25636. */
  25637. protected _restoreStateValues(): boolean;
  25638. /**
  25639. * Restored camera state. You must call storeState() first.
  25640. * @returns true if restored and false otherwise
  25641. */
  25642. restoreState(): boolean;
  25643. /**
  25644. * Gets the class name of the camera.
  25645. * @returns the class name
  25646. */
  25647. getClassName(): string;
  25648. /** @hidden */
  25649. readonly _isCamera: boolean;
  25650. /**
  25651. * Gets a string representation of the camera useful for debug purpose.
  25652. * @param fullDetails Defines that a more verboe level of logging is required
  25653. * @returns the string representation
  25654. */
  25655. toString(fullDetails?: boolean): string;
  25656. /**
  25657. * Gets the current world space position of the camera.
  25658. */
  25659. get globalPosition(): Vector3;
  25660. /**
  25661. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25662. * @returns the active meshe list
  25663. */
  25664. getActiveMeshes(): SmartArray<AbstractMesh>;
  25665. /**
  25666. * Check whether a mesh is part of the current active mesh list of the camera
  25667. * @param mesh Defines the mesh to check
  25668. * @returns true if active, false otherwise
  25669. */
  25670. isActiveMesh(mesh: Mesh): boolean;
  25671. /**
  25672. * Is this camera ready to be used/rendered
  25673. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25674. * @return true if the camera is ready
  25675. */
  25676. isReady(completeCheck?: boolean): boolean;
  25677. /** @hidden */
  25678. _initCache(): void;
  25679. /** @hidden */
  25680. _updateCache(ignoreParentClass?: boolean): void;
  25681. /** @hidden */
  25682. _isSynchronized(): boolean;
  25683. /** @hidden */
  25684. _isSynchronizedViewMatrix(): boolean;
  25685. /** @hidden */
  25686. _isSynchronizedProjectionMatrix(): boolean;
  25687. /**
  25688. * Attach the input controls to a specific dom element to get the input from.
  25689. * @param element Defines the element the controls should be listened from
  25690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25691. */
  25692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25693. /**
  25694. * Detach the current controls from the specified dom element.
  25695. * @param element Defines the element to stop listening the inputs from
  25696. */
  25697. detachControl(element: HTMLElement): void;
  25698. /**
  25699. * Update the camera state according to the different inputs gathered during the frame.
  25700. */
  25701. update(): void;
  25702. /** @hidden */
  25703. _checkInputs(): void;
  25704. /** @hidden */
  25705. get rigCameras(): Camera[];
  25706. /**
  25707. * Gets the post process used by the rig cameras
  25708. */
  25709. get rigPostProcess(): Nullable<PostProcess>;
  25710. /**
  25711. * Internal, gets the first post proces.
  25712. * @returns the first post process to be run on this camera.
  25713. */
  25714. _getFirstPostProcess(): Nullable<PostProcess>;
  25715. private _cascadePostProcessesToRigCams;
  25716. /**
  25717. * Attach a post process to the camera.
  25718. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25719. * @param postProcess The post process to attach to the camera
  25720. * @param insertAt The position of the post process in case several of them are in use in the scene
  25721. * @returns the position the post process has been inserted at
  25722. */
  25723. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25724. /**
  25725. * Detach a post process to the camera.
  25726. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25727. * @param postProcess The post process to detach from the camera
  25728. */
  25729. detachPostProcess(postProcess: PostProcess): void;
  25730. /**
  25731. * Gets the current world matrix of the camera
  25732. */
  25733. getWorldMatrix(): Matrix;
  25734. /** @hidden */
  25735. _getViewMatrix(): Matrix;
  25736. /**
  25737. * Gets the current view matrix of the camera.
  25738. * @param force forces the camera to recompute the matrix without looking at the cached state
  25739. * @returns the view matrix
  25740. */
  25741. getViewMatrix(force?: boolean): Matrix;
  25742. /**
  25743. * Freeze the projection matrix.
  25744. * It will prevent the cache check of the camera projection compute and can speed up perf
  25745. * if no parameter of the camera are meant to change
  25746. * @param projection Defines manually a projection if necessary
  25747. */
  25748. freezeProjectionMatrix(projection?: Matrix): void;
  25749. /**
  25750. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25751. */
  25752. unfreezeProjectionMatrix(): void;
  25753. /**
  25754. * Gets the current projection matrix of the camera.
  25755. * @param force forces the camera to recompute the matrix without looking at the cached state
  25756. * @returns the projection matrix
  25757. */
  25758. getProjectionMatrix(force?: boolean): Matrix;
  25759. /**
  25760. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25761. * @returns a Matrix
  25762. */
  25763. getTransformationMatrix(): Matrix;
  25764. private _updateFrustumPlanes;
  25765. /**
  25766. * Checks if a cullable object (mesh...) is in the camera frustum
  25767. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25768. * @param target The object to check
  25769. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25770. * @returns true if the object is in frustum otherwise false
  25771. */
  25772. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25773. /**
  25774. * Checks if a cullable object (mesh...) is in the camera frustum
  25775. * Unlike isInFrustum this cheks the full bounding box
  25776. * @param target The object to check
  25777. * @returns true if the object is in frustum otherwise false
  25778. */
  25779. isCompletelyInFrustum(target: ICullable): boolean;
  25780. /**
  25781. * Gets a ray in the forward direction from the camera.
  25782. * @param length Defines the length of the ray to create
  25783. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25784. * @param origin Defines the start point of the ray which defaults to the camera position
  25785. * @returns the forward ray
  25786. */
  25787. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25788. /**
  25789. * Releases resources associated with this node.
  25790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25792. */
  25793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25794. /** @hidden */
  25795. _isLeftCamera: boolean;
  25796. /**
  25797. * Gets the left camera of a rig setup in case of Rigged Camera
  25798. */
  25799. get isLeftCamera(): boolean;
  25800. /** @hidden */
  25801. _isRightCamera: boolean;
  25802. /**
  25803. * Gets the right camera of a rig setup in case of Rigged Camera
  25804. */
  25805. get isRightCamera(): boolean;
  25806. /**
  25807. * Gets the left camera of a rig setup in case of Rigged Camera
  25808. */
  25809. get leftCamera(): Nullable<FreeCamera>;
  25810. /**
  25811. * Gets the right camera of a rig setup in case of Rigged Camera
  25812. */
  25813. get rightCamera(): Nullable<FreeCamera>;
  25814. /**
  25815. * Gets the left camera target of a rig setup in case of Rigged Camera
  25816. * @returns the target position
  25817. */
  25818. getLeftTarget(): Nullable<Vector3>;
  25819. /**
  25820. * Gets the right camera target of a rig setup in case of Rigged Camera
  25821. * @returns the target position
  25822. */
  25823. getRightTarget(): Nullable<Vector3>;
  25824. /**
  25825. * @hidden
  25826. */
  25827. setCameraRigMode(mode: number, rigParams: any): void;
  25828. /** @hidden */
  25829. static _setStereoscopicRigMode(camera: Camera): void;
  25830. /** @hidden */
  25831. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25832. /** @hidden */
  25833. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25834. /** @hidden */
  25835. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25836. /** @hidden */
  25837. _getVRProjectionMatrix(): Matrix;
  25838. protected _updateCameraRotationMatrix(): void;
  25839. protected _updateWebVRCameraRotationMatrix(): void;
  25840. /**
  25841. * This function MUST be overwritten by the different WebVR cameras available.
  25842. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25843. * @hidden
  25844. */
  25845. _getWebVRProjectionMatrix(): Matrix;
  25846. /**
  25847. * This function MUST be overwritten by the different WebVR cameras available.
  25848. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25849. * @hidden
  25850. */
  25851. _getWebVRViewMatrix(): Matrix;
  25852. /** @hidden */
  25853. setCameraRigParameter(name: string, value: any): void;
  25854. /**
  25855. * needs to be overridden by children so sub has required properties to be copied
  25856. * @hidden
  25857. */
  25858. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25859. /**
  25860. * May need to be overridden by children
  25861. * @hidden
  25862. */
  25863. _updateRigCameras(): void;
  25864. /** @hidden */
  25865. _setupInputs(): void;
  25866. /**
  25867. * Serialiaze the camera setup to a json represention
  25868. * @returns the JSON representation
  25869. */
  25870. serialize(): any;
  25871. /**
  25872. * Clones the current camera.
  25873. * @param name The cloned camera name
  25874. * @returns the cloned camera
  25875. */
  25876. clone(name: string): Camera;
  25877. /**
  25878. * Gets the direction of the camera relative to a given local axis.
  25879. * @param localAxis Defines the reference axis to provide a relative direction.
  25880. * @return the direction
  25881. */
  25882. getDirection(localAxis: Vector3): Vector3;
  25883. /**
  25884. * Returns the current camera absolute rotation
  25885. */
  25886. get absoluteRotation(): Quaternion;
  25887. /**
  25888. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25889. * @param localAxis Defines the reference axis to provide a relative direction.
  25890. * @param result Defines the vector to store the result in
  25891. */
  25892. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25893. /**
  25894. * Gets a camera constructor for a given camera type
  25895. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25896. * @param name The name of the camera the result will be able to instantiate
  25897. * @param scene The scene the result will construct the camera in
  25898. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25899. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25900. * @returns a factory method to construc the camera
  25901. */
  25902. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25903. /**
  25904. * Compute the world matrix of the camera.
  25905. * @returns the camera world matrix
  25906. */
  25907. computeWorldMatrix(): Matrix;
  25908. /**
  25909. * Parse a JSON and creates the camera from the parsed information
  25910. * @param parsedCamera The JSON to parse
  25911. * @param scene The scene to instantiate the camera in
  25912. * @returns the newly constructed camera
  25913. */
  25914. static Parse(parsedCamera: any, scene: Scene): Camera;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * Class containing static functions to help procedurally build meshes
  25920. */
  25921. export class DiscBuilder {
  25922. /**
  25923. * Creates a plane polygonal mesh. By default, this is a disc
  25924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25925. * * 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
  25926. * * 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
  25927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25928. * * 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
  25929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25930. * @param name defines the name of the mesh
  25931. * @param options defines the options used to create the mesh
  25932. * @param scene defines the hosting scene
  25933. * @returns the plane polygonal mesh
  25934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25935. */
  25936. static CreateDisc(name: string, options: {
  25937. radius?: number;
  25938. tessellation?: number;
  25939. arc?: number;
  25940. updatable?: boolean;
  25941. sideOrientation?: number;
  25942. frontUVs?: Vector4;
  25943. backUVs?: Vector4;
  25944. }, scene?: Nullable<Scene>): Mesh;
  25945. }
  25946. }
  25947. declare module BABYLON {
  25948. /**
  25949. * This represents all the required information to add a fresnel effect on a material:
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25951. */
  25952. export class FresnelParameters {
  25953. private _isEnabled;
  25954. /**
  25955. * Define if the fresnel effect is enable or not.
  25956. */
  25957. get isEnabled(): boolean;
  25958. set isEnabled(value: boolean);
  25959. /**
  25960. * Define the color used on edges (grazing angle)
  25961. */
  25962. leftColor: Color3;
  25963. /**
  25964. * Define the color used on center
  25965. */
  25966. rightColor: Color3;
  25967. /**
  25968. * Define bias applied to computed fresnel term
  25969. */
  25970. bias: number;
  25971. /**
  25972. * Defined the power exponent applied to fresnel term
  25973. */
  25974. power: number;
  25975. /**
  25976. * Clones the current fresnel and its valuues
  25977. * @returns a clone fresnel configuration
  25978. */
  25979. clone(): FresnelParameters;
  25980. /**
  25981. * Serializes the current fresnel parameters to a JSON representation.
  25982. * @return the JSON serialization
  25983. */
  25984. serialize(): any;
  25985. /**
  25986. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25987. * @param parsedFresnelParameters Define the JSON representation
  25988. * @returns the parsed parameters
  25989. */
  25990. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25991. }
  25992. }
  25993. declare module BABYLON {
  25994. /**
  25995. * Base class of materials working in push mode in babylon JS
  25996. * @hidden
  25997. */
  25998. export class PushMaterial extends Material {
  25999. protected _activeEffect: Effect;
  26000. protected _normalMatrix: Matrix;
  26001. /**
  26002. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26003. * This means that the material can keep using a previous shader while a new one is being compiled.
  26004. * This is mostly used when shader parallel compilation is supported (true by default)
  26005. */
  26006. allowShaderHotSwapping: boolean;
  26007. constructor(name: string, scene: Scene);
  26008. getEffect(): Effect;
  26009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26010. /**
  26011. * Binds the given world matrix to the active effect
  26012. *
  26013. * @param world the matrix to bind
  26014. */
  26015. bindOnlyWorldMatrix(world: Matrix): void;
  26016. /**
  26017. * Binds the given normal matrix to the active effect
  26018. *
  26019. * @param normalMatrix the matrix to bind
  26020. */
  26021. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26022. bind(world: Matrix, mesh?: Mesh): void;
  26023. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26024. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26025. }
  26026. }
  26027. declare module BABYLON {
  26028. /**
  26029. * This groups all the flags used to control the materials channel.
  26030. */
  26031. export class MaterialFlags {
  26032. private static _DiffuseTextureEnabled;
  26033. /**
  26034. * Are diffuse textures enabled in the application.
  26035. */
  26036. static get DiffuseTextureEnabled(): boolean;
  26037. static set DiffuseTextureEnabled(value: boolean);
  26038. private static _AmbientTextureEnabled;
  26039. /**
  26040. * Are ambient textures enabled in the application.
  26041. */
  26042. static get AmbientTextureEnabled(): boolean;
  26043. static set AmbientTextureEnabled(value: boolean);
  26044. private static _OpacityTextureEnabled;
  26045. /**
  26046. * Are opacity textures enabled in the application.
  26047. */
  26048. static get OpacityTextureEnabled(): boolean;
  26049. static set OpacityTextureEnabled(value: boolean);
  26050. private static _ReflectionTextureEnabled;
  26051. /**
  26052. * Are reflection textures enabled in the application.
  26053. */
  26054. static get ReflectionTextureEnabled(): boolean;
  26055. static set ReflectionTextureEnabled(value: boolean);
  26056. private static _EmissiveTextureEnabled;
  26057. /**
  26058. * Are emissive textures enabled in the application.
  26059. */
  26060. static get EmissiveTextureEnabled(): boolean;
  26061. static set EmissiveTextureEnabled(value: boolean);
  26062. private static _SpecularTextureEnabled;
  26063. /**
  26064. * Are specular textures enabled in the application.
  26065. */
  26066. static get SpecularTextureEnabled(): boolean;
  26067. static set SpecularTextureEnabled(value: boolean);
  26068. private static _BumpTextureEnabled;
  26069. /**
  26070. * Are bump textures enabled in the application.
  26071. */
  26072. static get BumpTextureEnabled(): boolean;
  26073. static set BumpTextureEnabled(value: boolean);
  26074. private static _LightmapTextureEnabled;
  26075. /**
  26076. * Are lightmap textures enabled in the application.
  26077. */
  26078. static get LightmapTextureEnabled(): boolean;
  26079. static set LightmapTextureEnabled(value: boolean);
  26080. private static _RefractionTextureEnabled;
  26081. /**
  26082. * Are refraction textures enabled in the application.
  26083. */
  26084. static get RefractionTextureEnabled(): boolean;
  26085. static set RefractionTextureEnabled(value: boolean);
  26086. private static _ColorGradingTextureEnabled;
  26087. /**
  26088. * Are color grading textures enabled in the application.
  26089. */
  26090. static get ColorGradingTextureEnabled(): boolean;
  26091. static set ColorGradingTextureEnabled(value: boolean);
  26092. private static _FresnelEnabled;
  26093. /**
  26094. * Are fresnels enabled in the application.
  26095. */
  26096. static get FresnelEnabled(): boolean;
  26097. static set FresnelEnabled(value: boolean);
  26098. private static _ClearCoatTextureEnabled;
  26099. /**
  26100. * Are clear coat textures enabled in the application.
  26101. */
  26102. static get ClearCoatTextureEnabled(): boolean;
  26103. static set ClearCoatTextureEnabled(value: boolean);
  26104. private static _ClearCoatBumpTextureEnabled;
  26105. /**
  26106. * Are clear coat bump textures enabled in the application.
  26107. */
  26108. static get ClearCoatBumpTextureEnabled(): boolean;
  26109. static set ClearCoatBumpTextureEnabled(value: boolean);
  26110. private static _ClearCoatTintTextureEnabled;
  26111. /**
  26112. * Are clear coat tint textures enabled in the application.
  26113. */
  26114. static get ClearCoatTintTextureEnabled(): boolean;
  26115. static set ClearCoatTintTextureEnabled(value: boolean);
  26116. private static _SheenTextureEnabled;
  26117. /**
  26118. * Are sheen textures enabled in the application.
  26119. */
  26120. static get SheenTextureEnabled(): boolean;
  26121. static set SheenTextureEnabled(value: boolean);
  26122. private static _AnisotropicTextureEnabled;
  26123. /**
  26124. * Are anisotropic textures enabled in the application.
  26125. */
  26126. static get AnisotropicTextureEnabled(): boolean;
  26127. static set AnisotropicTextureEnabled(value: boolean);
  26128. private static _ThicknessTextureEnabled;
  26129. /**
  26130. * Are thickness textures enabled in the application.
  26131. */
  26132. static get ThicknessTextureEnabled(): boolean;
  26133. static set ThicknessTextureEnabled(value: boolean);
  26134. }
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var defaultFragmentDeclaration: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var defaultUboDeclaration: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var lightFragmentDeclaration: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var lightUboDeclaration: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var lightsFragmentFunctions: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var shadowsFragmentFunctions: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var fresnelFunction: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var reflectionFunction: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var bumpFragmentFunctions: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /** @hidden */
  26201. export var logDepthDeclaration: {
  26202. name: string;
  26203. shader: string;
  26204. };
  26205. }
  26206. declare module BABYLON {
  26207. /** @hidden */
  26208. export var bumpFragment: {
  26209. name: string;
  26210. shader: string;
  26211. };
  26212. }
  26213. declare module BABYLON {
  26214. /** @hidden */
  26215. export var depthPrePass: {
  26216. name: string;
  26217. shader: string;
  26218. };
  26219. }
  26220. declare module BABYLON {
  26221. /** @hidden */
  26222. export var lightFragment: {
  26223. name: string;
  26224. shader: string;
  26225. };
  26226. }
  26227. declare module BABYLON {
  26228. /** @hidden */
  26229. export var logDepthFragment: {
  26230. name: string;
  26231. shader: string;
  26232. };
  26233. }
  26234. declare module BABYLON {
  26235. /** @hidden */
  26236. export var defaultPixelShader: {
  26237. name: string;
  26238. shader: string;
  26239. };
  26240. }
  26241. declare module BABYLON {
  26242. /** @hidden */
  26243. export var defaultVertexDeclaration: {
  26244. name: string;
  26245. shader: string;
  26246. };
  26247. }
  26248. declare module BABYLON {
  26249. /** @hidden */
  26250. export var bumpVertexDeclaration: {
  26251. name: string;
  26252. shader: string;
  26253. };
  26254. }
  26255. declare module BABYLON {
  26256. /** @hidden */
  26257. export var bumpVertex: {
  26258. name: string;
  26259. shader: string;
  26260. };
  26261. }
  26262. declare module BABYLON {
  26263. /** @hidden */
  26264. export var fogVertex: {
  26265. name: string;
  26266. shader: string;
  26267. };
  26268. }
  26269. declare module BABYLON {
  26270. /** @hidden */
  26271. export var shadowsVertex: {
  26272. name: string;
  26273. shader: string;
  26274. };
  26275. }
  26276. declare module BABYLON {
  26277. /** @hidden */
  26278. export var pointCloudVertex: {
  26279. name: string;
  26280. shader: string;
  26281. };
  26282. }
  26283. declare module BABYLON {
  26284. /** @hidden */
  26285. export var logDepthVertex: {
  26286. name: string;
  26287. shader: string;
  26288. };
  26289. }
  26290. declare module BABYLON {
  26291. /** @hidden */
  26292. export var defaultVertexShader: {
  26293. name: string;
  26294. shader: string;
  26295. };
  26296. }
  26297. declare module BABYLON {
  26298. /** @hidden */
  26299. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26300. MAINUV1: boolean;
  26301. MAINUV2: boolean;
  26302. DIFFUSE: boolean;
  26303. DIFFUSEDIRECTUV: number;
  26304. AMBIENT: boolean;
  26305. AMBIENTDIRECTUV: number;
  26306. OPACITY: boolean;
  26307. OPACITYDIRECTUV: number;
  26308. OPACITYRGB: boolean;
  26309. REFLECTION: boolean;
  26310. EMISSIVE: boolean;
  26311. EMISSIVEDIRECTUV: number;
  26312. SPECULAR: boolean;
  26313. SPECULARDIRECTUV: number;
  26314. BUMP: boolean;
  26315. BUMPDIRECTUV: number;
  26316. PARALLAX: boolean;
  26317. PARALLAXOCCLUSION: boolean;
  26318. SPECULAROVERALPHA: boolean;
  26319. CLIPPLANE: boolean;
  26320. CLIPPLANE2: boolean;
  26321. CLIPPLANE3: boolean;
  26322. CLIPPLANE4: boolean;
  26323. CLIPPLANE5: boolean;
  26324. CLIPPLANE6: boolean;
  26325. ALPHATEST: boolean;
  26326. DEPTHPREPASS: boolean;
  26327. ALPHAFROMDIFFUSE: boolean;
  26328. POINTSIZE: boolean;
  26329. FOG: boolean;
  26330. SPECULARTERM: boolean;
  26331. DIFFUSEFRESNEL: boolean;
  26332. OPACITYFRESNEL: boolean;
  26333. REFLECTIONFRESNEL: boolean;
  26334. REFRACTIONFRESNEL: boolean;
  26335. EMISSIVEFRESNEL: boolean;
  26336. FRESNEL: boolean;
  26337. NORMAL: boolean;
  26338. UV1: boolean;
  26339. UV2: boolean;
  26340. VERTEXCOLOR: boolean;
  26341. VERTEXALPHA: boolean;
  26342. NUM_BONE_INFLUENCERS: number;
  26343. BonesPerMesh: number;
  26344. BONETEXTURE: boolean;
  26345. INSTANCES: boolean;
  26346. GLOSSINESS: boolean;
  26347. ROUGHNESS: boolean;
  26348. EMISSIVEASILLUMINATION: boolean;
  26349. LINKEMISSIVEWITHDIFFUSE: boolean;
  26350. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26351. LIGHTMAP: boolean;
  26352. LIGHTMAPDIRECTUV: number;
  26353. OBJECTSPACE_NORMALMAP: boolean;
  26354. USELIGHTMAPASSHADOWMAP: boolean;
  26355. REFLECTIONMAP_3D: boolean;
  26356. REFLECTIONMAP_SPHERICAL: boolean;
  26357. REFLECTIONMAP_PLANAR: boolean;
  26358. REFLECTIONMAP_CUBIC: boolean;
  26359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26360. REFLECTIONMAP_PROJECTION: boolean;
  26361. REFLECTIONMAP_SKYBOX: boolean;
  26362. REFLECTIONMAP_EXPLICIT: boolean;
  26363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26366. INVERTCUBICMAP: boolean;
  26367. LOGARITHMICDEPTH: boolean;
  26368. REFRACTION: boolean;
  26369. REFRACTIONMAP_3D: boolean;
  26370. REFLECTIONOVERALPHA: boolean;
  26371. TWOSIDEDLIGHTING: boolean;
  26372. SHADOWFLOAT: boolean;
  26373. MORPHTARGETS: boolean;
  26374. MORPHTARGETS_NORMAL: boolean;
  26375. MORPHTARGETS_TANGENT: boolean;
  26376. MORPHTARGETS_UV: boolean;
  26377. NUM_MORPH_INFLUENCERS: number;
  26378. NONUNIFORMSCALING: boolean;
  26379. PREMULTIPLYALPHA: boolean;
  26380. IMAGEPROCESSING: boolean;
  26381. VIGNETTE: boolean;
  26382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26383. VIGNETTEBLENDMODEOPAQUE: boolean;
  26384. TONEMAPPING: boolean;
  26385. TONEMAPPING_ACES: boolean;
  26386. CONTRAST: boolean;
  26387. COLORCURVES: boolean;
  26388. COLORGRADING: boolean;
  26389. COLORGRADING3D: boolean;
  26390. SAMPLER3DGREENDEPTH: boolean;
  26391. SAMPLER3DBGRMAP: boolean;
  26392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26393. MULTIVIEW: boolean;
  26394. /**
  26395. * If the reflection texture on this material is in linear color space
  26396. * @hidden
  26397. */
  26398. IS_REFLECTION_LINEAR: boolean;
  26399. /**
  26400. * If the refraction texture on this material is in linear color space
  26401. * @hidden
  26402. */
  26403. IS_REFRACTION_LINEAR: boolean;
  26404. EXPOSURE: boolean;
  26405. constructor();
  26406. setReflectionMode(modeToEnable: string): void;
  26407. }
  26408. /**
  26409. * This is the default material used in Babylon. It is the best trade off between quality
  26410. * and performances.
  26411. * @see http://doc.babylonjs.com/babylon101/materials
  26412. */
  26413. export class StandardMaterial extends PushMaterial {
  26414. private _diffuseTexture;
  26415. /**
  26416. * The basic texture of the material as viewed under a light.
  26417. */
  26418. diffuseTexture: Nullable<BaseTexture>;
  26419. private _ambientTexture;
  26420. /**
  26421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26422. */
  26423. ambientTexture: Nullable<BaseTexture>;
  26424. private _opacityTexture;
  26425. /**
  26426. * Define the transparency of the material from a texture.
  26427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26429. */
  26430. opacityTexture: Nullable<BaseTexture>;
  26431. private _reflectionTexture;
  26432. /**
  26433. * Define the texture used to display the reflection.
  26434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26435. */
  26436. reflectionTexture: Nullable<BaseTexture>;
  26437. private _emissiveTexture;
  26438. /**
  26439. * Define texture of the material as if self lit.
  26440. * This will be mixed in the final result even in the absence of light.
  26441. */
  26442. emissiveTexture: Nullable<BaseTexture>;
  26443. private _specularTexture;
  26444. /**
  26445. * Define how the color and intensity of the highlight given by the light in the material.
  26446. */
  26447. specularTexture: Nullable<BaseTexture>;
  26448. private _bumpTexture;
  26449. /**
  26450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26451. * 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.
  26452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26453. */
  26454. bumpTexture: Nullable<BaseTexture>;
  26455. private _lightmapTexture;
  26456. /**
  26457. * Complex lighting can be computationally expensive to compute at runtime.
  26458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26460. */
  26461. lightmapTexture: Nullable<BaseTexture>;
  26462. private _refractionTexture;
  26463. /**
  26464. * Define the texture used to display the refraction.
  26465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26466. */
  26467. refractionTexture: Nullable<BaseTexture>;
  26468. /**
  26469. * The color of the material lit by the environmental background lighting.
  26470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26471. */
  26472. ambientColor: Color3;
  26473. /**
  26474. * The basic color of the material as viewed under a light.
  26475. */
  26476. diffuseColor: Color3;
  26477. /**
  26478. * Define how the color and intensity of the highlight given by the light in the material.
  26479. */
  26480. specularColor: Color3;
  26481. /**
  26482. * Define the color of the material as if self lit.
  26483. * This will be mixed in the final result even in the absence of light.
  26484. */
  26485. emissiveColor: Color3;
  26486. /**
  26487. * Defines how sharp are the highlights in the material.
  26488. * The bigger the value the sharper giving a more glossy feeling to the result.
  26489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26490. */
  26491. specularPower: number;
  26492. private _useAlphaFromDiffuseTexture;
  26493. /**
  26494. * Does the transparency come from the diffuse texture alpha channel.
  26495. */
  26496. useAlphaFromDiffuseTexture: boolean;
  26497. private _useEmissiveAsIllumination;
  26498. /**
  26499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26500. */
  26501. useEmissiveAsIllumination: boolean;
  26502. private _linkEmissiveWithDiffuse;
  26503. /**
  26504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26505. * the emissive level when the final color is close to one.
  26506. */
  26507. linkEmissiveWithDiffuse: boolean;
  26508. private _useSpecularOverAlpha;
  26509. /**
  26510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26512. */
  26513. useSpecularOverAlpha: boolean;
  26514. private _useReflectionOverAlpha;
  26515. /**
  26516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26518. */
  26519. useReflectionOverAlpha: boolean;
  26520. private _disableLighting;
  26521. /**
  26522. * Does lights from the scene impacts this material.
  26523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26524. */
  26525. disableLighting: boolean;
  26526. private _useObjectSpaceNormalMap;
  26527. /**
  26528. * Allows using an object space normal map (instead of tangent space).
  26529. */
  26530. useObjectSpaceNormalMap: boolean;
  26531. private _useParallax;
  26532. /**
  26533. * Is parallax enabled or not.
  26534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26535. */
  26536. useParallax: boolean;
  26537. private _useParallaxOcclusion;
  26538. /**
  26539. * Is parallax occlusion enabled or not.
  26540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26542. */
  26543. useParallaxOcclusion: boolean;
  26544. /**
  26545. * 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.
  26546. */
  26547. parallaxScaleBias: number;
  26548. private _roughness;
  26549. /**
  26550. * Helps to define how blurry the reflections should appears in the material.
  26551. */
  26552. roughness: number;
  26553. /**
  26554. * In case of refraction, define the value of the index of refraction.
  26555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26556. */
  26557. indexOfRefraction: number;
  26558. /**
  26559. * Invert the refraction texture alongside the y axis.
  26560. * It can be useful with procedural textures or probe for instance.
  26561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26562. */
  26563. invertRefractionY: boolean;
  26564. /**
  26565. * Defines the alpha limits in alpha test mode.
  26566. */
  26567. alphaCutOff: number;
  26568. private _useLightmapAsShadowmap;
  26569. /**
  26570. * In case of light mapping, define whether the map contains light or shadow informations.
  26571. */
  26572. useLightmapAsShadowmap: boolean;
  26573. private _diffuseFresnelParameters;
  26574. /**
  26575. * Define the diffuse fresnel parameters of the material.
  26576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26577. */
  26578. diffuseFresnelParameters: FresnelParameters;
  26579. private _opacityFresnelParameters;
  26580. /**
  26581. * Define the opacity fresnel parameters of the material.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26583. */
  26584. opacityFresnelParameters: FresnelParameters;
  26585. private _reflectionFresnelParameters;
  26586. /**
  26587. * Define the reflection fresnel parameters of the material.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26589. */
  26590. reflectionFresnelParameters: FresnelParameters;
  26591. private _refractionFresnelParameters;
  26592. /**
  26593. * Define the refraction fresnel parameters of the material.
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26595. */
  26596. refractionFresnelParameters: FresnelParameters;
  26597. private _emissiveFresnelParameters;
  26598. /**
  26599. * Define the emissive fresnel parameters of the material.
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26601. */
  26602. emissiveFresnelParameters: FresnelParameters;
  26603. private _useReflectionFresnelFromSpecular;
  26604. /**
  26605. * If true automatically deducts the fresnels values from the material specularity.
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26607. */
  26608. useReflectionFresnelFromSpecular: boolean;
  26609. private _useGlossinessFromSpecularMapAlpha;
  26610. /**
  26611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26612. */
  26613. useGlossinessFromSpecularMapAlpha: boolean;
  26614. private _maxSimultaneousLights;
  26615. /**
  26616. * Defines the maximum number of lights that can be used in the material
  26617. */
  26618. maxSimultaneousLights: number;
  26619. private _invertNormalMapX;
  26620. /**
  26621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26622. */
  26623. invertNormalMapX: boolean;
  26624. private _invertNormalMapY;
  26625. /**
  26626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26627. */
  26628. invertNormalMapY: boolean;
  26629. private _twoSidedLighting;
  26630. /**
  26631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26632. */
  26633. twoSidedLighting: boolean;
  26634. /**
  26635. * Default configuration related to image processing available in the standard Material.
  26636. */
  26637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26638. /**
  26639. * Gets the image processing configuration used either in this material.
  26640. */
  26641. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26642. /**
  26643. * Sets the Default image processing configuration used either in the this material.
  26644. *
  26645. * If sets to null, the scene one is in use.
  26646. */
  26647. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26648. /**
  26649. * Keep track of the image processing observer to allow dispose and replace.
  26650. */
  26651. private _imageProcessingObserver;
  26652. /**
  26653. * Attaches a new image processing configuration to the Standard Material.
  26654. * @param configuration
  26655. */
  26656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26657. /**
  26658. * Gets wether the color curves effect is enabled.
  26659. */
  26660. get cameraColorCurvesEnabled(): boolean;
  26661. /**
  26662. * Sets wether the color curves effect is enabled.
  26663. */
  26664. set cameraColorCurvesEnabled(value: boolean);
  26665. /**
  26666. * Gets wether the color grading effect is enabled.
  26667. */
  26668. get cameraColorGradingEnabled(): boolean;
  26669. /**
  26670. * Gets wether the color grading effect is enabled.
  26671. */
  26672. set cameraColorGradingEnabled(value: boolean);
  26673. /**
  26674. * Gets wether tonemapping is enabled or not.
  26675. */
  26676. get cameraToneMappingEnabled(): boolean;
  26677. /**
  26678. * Sets wether tonemapping is enabled or not
  26679. */
  26680. set cameraToneMappingEnabled(value: boolean);
  26681. /**
  26682. * The camera exposure used on this material.
  26683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26684. * This corresponds to a photographic exposure.
  26685. */
  26686. get cameraExposure(): number;
  26687. /**
  26688. * The camera exposure used on this material.
  26689. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26690. * This corresponds to a photographic exposure.
  26691. */
  26692. set cameraExposure(value: number);
  26693. /**
  26694. * Gets The camera contrast used on this material.
  26695. */
  26696. get cameraContrast(): number;
  26697. /**
  26698. * Sets The camera contrast used on this material.
  26699. */
  26700. set cameraContrast(value: number);
  26701. /**
  26702. * Gets the Color Grading 2D Lookup Texture.
  26703. */
  26704. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26705. /**
  26706. * Sets the Color Grading 2D Lookup Texture.
  26707. */
  26708. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26709. /**
  26710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26712. * 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;
  26713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26714. */
  26715. get cameraColorCurves(): Nullable<ColorCurves>;
  26716. /**
  26717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26719. * 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;
  26720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26721. */
  26722. set cameraColorCurves(value: Nullable<ColorCurves>);
  26723. /**
  26724. * Custom callback helping to override the default shader used in the material.
  26725. */
  26726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26727. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26728. protected _worldViewProjectionMatrix: Matrix;
  26729. protected _globalAmbientColor: Color3;
  26730. protected _useLogarithmicDepth: boolean;
  26731. protected _rebuildInParallel: boolean;
  26732. /**
  26733. * Instantiates a new standard material.
  26734. * This is the default material used in Babylon. It is the best trade off between quality
  26735. * and performances.
  26736. * @see http://doc.babylonjs.com/babylon101/materials
  26737. * @param name Define the name of the material in the scene
  26738. * @param scene Define the scene the material belong to
  26739. */
  26740. constructor(name: string, scene: Scene);
  26741. /**
  26742. * Gets a boolean indicating that current material needs to register RTT
  26743. */
  26744. get hasRenderTargetTextures(): boolean;
  26745. /**
  26746. * Gets the current class name of the material e.g. "StandardMaterial"
  26747. * Mainly use in serialization.
  26748. * @returns the class name
  26749. */
  26750. getClassName(): string;
  26751. /**
  26752. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26753. * You can try switching to logarithmic depth.
  26754. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26755. */
  26756. get useLogarithmicDepth(): boolean;
  26757. set useLogarithmicDepth(value: boolean);
  26758. /**
  26759. * Specifies if the material will require alpha blending
  26760. * @returns a boolean specifying if alpha blending is needed
  26761. */
  26762. needAlphaBlending(): boolean;
  26763. /**
  26764. * Specifies if this material should be rendered in alpha test mode
  26765. * @returns a boolean specifying if an alpha test is needed.
  26766. */
  26767. needAlphaTesting(): boolean;
  26768. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26769. /**
  26770. * Get the texture used for alpha test purpose.
  26771. * @returns the diffuse texture in case of the standard material.
  26772. */
  26773. getAlphaTestTexture(): Nullable<BaseTexture>;
  26774. /**
  26775. * Get if the submesh is ready to be used and all its information available.
  26776. * Child classes can use it to update shaders
  26777. * @param mesh defines the mesh to check
  26778. * @param subMesh defines which submesh to check
  26779. * @param useInstances specifies that instances should be used
  26780. * @returns a boolean indicating that the submesh is ready or not
  26781. */
  26782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26783. /**
  26784. * Builds the material UBO layouts.
  26785. * Used internally during the effect preparation.
  26786. */
  26787. buildUniformLayout(): void;
  26788. /**
  26789. * Unbinds the material from the mesh
  26790. */
  26791. unbind(): void;
  26792. /**
  26793. * Binds the submesh to this material by preparing the effect and shader to draw
  26794. * @param world defines the world transformation matrix
  26795. * @param mesh defines the mesh containing the submesh
  26796. * @param subMesh defines the submesh to bind the material to
  26797. */
  26798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26799. /**
  26800. * Get the list of animatables in the material.
  26801. * @returns the list of animatables object used in the material
  26802. */
  26803. getAnimatables(): IAnimatable[];
  26804. /**
  26805. * Gets the active textures from the material
  26806. * @returns an array of textures
  26807. */
  26808. getActiveTextures(): BaseTexture[];
  26809. /**
  26810. * Specifies if the material uses a texture
  26811. * @param texture defines the texture to check against the material
  26812. * @returns a boolean specifying if the material uses the texture
  26813. */
  26814. hasTexture(texture: BaseTexture): boolean;
  26815. /**
  26816. * Disposes the material
  26817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26819. */
  26820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26821. /**
  26822. * Makes a duplicate of the material, and gives it a new name
  26823. * @param name defines the new name for the duplicated material
  26824. * @returns the cloned material
  26825. */
  26826. clone(name: string): StandardMaterial;
  26827. /**
  26828. * Serializes this material in a JSON representation
  26829. * @returns the serialized material object
  26830. */
  26831. serialize(): any;
  26832. /**
  26833. * Creates a standard material from parsed material data
  26834. * @param source defines the JSON representation of the material
  26835. * @param scene defines the hosting scene
  26836. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26837. * @returns a new standard material
  26838. */
  26839. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26840. /**
  26841. * Are diffuse textures enabled in the application.
  26842. */
  26843. static get DiffuseTextureEnabled(): boolean;
  26844. static set DiffuseTextureEnabled(value: boolean);
  26845. /**
  26846. * Are ambient textures enabled in the application.
  26847. */
  26848. static get AmbientTextureEnabled(): boolean;
  26849. static set AmbientTextureEnabled(value: boolean);
  26850. /**
  26851. * Are opacity textures enabled in the application.
  26852. */
  26853. static get OpacityTextureEnabled(): boolean;
  26854. static set OpacityTextureEnabled(value: boolean);
  26855. /**
  26856. * Are reflection textures enabled in the application.
  26857. */
  26858. static get ReflectionTextureEnabled(): boolean;
  26859. static set ReflectionTextureEnabled(value: boolean);
  26860. /**
  26861. * Are emissive textures enabled in the application.
  26862. */
  26863. static get EmissiveTextureEnabled(): boolean;
  26864. static set EmissiveTextureEnabled(value: boolean);
  26865. /**
  26866. * Are specular textures enabled in the application.
  26867. */
  26868. static get SpecularTextureEnabled(): boolean;
  26869. static set SpecularTextureEnabled(value: boolean);
  26870. /**
  26871. * Are bump textures enabled in the application.
  26872. */
  26873. static get BumpTextureEnabled(): boolean;
  26874. static set BumpTextureEnabled(value: boolean);
  26875. /**
  26876. * Are lightmap textures enabled in the application.
  26877. */
  26878. static get LightmapTextureEnabled(): boolean;
  26879. static set LightmapTextureEnabled(value: boolean);
  26880. /**
  26881. * Are refraction textures enabled in the application.
  26882. */
  26883. static get RefractionTextureEnabled(): boolean;
  26884. static set RefractionTextureEnabled(value: boolean);
  26885. /**
  26886. * Are color grading textures enabled in the application.
  26887. */
  26888. static get ColorGradingTextureEnabled(): boolean;
  26889. static set ColorGradingTextureEnabled(value: boolean);
  26890. /**
  26891. * Are fresnels enabled in the application.
  26892. */
  26893. static get FresnelEnabled(): boolean;
  26894. static set FresnelEnabled(value: boolean);
  26895. }
  26896. }
  26897. declare module BABYLON {
  26898. /**
  26899. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26900. *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.
  26901. * The SPS is also a particle system. It provides some methods to manage the particles.
  26902. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26903. *
  26904. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26905. */
  26906. export class SolidParticleSystem implements IDisposable {
  26907. /**
  26908. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26909. * Example : var p = SPS.particles[i];
  26910. */
  26911. particles: SolidParticle[];
  26912. /**
  26913. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26914. */
  26915. nbParticles: number;
  26916. /**
  26917. * If the particles must ever face the camera (default false). Useful for planar particles.
  26918. */
  26919. billboard: boolean;
  26920. /**
  26921. * Recompute normals when adding a shape
  26922. */
  26923. recomputeNormals: boolean;
  26924. /**
  26925. * This a counter ofr your own usage. It's not set by any SPS functions.
  26926. */
  26927. counter: number;
  26928. /**
  26929. * The SPS name. This name is also given to the underlying mesh.
  26930. */
  26931. name: string;
  26932. /**
  26933. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26934. */
  26935. mesh: Mesh;
  26936. /**
  26937. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26938. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26939. */
  26940. vars: any;
  26941. /**
  26942. * This array is populated when the SPS is set as 'pickable'.
  26943. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26944. * Each element of this array is an object `{idx: int, faceId: int}`.
  26945. * `idx` is the picked particle index in the `SPS.particles` array
  26946. * `faceId` is the picked face index counted within this particle.
  26947. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26948. */
  26949. pickedParticles: {
  26950. idx: number;
  26951. faceId: number;
  26952. }[];
  26953. /**
  26954. * This array is populated when `enableDepthSort` is set to true.
  26955. * Each element of this array is an instance of the class DepthSortedParticle.
  26956. */
  26957. depthSortedParticles: DepthSortedParticle[];
  26958. /**
  26959. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26960. * @hidden
  26961. */
  26962. _bSphereOnly: boolean;
  26963. /**
  26964. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26965. * @hidden
  26966. */
  26967. _bSphereRadiusFactor: number;
  26968. private _scene;
  26969. private _positions;
  26970. private _indices;
  26971. private _normals;
  26972. private _colors;
  26973. private _uvs;
  26974. private _indices32;
  26975. private _positions32;
  26976. private _normals32;
  26977. private _fixedNormal32;
  26978. private _colors32;
  26979. private _uvs32;
  26980. private _index;
  26981. private _updatable;
  26982. private _pickable;
  26983. private _isVisibilityBoxLocked;
  26984. private _alwaysVisible;
  26985. private _depthSort;
  26986. private _expandable;
  26987. private _shapeCounter;
  26988. private _copy;
  26989. private _color;
  26990. private _computeParticleColor;
  26991. private _computeParticleTexture;
  26992. private _computeParticleRotation;
  26993. private _computeParticleVertex;
  26994. private _computeBoundingBox;
  26995. private _depthSortParticles;
  26996. private _camera;
  26997. private _mustUnrotateFixedNormals;
  26998. private _particlesIntersect;
  26999. private _needs32Bits;
  27000. private _isNotBuilt;
  27001. private _lastParticleId;
  27002. private _idxOfId;
  27003. private _multimaterialEnabled;
  27004. private _useModelMaterial;
  27005. private _indicesByMaterial;
  27006. private _materialIndexes;
  27007. private _depthSortFunction;
  27008. private _materialSortFunction;
  27009. private _materials;
  27010. private _multimaterial;
  27011. private _materialIndexesById;
  27012. private _defaultMaterial;
  27013. private _autoUpdateSubMeshes;
  27014. /**
  27015. * Creates a SPS (Solid Particle System) object.
  27016. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27017. * @param scene (Scene) is the scene in which the SPS is added.
  27018. * @param options defines the options of the sps e.g.
  27019. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27020. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27021. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27022. * * 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.
  27023. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27024. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27025. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27026. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27027. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27028. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27029. */
  27030. constructor(name: string, scene: Scene, options?: {
  27031. updatable?: boolean;
  27032. isPickable?: boolean;
  27033. enableDepthSort?: boolean;
  27034. particleIntersection?: boolean;
  27035. boundingSphereOnly?: boolean;
  27036. bSphereRadiusFactor?: number;
  27037. expandable?: boolean;
  27038. useModelMaterial?: boolean;
  27039. enableMultiMaterial?: boolean;
  27040. });
  27041. /**
  27042. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27043. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27044. * @returns the created mesh
  27045. */
  27046. buildMesh(): Mesh;
  27047. /**
  27048. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27049. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27050. * Thus the particles generated from `digest()` have their property `position` set yet.
  27051. * @param mesh ( Mesh ) is the mesh to be digested
  27052. * @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
  27053. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27054. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27055. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27056. * @returns the current SPS
  27057. */
  27058. digest(mesh: Mesh, options?: {
  27059. facetNb?: number;
  27060. number?: number;
  27061. delta?: number;
  27062. storage?: [];
  27063. }): SolidParticleSystem;
  27064. /**
  27065. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27066. * @hidden
  27067. */
  27068. private _unrotateFixedNormals;
  27069. /**
  27070. * Resets the temporary working copy particle
  27071. * @hidden
  27072. */
  27073. private _resetCopy;
  27074. /**
  27075. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27076. * @param p the current index in the positions array to be updated
  27077. * @param ind the current index in the indices array
  27078. * @param shape a Vector3 array, the shape geometry
  27079. * @param positions the positions array to be updated
  27080. * @param meshInd the shape indices array
  27081. * @param indices the indices array to be updated
  27082. * @param meshUV the shape uv array
  27083. * @param uvs the uv array to be updated
  27084. * @param meshCol the shape color array
  27085. * @param colors the color array to be updated
  27086. * @param meshNor the shape normals array
  27087. * @param normals the normals array to be updated
  27088. * @param idx the particle index
  27089. * @param idxInShape the particle index in its shape
  27090. * @param options the addShape() method passed options
  27091. * @model the particle model
  27092. * @hidden
  27093. */
  27094. private _meshBuilder;
  27095. /**
  27096. * Returns a shape Vector3 array from positions float array
  27097. * @param positions float array
  27098. * @returns a vector3 array
  27099. * @hidden
  27100. */
  27101. private _posToShape;
  27102. /**
  27103. * Returns a shapeUV array from a float uvs (array deep copy)
  27104. * @param uvs as a float array
  27105. * @returns a shapeUV array
  27106. * @hidden
  27107. */
  27108. private _uvsToShapeUV;
  27109. /**
  27110. * Adds a new particle object in the particles array
  27111. * @param idx particle index in particles array
  27112. * @param id particle id
  27113. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27114. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27115. * @param model particle ModelShape object
  27116. * @param shapeId model shape identifier
  27117. * @param idxInShape index of the particle in the current model
  27118. * @param bInfo model bounding info object
  27119. * @param storage target storage array, if any
  27120. * @hidden
  27121. */
  27122. private _addParticle;
  27123. /**
  27124. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27125. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27126. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27127. * @param nb (positive integer) the number of particles to be created from this model
  27128. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27129. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27130. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27131. * @returns the number of shapes in the system
  27132. */
  27133. addShape(mesh: Mesh, nb: number, options?: {
  27134. positionFunction?: any;
  27135. vertexFunction?: any;
  27136. storage?: [];
  27137. }): number;
  27138. /**
  27139. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27140. * @hidden
  27141. */
  27142. private _rebuildParticle;
  27143. /**
  27144. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27145. * @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.
  27146. * @returns the SPS.
  27147. */
  27148. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27149. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27150. * Returns an array with the removed particles.
  27151. * 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.
  27152. * The SPS can't be empty so at least one particle needs to remain in place.
  27153. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27154. * @param start index of the first particle to remove
  27155. * @param end index of the last particle to remove (included)
  27156. * @returns an array populated with the removed particles
  27157. */
  27158. removeParticles(start: number, end: number): SolidParticle[];
  27159. /**
  27160. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27161. * @param solidParticleArray an array populated with Solid Particles objects
  27162. * @returns the SPS
  27163. */
  27164. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27165. /**
  27166. * Creates a new particle and modifies the SPS mesh geometry :
  27167. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27168. * - calls _addParticle() to populate the particle array
  27169. * factorized code from addShape() and insertParticlesFromArray()
  27170. * @param idx particle index in the particles array
  27171. * @param i particle index in its shape
  27172. * @param modelShape particle ModelShape object
  27173. * @param shape shape vertex array
  27174. * @param meshInd shape indices array
  27175. * @param meshUV shape uv array
  27176. * @param meshCol shape color array
  27177. * @param meshNor shape normals array
  27178. * @param bbInfo shape bounding info
  27179. * @param storage target particle storage
  27180. * @options addShape() passed options
  27181. * @hidden
  27182. */
  27183. private _insertNewParticle;
  27184. /**
  27185. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27186. * This method calls `updateParticle()` for each particle of the SPS.
  27187. * For an animated SPS, it is usually called within the render loop.
  27188. * 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.
  27189. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27190. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27191. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27192. * @returns the SPS.
  27193. */
  27194. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27195. /**
  27196. * Disposes the SPS.
  27197. */
  27198. dispose(): void;
  27199. /**
  27200. * Returns a SolidParticle object from its identifier : particle.id
  27201. * @param id (integer) the particle Id
  27202. * @returns the searched particle or null if not found in the SPS.
  27203. */
  27204. getParticleById(id: number): Nullable<SolidParticle>;
  27205. /**
  27206. * Returns a new array populated with the particles having the passed shapeId.
  27207. * @param shapeId (integer) the shape identifier
  27208. * @returns a new solid particle array
  27209. */
  27210. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27211. /**
  27212. * Populates the passed array "ref" with the particles having the passed shapeId.
  27213. * @param shapeId the shape identifier
  27214. * @returns the SPS
  27215. * @param ref
  27216. */
  27217. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27218. /**
  27219. * Computes the required SubMeshes according the materials assigned to the particles.
  27220. * @returns the solid particle system.
  27221. * Does nothing if called before the SPS mesh is built.
  27222. */
  27223. computeSubMeshes(): SolidParticleSystem;
  27224. /**
  27225. * Sorts the solid particles by material when MultiMaterial is enabled.
  27226. * Updates the indices32 array.
  27227. * Updates the indicesByMaterial array.
  27228. * Updates the mesh indices array.
  27229. * @returns the SPS
  27230. * @hidden
  27231. */
  27232. private _sortParticlesByMaterial;
  27233. /**
  27234. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27235. * @hidden
  27236. */
  27237. private _setMaterialIndexesById;
  27238. /**
  27239. * Returns an array with unique values of Materials from the passed array
  27240. * @param array the material array to be checked and filtered
  27241. * @hidden
  27242. */
  27243. private _filterUniqueMaterialId;
  27244. /**
  27245. * Sets a new Standard Material as _defaultMaterial if not already set.
  27246. * @hidden
  27247. */
  27248. private _setDefaultMaterial;
  27249. /**
  27250. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27252. * @returns the SPS.
  27253. */
  27254. refreshVisibleSize(): SolidParticleSystem;
  27255. /**
  27256. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27257. * @param size the size (float) of the visibility box
  27258. * note : this doesn't lock the SPS mesh bounding box.
  27259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27260. */
  27261. setVisibilityBox(size: number): void;
  27262. /**
  27263. * Gets whether the SPS as always visible or not
  27264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27265. */
  27266. get isAlwaysVisible(): boolean;
  27267. /**
  27268. * Sets the SPS as always visible or not
  27269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27270. */
  27271. set isAlwaysVisible(val: boolean);
  27272. /**
  27273. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27275. */
  27276. set isVisibilityBoxLocked(val: boolean);
  27277. /**
  27278. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27280. */
  27281. get isVisibilityBoxLocked(): boolean;
  27282. /**
  27283. * Tells to `setParticles()` to compute the particle rotations or not.
  27284. * Default value : true. The SPS is faster when it's set to false.
  27285. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27286. */
  27287. set computeParticleRotation(val: boolean);
  27288. /**
  27289. * Tells to `setParticles()` to compute the particle colors or not.
  27290. * Default value : true. The SPS is faster when it's set to false.
  27291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27292. */
  27293. set computeParticleColor(val: boolean);
  27294. set computeParticleTexture(val: boolean);
  27295. /**
  27296. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27297. * Default value : false. The SPS is faster when it's set to false.
  27298. * Note : the particle custom vertex positions aren't stored values.
  27299. */
  27300. set computeParticleVertex(val: boolean);
  27301. /**
  27302. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27303. */
  27304. set computeBoundingBox(val: boolean);
  27305. /**
  27306. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27307. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27308. * Default : `true`
  27309. */
  27310. set depthSortParticles(val: boolean);
  27311. /**
  27312. * Gets if `setParticles()` computes the particle rotations or not.
  27313. * Default value : true. The SPS is faster when it's set to false.
  27314. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27315. */
  27316. get computeParticleRotation(): boolean;
  27317. /**
  27318. * Gets if `setParticles()` computes the particle colors or not.
  27319. * Default value : true. The SPS is faster when it's set to false.
  27320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27321. */
  27322. get computeParticleColor(): boolean;
  27323. /**
  27324. * Gets if `setParticles()` computes the particle textures or not.
  27325. * Default value : true. The SPS is faster when it's set to false.
  27326. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27327. */
  27328. get computeParticleTexture(): boolean;
  27329. /**
  27330. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27331. * Default value : false. The SPS is faster when it's set to false.
  27332. * Note : the particle custom vertex positions aren't stored values.
  27333. */
  27334. get computeParticleVertex(): boolean;
  27335. /**
  27336. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27337. */
  27338. get computeBoundingBox(): boolean;
  27339. /**
  27340. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27342. * Default : `true`
  27343. */
  27344. get depthSortParticles(): boolean;
  27345. /**
  27346. * Gets if the SPS is created as expandable at construction time.
  27347. * Default : `false`
  27348. */
  27349. get expandable(): boolean;
  27350. /**
  27351. * Gets if the SPS supports the Multi Materials
  27352. */
  27353. get multimaterialEnabled(): boolean;
  27354. /**
  27355. * Gets if the SPS uses the model materials for its own multimaterial.
  27356. */
  27357. get useModelMaterial(): boolean;
  27358. /**
  27359. * The SPS used material array.
  27360. */
  27361. get materials(): Material[];
  27362. /**
  27363. * Sets the SPS MultiMaterial from the passed materials.
  27364. * Note : the passed array is internally copied and not used then by reference.
  27365. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27366. */
  27367. setMultiMaterial(materials: Material[]): void;
  27368. /**
  27369. * The SPS computed multimaterial object
  27370. */
  27371. get multimaterial(): MultiMaterial;
  27372. set multimaterial(mm: MultiMaterial);
  27373. /**
  27374. * If the subMeshes must be updated on the next call to setParticles()
  27375. */
  27376. get autoUpdateSubMeshes(): boolean;
  27377. set autoUpdateSubMeshes(val: boolean);
  27378. /**
  27379. * This function does nothing. It may be overwritten to set all the particle first values.
  27380. * The SPS doesn't call this function, you may have to call it by your own.
  27381. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27382. */
  27383. initParticles(): void;
  27384. /**
  27385. * This function does nothing. It may be overwritten to recycle a particle.
  27386. * The SPS doesn't call this function, you may have to call it by your own.
  27387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27388. * @param particle The particle to recycle
  27389. * @returns the recycled particle
  27390. */
  27391. recycleParticle(particle: SolidParticle): SolidParticle;
  27392. /**
  27393. * Updates a particle : this function should be overwritten by the user.
  27394. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27395. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27396. * @example : just set a particle position or velocity and recycle conditions
  27397. * @param particle The particle to update
  27398. * @returns the updated particle
  27399. */
  27400. updateParticle(particle: SolidParticle): SolidParticle;
  27401. /**
  27402. * Updates a vertex of a particle : it can be overwritten by the user.
  27403. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27404. * @param particle the current particle
  27405. * @param vertex the current index of the current particle
  27406. * @param pt the index of the current vertex in the particle shape
  27407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27408. * @example : just set a vertex particle position
  27409. * @returns the updated vertex
  27410. */
  27411. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27412. /**
  27413. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27414. * This does nothing and may be overwritten by the user.
  27415. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27416. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27417. * @param update the boolean update value actually passed to setParticles()
  27418. */
  27419. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27420. /**
  27421. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27422. * This will be passed three parameters.
  27423. * This does nothing and may be overwritten by the user.
  27424. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27425. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27426. * @param update the boolean update value actually passed to setParticles()
  27427. */
  27428. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. /**
  27433. * Represents one particle of a solid particle system.
  27434. */
  27435. export class SolidParticle {
  27436. /**
  27437. * particle global index
  27438. */
  27439. idx: number;
  27440. /**
  27441. * particle identifier
  27442. */
  27443. id: number;
  27444. /**
  27445. * The color of the particle
  27446. */
  27447. color: Nullable<Color4>;
  27448. /**
  27449. * The world space position of the particle.
  27450. */
  27451. position: Vector3;
  27452. /**
  27453. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27454. */
  27455. rotation: Vector3;
  27456. /**
  27457. * The world space rotation quaternion of the particle.
  27458. */
  27459. rotationQuaternion: Nullable<Quaternion>;
  27460. /**
  27461. * The scaling of the particle.
  27462. */
  27463. scaling: Vector3;
  27464. /**
  27465. * The uvs of the particle.
  27466. */
  27467. uvs: Vector4;
  27468. /**
  27469. * The current speed of the particle.
  27470. */
  27471. velocity: Vector3;
  27472. /**
  27473. * The pivot point in the particle local space.
  27474. */
  27475. pivot: Vector3;
  27476. /**
  27477. * Must the particle be translated from its pivot point in its local space ?
  27478. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27479. * Default : false
  27480. */
  27481. translateFromPivot: boolean;
  27482. /**
  27483. * Is the particle active or not ?
  27484. */
  27485. alive: boolean;
  27486. /**
  27487. * Is the particle visible or not ?
  27488. */
  27489. isVisible: boolean;
  27490. /**
  27491. * Index of this particle in the global "positions" array (Internal use)
  27492. * @hidden
  27493. */
  27494. _pos: number;
  27495. /**
  27496. * @hidden Index of this particle in the global "indices" array (Internal use)
  27497. */
  27498. _ind: number;
  27499. /**
  27500. * @hidden ModelShape of this particle (Internal use)
  27501. */
  27502. _model: ModelShape;
  27503. /**
  27504. * ModelShape id of this particle
  27505. */
  27506. shapeId: number;
  27507. /**
  27508. * Index of the particle in its shape id
  27509. */
  27510. idxInShape: number;
  27511. /**
  27512. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27513. */
  27514. _modelBoundingInfo: BoundingInfo;
  27515. /**
  27516. * @hidden Particle BoundingInfo object (Internal use)
  27517. */
  27518. _boundingInfo: BoundingInfo;
  27519. /**
  27520. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27521. */
  27522. _sps: SolidParticleSystem;
  27523. /**
  27524. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27525. */
  27526. _stillInvisible: boolean;
  27527. /**
  27528. * @hidden Last computed particle rotation matrix
  27529. */
  27530. _rotationMatrix: number[];
  27531. /**
  27532. * Parent particle Id, if any.
  27533. * Default null.
  27534. */
  27535. parentId: Nullable<number>;
  27536. /**
  27537. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27538. */
  27539. materialIndex: Nullable<number>;
  27540. /**
  27541. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27542. * The possible values are :
  27543. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27544. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27547. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27548. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27549. * */
  27550. cullingStrategy: number;
  27551. /**
  27552. * @hidden Internal global position in the SPS.
  27553. */
  27554. _globalPosition: Vector3;
  27555. /**
  27556. * Creates a Solid Particle object.
  27557. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27558. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27559. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27560. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27561. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27562. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27563. * @param shapeId (integer) is the model shape identifier in the SPS.
  27564. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27565. * @param sps defines the sps it is associated to
  27566. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27567. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27568. */
  27569. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27570. /**
  27571. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27572. * @param target the particle target
  27573. * @returns the current particle
  27574. */
  27575. copyToRef(target: SolidParticle): SolidParticle;
  27576. /**
  27577. * Legacy support, changed scale to scaling
  27578. */
  27579. get scale(): Vector3;
  27580. /**
  27581. * Legacy support, changed scale to scaling
  27582. */
  27583. set scale(scale: Vector3);
  27584. /**
  27585. * Legacy support, changed quaternion to rotationQuaternion
  27586. */
  27587. get quaternion(): Nullable<Quaternion>;
  27588. /**
  27589. * Legacy support, changed quaternion to rotationQuaternion
  27590. */
  27591. set quaternion(q: Nullable<Quaternion>);
  27592. /**
  27593. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27594. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27595. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27596. * @returns true if it intersects
  27597. */
  27598. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27599. /**
  27600. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27601. * A particle is in the frustum if its bounding box intersects the frustum
  27602. * @param frustumPlanes defines the frustum to test
  27603. * @returns true if the particle is in the frustum planes
  27604. */
  27605. isInFrustum(frustumPlanes: Plane[]): boolean;
  27606. /**
  27607. * get the rotation matrix of the particle
  27608. * @hidden
  27609. */
  27610. getRotationMatrix(m: Matrix): void;
  27611. }
  27612. /**
  27613. * Represents the shape of the model used by one particle of a solid particle system.
  27614. * SPS internal tool, don't use it manually.
  27615. */
  27616. export class ModelShape {
  27617. /**
  27618. * The shape id
  27619. * @hidden
  27620. */
  27621. shapeID: number;
  27622. /**
  27623. * flat array of model positions (internal use)
  27624. * @hidden
  27625. */
  27626. _shape: Vector3[];
  27627. /**
  27628. * flat array of model UVs (internal use)
  27629. * @hidden
  27630. */
  27631. _shapeUV: number[];
  27632. /**
  27633. * color array of the model
  27634. * @hidden
  27635. */
  27636. _shapeColors: number[];
  27637. /**
  27638. * indices array of the model
  27639. * @hidden
  27640. */
  27641. _indices: number[];
  27642. /**
  27643. * normals array of the model
  27644. * @hidden
  27645. */
  27646. _normals: number[];
  27647. /**
  27648. * length of the shape in the model indices array (internal use)
  27649. * @hidden
  27650. */
  27651. _indicesLength: number;
  27652. /**
  27653. * Custom position function (internal use)
  27654. * @hidden
  27655. */
  27656. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27657. /**
  27658. * Custom vertex function (internal use)
  27659. * @hidden
  27660. */
  27661. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27662. /**
  27663. * Model material (internal use)
  27664. * @hidden
  27665. */
  27666. _material: Nullable<Material>;
  27667. /**
  27668. * 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.
  27669. * SPS internal tool, don't use it manually.
  27670. * @hidden
  27671. */
  27672. 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>);
  27673. }
  27674. /**
  27675. * Represents a Depth Sorted Particle in the solid particle system.
  27676. * @hidden
  27677. */
  27678. export class DepthSortedParticle {
  27679. /**
  27680. * Index of the particle in the "indices" array
  27681. */
  27682. ind: number;
  27683. /**
  27684. * Length of the particle shape in the "indices" array
  27685. */
  27686. indicesLength: number;
  27687. /**
  27688. * Squared distance from the particle to the camera
  27689. */
  27690. sqDistance: number;
  27691. /**
  27692. * Material index when used with MultiMaterials
  27693. */
  27694. materialIndex: number;
  27695. /**
  27696. * Creates a new sorted particle
  27697. * @param materialIndex
  27698. */
  27699. constructor(ind: number, indLength: number, materialIndex: number);
  27700. }
  27701. }
  27702. declare module BABYLON {
  27703. /**
  27704. * @hidden
  27705. */
  27706. export class _MeshCollisionData {
  27707. _checkCollisions: boolean;
  27708. _collisionMask: number;
  27709. _collisionGroup: number;
  27710. _collider: Nullable<Collider>;
  27711. _oldPositionForCollisions: Vector3;
  27712. _diffPositionForCollisions: Vector3;
  27713. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27714. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27715. }
  27716. }
  27717. declare module BABYLON {
  27718. /** @hidden */
  27719. class _FacetDataStorage {
  27720. facetPositions: Vector3[];
  27721. facetNormals: Vector3[];
  27722. facetPartitioning: number[][];
  27723. facetNb: number;
  27724. partitioningSubdivisions: number;
  27725. partitioningBBoxRatio: number;
  27726. facetDataEnabled: boolean;
  27727. facetParameters: any;
  27728. bbSize: Vector3;
  27729. subDiv: {
  27730. max: number;
  27731. X: number;
  27732. Y: number;
  27733. Z: number;
  27734. };
  27735. facetDepthSort: boolean;
  27736. facetDepthSortEnabled: boolean;
  27737. depthSortedIndices: IndicesArray;
  27738. depthSortedFacets: {
  27739. ind: number;
  27740. sqDistance: number;
  27741. }[];
  27742. facetDepthSortFunction: (f1: {
  27743. ind: number;
  27744. sqDistance: number;
  27745. }, f2: {
  27746. ind: number;
  27747. sqDistance: number;
  27748. }) => number;
  27749. facetDepthSortFrom: Vector3;
  27750. facetDepthSortOrigin: Vector3;
  27751. invertedMatrix: Matrix;
  27752. }
  27753. /**
  27754. * @hidden
  27755. **/
  27756. class _InternalAbstractMeshDataInfo {
  27757. _hasVertexAlpha: boolean;
  27758. _useVertexColors: boolean;
  27759. _numBoneInfluencers: number;
  27760. _applyFog: boolean;
  27761. _receiveShadows: boolean;
  27762. _facetData: _FacetDataStorage;
  27763. _visibility: number;
  27764. _skeleton: Nullable<Skeleton>;
  27765. _layerMask: number;
  27766. _computeBonesUsingShaders: boolean;
  27767. _isActive: boolean;
  27768. _onlyForInstances: boolean;
  27769. _isActiveIntermediate: boolean;
  27770. _onlyForInstancesIntermediate: boolean;
  27771. _actAsRegularMesh: boolean;
  27772. }
  27773. /**
  27774. * Class used to store all common mesh properties
  27775. */
  27776. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27777. /** No occlusion */
  27778. static OCCLUSION_TYPE_NONE: number;
  27779. /** Occlusion set to optimisitic */
  27780. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27781. /** Occlusion set to strict */
  27782. static OCCLUSION_TYPE_STRICT: number;
  27783. /** Use an accurante occlusion algorithm */
  27784. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27785. /** Use a conservative occlusion algorithm */
  27786. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27787. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27788. * Test order :
  27789. * Is the bounding sphere outside the frustum ?
  27790. * If not, are the bounding box vertices outside the frustum ?
  27791. * It not, then the cullable object is in the frustum.
  27792. */
  27793. static readonly CULLINGSTRATEGY_STANDARD: number;
  27794. /** Culling strategy : Bounding Sphere Only.
  27795. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27796. * It's also less accurate than the standard because some not visible objects can still be selected.
  27797. * Test : is the bounding sphere outside the frustum ?
  27798. * If not, then the cullable object is in the frustum.
  27799. */
  27800. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27801. /** Culling strategy : Optimistic Inclusion.
  27802. * This in an inclusion test first, then the standard exclusion test.
  27803. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27804. * 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.
  27805. * Anyway, it's as accurate as the standard strategy.
  27806. * Test :
  27807. * Is the cullable object bounding sphere center in the frustum ?
  27808. * If not, apply the default culling strategy.
  27809. */
  27810. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27811. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27812. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27813. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27814. * 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.
  27815. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27816. * Test :
  27817. * Is the cullable object bounding sphere center in the frustum ?
  27818. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27819. */
  27820. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27821. /**
  27822. * No billboard
  27823. */
  27824. static get BILLBOARDMODE_NONE(): number;
  27825. /** Billboard on X axis */
  27826. static get BILLBOARDMODE_X(): number;
  27827. /** Billboard on Y axis */
  27828. static get BILLBOARDMODE_Y(): number;
  27829. /** Billboard on Z axis */
  27830. static get BILLBOARDMODE_Z(): number;
  27831. /** Billboard on all axes */
  27832. static get BILLBOARDMODE_ALL(): number;
  27833. /** Billboard on using position instead of orientation */
  27834. static get BILLBOARDMODE_USE_POSITION(): number;
  27835. /** @hidden */
  27836. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27837. /**
  27838. * The culling strategy to use to check whether the mesh must be rendered or not.
  27839. * This value can be changed at any time and will be used on the next render mesh selection.
  27840. * The possible values are :
  27841. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27842. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27843. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27844. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27845. * Please read each static variable documentation to get details about the culling process.
  27846. * */
  27847. cullingStrategy: number;
  27848. /**
  27849. * Gets the number of facets in the mesh
  27850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27851. */
  27852. get facetNb(): number;
  27853. /**
  27854. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27856. */
  27857. get partitioningSubdivisions(): number;
  27858. set partitioningSubdivisions(nb: number);
  27859. /**
  27860. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27861. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27863. */
  27864. get partitioningBBoxRatio(): number;
  27865. set partitioningBBoxRatio(ratio: number);
  27866. /**
  27867. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27868. * Works only for updatable meshes.
  27869. * Doesn't work with multi-materials
  27870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27871. */
  27872. get mustDepthSortFacets(): boolean;
  27873. set mustDepthSortFacets(sort: boolean);
  27874. /**
  27875. * The location (Vector3) where the facet depth sort must be computed from.
  27876. * By default, the active camera position.
  27877. * Used only when facet depth sort is enabled
  27878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27879. */
  27880. get facetDepthSortFrom(): Vector3;
  27881. set facetDepthSortFrom(location: Vector3);
  27882. /**
  27883. * gets a boolean indicating if facetData is enabled
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27885. */
  27886. get isFacetDataEnabled(): boolean;
  27887. /** @hidden */
  27888. _updateNonUniformScalingState(value: boolean): boolean;
  27889. /**
  27890. * An event triggered when this mesh collides with another one
  27891. */
  27892. onCollideObservable: Observable<AbstractMesh>;
  27893. /** Set a function to call when this mesh collides with another one */
  27894. set onCollide(callback: () => void);
  27895. /**
  27896. * An event triggered when the collision's position changes
  27897. */
  27898. onCollisionPositionChangeObservable: Observable<Vector3>;
  27899. /** Set a function to call when the collision's position changes */
  27900. set onCollisionPositionChange(callback: () => void);
  27901. /**
  27902. * An event triggered when material is changed
  27903. */
  27904. onMaterialChangedObservable: Observable<AbstractMesh>;
  27905. /**
  27906. * Gets or sets the orientation for POV movement & rotation
  27907. */
  27908. definedFacingForward: boolean;
  27909. /** @hidden */
  27910. _occlusionQuery: Nullable<WebGLQuery>;
  27911. /** @hidden */
  27912. _renderingGroup: Nullable<RenderingGroup>;
  27913. /**
  27914. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27915. */
  27916. get visibility(): number;
  27917. /**
  27918. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27919. */
  27920. set visibility(value: number);
  27921. /** Gets or sets the alpha index used to sort transparent meshes
  27922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27923. */
  27924. alphaIndex: number;
  27925. /**
  27926. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27927. */
  27928. isVisible: boolean;
  27929. /**
  27930. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27931. */
  27932. isPickable: boolean;
  27933. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27934. showSubMeshesBoundingBox: boolean;
  27935. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27936. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27937. */
  27938. isBlocker: boolean;
  27939. /**
  27940. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27941. */
  27942. enablePointerMoveEvents: boolean;
  27943. /**
  27944. * Specifies the rendering group id for this mesh (0 by default)
  27945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27946. */
  27947. renderingGroupId: number;
  27948. private _material;
  27949. /** Gets or sets current material */
  27950. get material(): Nullable<Material>;
  27951. set material(value: Nullable<Material>);
  27952. /**
  27953. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27954. * @see http://doc.babylonjs.com/babylon101/shadows
  27955. */
  27956. get receiveShadows(): boolean;
  27957. set receiveShadows(value: boolean);
  27958. /** Defines color to use when rendering outline */
  27959. outlineColor: Color3;
  27960. /** Define width to use when rendering outline */
  27961. outlineWidth: number;
  27962. /** Defines color to use when rendering overlay */
  27963. overlayColor: Color3;
  27964. /** Defines alpha to use when rendering overlay */
  27965. overlayAlpha: number;
  27966. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27967. get hasVertexAlpha(): boolean;
  27968. set hasVertexAlpha(value: boolean);
  27969. /** 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) */
  27970. get useVertexColors(): boolean;
  27971. set useVertexColors(value: boolean);
  27972. /**
  27973. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27974. */
  27975. get computeBonesUsingShaders(): boolean;
  27976. set computeBonesUsingShaders(value: boolean);
  27977. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27978. get numBoneInfluencers(): number;
  27979. set numBoneInfluencers(value: number);
  27980. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27981. get applyFog(): boolean;
  27982. set applyFog(value: boolean);
  27983. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27984. useOctreeForRenderingSelection: boolean;
  27985. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27986. useOctreeForPicking: boolean;
  27987. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27988. useOctreeForCollisions: boolean;
  27989. /**
  27990. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27991. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27992. */
  27993. get layerMask(): number;
  27994. set layerMask(value: number);
  27995. /**
  27996. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27997. */
  27998. alwaysSelectAsActiveMesh: boolean;
  27999. /**
  28000. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28001. */
  28002. doNotSyncBoundingInfo: boolean;
  28003. /**
  28004. * Gets or sets the current action manager
  28005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28006. */
  28007. actionManager: Nullable<AbstractActionManager>;
  28008. private _meshCollisionData;
  28009. /**
  28010. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28012. */
  28013. ellipsoid: Vector3;
  28014. /**
  28015. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28017. */
  28018. ellipsoidOffset: Vector3;
  28019. /**
  28020. * Gets or sets a collision mask used to mask collisions (default is -1).
  28021. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28022. */
  28023. get collisionMask(): number;
  28024. set collisionMask(mask: number);
  28025. /**
  28026. * Gets or sets the current collision group mask (-1 by default).
  28027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28028. */
  28029. get collisionGroup(): number;
  28030. set collisionGroup(mask: number);
  28031. /**
  28032. * Defines edge width used when edgesRenderer is enabled
  28033. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28034. */
  28035. edgesWidth: number;
  28036. /**
  28037. * Defines edge color used when edgesRenderer is enabled
  28038. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28039. */
  28040. edgesColor: Color4;
  28041. /** @hidden */
  28042. _edgesRenderer: Nullable<IEdgesRenderer>;
  28043. /** @hidden */
  28044. _masterMesh: Nullable<AbstractMesh>;
  28045. /** @hidden */
  28046. _boundingInfo: Nullable<BoundingInfo>;
  28047. /** @hidden */
  28048. _renderId: number;
  28049. /**
  28050. * Gets or sets the list of subMeshes
  28051. * @see http://doc.babylonjs.com/how_to/multi_materials
  28052. */
  28053. subMeshes: SubMesh[];
  28054. /** @hidden */
  28055. _intersectionsInProgress: AbstractMesh[];
  28056. /** @hidden */
  28057. _unIndexed: boolean;
  28058. /** @hidden */
  28059. _lightSources: Light[];
  28060. /** Gets the list of lights affecting that mesh */
  28061. get lightSources(): Light[];
  28062. /** @hidden */
  28063. get _positions(): Nullable<Vector3[]>;
  28064. /** @hidden */
  28065. _waitingData: {
  28066. lods: Nullable<any>;
  28067. actions: Nullable<any>;
  28068. freezeWorldMatrix: Nullable<boolean>;
  28069. };
  28070. /** @hidden */
  28071. _bonesTransformMatrices: Nullable<Float32Array>;
  28072. /** @hidden */
  28073. _transformMatrixTexture: Nullable<RawTexture>;
  28074. /**
  28075. * Gets or sets a skeleton to apply skining transformations
  28076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28077. */
  28078. set skeleton(value: Nullable<Skeleton>);
  28079. get skeleton(): Nullable<Skeleton>;
  28080. /**
  28081. * An event triggered when the mesh is rebuilt.
  28082. */
  28083. onRebuildObservable: Observable<AbstractMesh>;
  28084. /**
  28085. * Creates a new AbstractMesh
  28086. * @param name defines the name of the mesh
  28087. * @param scene defines the hosting scene
  28088. */
  28089. constructor(name: string, scene?: Nullable<Scene>);
  28090. /**
  28091. * Returns the string "AbstractMesh"
  28092. * @returns "AbstractMesh"
  28093. */
  28094. getClassName(): string;
  28095. /**
  28096. * Gets a string representation of the current mesh
  28097. * @param fullDetails defines a boolean indicating if full details must be included
  28098. * @returns a string representation of the current mesh
  28099. */
  28100. toString(fullDetails?: boolean): string;
  28101. /**
  28102. * @hidden
  28103. */
  28104. protected _getEffectiveParent(): Nullable<Node>;
  28105. /** @hidden */
  28106. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28107. /** @hidden */
  28108. _rebuild(): void;
  28109. /** @hidden */
  28110. _resyncLightSources(): void;
  28111. /** @hidden */
  28112. _resyncLightSource(light: Light): void;
  28113. /** @hidden */
  28114. _unBindEffect(): void;
  28115. /** @hidden */
  28116. _removeLightSource(light: Light, dispose: boolean): void;
  28117. private _markSubMeshesAsDirty;
  28118. /** @hidden */
  28119. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28120. /** @hidden */
  28121. _markSubMeshesAsAttributesDirty(): void;
  28122. /** @hidden */
  28123. _markSubMeshesAsMiscDirty(): void;
  28124. /**
  28125. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28126. */
  28127. get scaling(): Vector3;
  28128. set scaling(newScaling: Vector3);
  28129. /**
  28130. * Returns true if the mesh is blocked. Implemented by child classes
  28131. */
  28132. get isBlocked(): boolean;
  28133. /**
  28134. * Returns the mesh itself by default. Implemented by child classes
  28135. * @param camera defines the camera to use to pick the right LOD level
  28136. * @returns the currentAbstractMesh
  28137. */
  28138. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28139. /**
  28140. * Returns 0 by default. Implemented by child classes
  28141. * @returns an integer
  28142. */
  28143. getTotalVertices(): number;
  28144. /**
  28145. * Returns a positive integer : the total number of indices in this mesh geometry.
  28146. * @returns the numner of indices or zero if the mesh has no geometry.
  28147. */
  28148. getTotalIndices(): number;
  28149. /**
  28150. * Returns null by default. Implemented by child classes
  28151. * @returns null
  28152. */
  28153. getIndices(): Nullable<IndicesArray>;
  28154. /**
  28155. * Returns the array of the requested vertex data kind. Implemented by child classes
  28156. * @param kind defines the vertex data kind to use
  28157. * @returns null
  28158. */
  28159. getVerticesData(kind: string): Nullable<FloatArray>;
  28160. /**
  28161. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28162. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28163. * Note that a new underlying VertexBuffer object is created each call.
  28164. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28165. * @param kind defines vertex data kind:
  28166. * * VertexBuffer.PositionKind
  28167. * * VertexBuffer.UVKind
  28168. * * VertexBuffer.UV2Kind
  28169. * * VertexBuffer.UV3Kind
  28170. * * VertexBuffer.UV4Kind
  28171. * * VertexBuffer.UV5Kind
  28172. * * VertexBuffer.UV6Kind
  28173. * * VertexBuffer.ColorKind
  28174. * * VertexBuffer.MatricesIndicesKind
  28175. * * VertexBuffer.MatricesIndicesExtraKind
  28176. * * VertexBuffer.MatricesWeightsKind
  28177. * * VertexBuffer.MatricesWeightsExtraKind
  28178. * @param data defines the data source
  28179. * @param updatable defines if the data must be flagged as updatable (or static)
  28180. * @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
  28181. * @returns the current mesh
  28182. */
  28183. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28184. /**
  28185. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28186. * If the mesh has no geometry, it is simply returned as it is.
  28187. * @param kind defines vertex data kind:
  28188. * * VertexBuffer.PositionKind
  28189. * * VertexBuffer.UVKind
  28190. * * VertexBuffer.UV2Kind
  28191. * * VertexBuffer.UV3Kind
  28192. * * VertexBuffer.UV4Kind
  28193. * * VertexBuffer.UV5Kind
  28194. * * VertexBuffer.UV6Kind
  28195. * * VertexBuffer.ColorKind
  28196. * * VertexBuffer.MatricesIndicesKind
  28197. * * VertexBuffer.MatricesIndicesExtraKind
  28198. * * VertexBuffer.MatricesWeightsKind
  28199. * * VertexBuffer.MatricesWeightsExtraKind
  28200. * @param data defines the data source
  28201. * @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
  28202. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28203. * @returns the current mesh
  28204. */
  28205. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28206. /**
  28207. * Sets the mesh indices,
  28208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28209. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28210. * @param totalVertices Defines the total number of vertices
  28211. * @returns the current mesh
  28212. */
  28213. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28214. /**
  28215. * Gets a boolean indicating if specific vertex data is present
  28216. * @param kind defines the vertex data kind to use
  28217. * @returns true is data kind is present
  28218. */
  28219. isVerticesDataPresent(kind: string): boolean;
  28220. /**
  28221. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28222. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28223. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28224. * @returns a BoundingInfo
  28225. */
  28226. getBoundingInfo(): BoundingInfo;
  28227. /**
  28228. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28229. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28230. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28231. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28232. * @returns the current mesh
  28233. */
  28234. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28235. /**
  28236. * Overwrite the current bounding info
  28237. * @param boundingInfo defines the new bounding info
  28238. * @returns the current mesh
  28239. */
  28240. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28241. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28242. get useBones(): boolean;
  28243. /** @hidden */
  28244. _preActivate(): void;
  28245. /** @hidden */
  28246. _preActivateForIntermediateRendering(renderId: number): void;
  28247. /** @hidden */
  28248. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28249. /** @hidden */
  28250. _postActivate(): void;
  28251. /** @hidden */
  28252. _freeze(): void;
  28253. /** @hidden */
  28254. _unFreeze(): void;
  28255. /**
  28256. * Gets the current world matrix
  28257. * @returns a Matrix
  28258. */
  28259. getWorldMatrix(): Matrix;
  28260. /** @hidden */
  28261. _getWorldMatrixDeterminant(): number;
  28262. /**
  28263. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28264. */
  28265. get isAnInstance(): boolean;
  28266. /**
  28267. * Gets a boolean indicating if this mesh has instances
  28268. */
  28269. get hasInstances(): boolean;
  28270. /**
  28271. * Perform relative position change from the point of view of behind the front of the mesh.
  28272. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28273. * Supports definition of mesh facing forward or backward
  28274. * @param amountRight defines the distance on the right axis
  28275. * @param amountUp defines the distance on the up axis
  28276. * @param amountForward defines the distance on the forward axis
  28277. * @returns the current mesh
  28278. */
  28279. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28280. /**
  28281. * Calculate relative position change from the point of view of behind the front of the mesh.
  28282. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28283. * Supports definition of mesh facing forward or backward
  28284. * @param amountRight defines the distance on the right axis
  28285. * @param amountUp defines the distance on the up axis
  28286. * @param amountForward defines the distance on the forward axis
  28287. * @returns the new displacement vector
  28288. */
  28289. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28290. /**
  28291. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28292. * Supports definition of mesh facing forward or backward
  28293. * @param flipBack defines the flip
  28294. * @param twirlClockwise defines the twirl
  28295. * @param tiltRight defines the tilt
  28296. * @returns the current mesh
  28297. */
  28298. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28299. /**
  28300. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28301. * Supports definition of mesh facing forward or backward.
  28302. * @param flipBack defines the flip
  28303. * @param twirlClockwise defines the twirl
  28304. * @param tiltRight defines the tilt
  28305. * @returns the new rotation vector
  28306. */
  28307. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28308. /**
  28309. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28310. * This means the mesh underlying bounding box and sphere are recomputed.
  28311. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28312. * @returns the current mesh
  28313. */
  28314. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28315. /** @hidden */
  28316. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28317. /** @hidden */
  28318. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28319. /** @hidden */
  28320. _updateBoundingInfo(): AbstractMesh;
  28321. /** @hidden */
  28322. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28323. /** @hidden */
  28324. protected _afterComputeWorldMatrix(): void;
  28325. /** @hidden */
  28326. get _effectiveMesh(): AbstractMesh;
  28327. /**
  28328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28329. * A mesh is in the frustum if its bounding box intersects the frustum
  28330. * @param frustumPlanes defines the frustum to test
  28331. * @returns true if the mesh is in the frustum planes
  28332. */
  28333. isInFrustum(frustumPlanes: Plane[]): boolean;
  28334. /**
  28335. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28336. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28337. * @param frustumPlanes defines the frustum to test
  28338. * @returns true if the mesh is completely in the frustum planes
  28339. */
  28340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28341. /**
  28342. * True if the mesh intersects another mesh or a SolidParticle object
  28343. * @param mesh defines a target mesh or SolidParticle to test
  28344. * @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)
  28345. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28346. * @returns true if there is an intersection
  28347. */
  28348. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28349. /**
  28350. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28351. * @param point defines the point to test
  28352. * @returns true if there is an intersection
  28353. */
  28354. intersectsPoint(point: Vector3): boolean;
  28355. /**
  28356. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28358. */
  28359. get checkCollisions(): boolean;
  28360. set checkCollisions(collisionEnabled: boolean);
  28361. /**
  28362. * Gets Collider object used to compute collisions (not physics)
  28363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28364. */
  28365. get collider(): Nullable<Collider>;
  28366. /**
  28367. * Move the mesh using collision engine
  28368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28369. * @param displacement defines the requested displacement vector
  28370. * @returns the current mesh
  28371. */
  28372. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28373. private _onCollisionPositionChange;
  28374. /** @hidden */
  28375. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28376. /** @hidden */
  28377. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28378. /** @hidden */
  28379. _checkCollision(collider: Collider): AbstractMesh;
  28380. /** @hidden */
  28381. _generatePointsArray(): boolean;
  28382. /**
  28383. * Checks if the passed Ray intersects with the mesh
  28384. * @param ray defines the ray to use
  28385. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28387. * @returns the picking info
  28388. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28389. */
  28390. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28391. /**
  28392. * Clones the current mesh
  28393. * @param name defines the mesh name
  28394. * @param newParent defines the new mesh parent
  28395. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28396. * @returns the new mesh
  28397. */
  28398. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28399. /**
  28400. * Disposes all the submeshes of the current meshnp
  28401. * @returns the current mesh
  28402. */
  28403. releaseSubMeshes(): AbstractMesh;
  28404. /**
  28405. * Releases resources associated with this abstract mesh.
  28406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28408. */
  28409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28410. /**
  28411. * Adds the passed mesh as a child to the current mesh
  28412. * @param mesh defines the child mesh
  28413. * @returns the current mesh
  28414. */
  28415. addChild(mesh: AbstractMesh): AbstractMesh;
  28416. /**
  28417. * Removes the passed mesh from the current mesh children list
  28418. * @param mesh defines the child mesh
  28419. * @returns the current mesh
  28420. */
  28421. removeChild(mesh: AbstractMesh): AbstractMesh;
  28422. /** @hidden */
  28423. private _initFacetData;
  28424. /**
  28425. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28426. * This method can be called within the render loop.
  28427. * 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
  28428. * @returns the current mesh
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28430. */
  28431. updateFacetData(): AbstractMesh;
  28432. /**
  28433. * Returns the facetLocalNormals array.
  28434. * The normals are expressed in the mesh local spac
  28435. * @returns an array of Vector3
  28436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28437. */
  28438. getFacetLocalNormals(): Vector3[];
  28439. /**
  28440. * Returns the facetLocalPositions array.
  28441. * The facet positions are expressed in the mesh local space
  28442. * @returns an array of Vector3
  28443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28444. */
  28445. getFacetLocalPositions(): Vector3[];
  28446. /**
  28447. * Returns the facetLocalPartioning array
  28448. * @returns an array of array of numbers
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28450. */
  28451. getFacetLocalPartitioning(): number[][];
  28452. /**
  28453. * Returns the i-th facet position in the world system.
  28454. * This method allocates a new Vector3 per call
  28455. * @param i defines the facet index
  28456. * @returns a new Vector3
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28458. */
  28459. getFacetPosition(i: number): Vector3;
  28460. /**
  28461. * Sets the reference Vector3 with the i-th facet position in the world system
  28462. * @param i defines the facet index
  28463. * @param ref defines the target vector
  28464. * @returns the current mesh
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28466. */
  28467. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28468. /**
  28469. * Returns the i-th facet normal in the world system.
  28470. * This method allocates a new Vector3 per call
  28471. * @param i defines the facet index
  28472. * @returns a new Vector3
  28473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28474. */
  28475. getFacetNormal(i: number): Vector3;
  28476. /**
  28477. * Sets the reference Vector3 with the i-th facet normal in the world system
  28478. * @param i defines the facet index
  28479. * @param ref defines the target vector
  28480. * @returns the current mesh
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28482. */
  28483. getFacetNormalToRef(i: number, ref: Vector3): this;
  28484. /**
  28485. * 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)
  28486. * @param x defines x coordinate
  28487. * @param y defines y coordinate
  28488. * @param z defines z coordinate
  28489. * @returns the array of facet indexes
  28490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28491. */
  28492. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28493. /**
  28494. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28495. * @param projected sets as the (x,y,z) world projection on the facet
  28496. * @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
  28497. * @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
  28498. * @param x defines x coordinate
  28499. * @param y defines y coordinate
  28500. * @param z defines z coordinate
  28501. * @returns the face index if found (or null instead)
  28502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28503. */
  28504. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28505. /**
  28506. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28507. * @param projected sets as the (x,y,z) local projection on the facet
  28508. * @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
  28509. * @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
  28510. * @param x defines x coordinate
  28511. * @param y defines y coordinate
  28512. * @param z defines z coordinate
  28513. * @returns the face index if found (or null instead)
  28514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28515. */
  28516. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28517. /**
  28518. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28519. * @returns the parameters
  28520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28521. */
  28522. getFacetDataParameters(): any;
  28523. /**
  28524. * Disables the feature FacetData and frees the related memory
  28525. * @returns the current mesh
  28526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28527. */
  28528. disableFacetData(): AbstractMesh;
  28529. /**
  28530. * Updates the AbstractMesh indices array
  28531. * @param indices defines the data source
  28532. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28533. * @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)
  28534. * @returns the current mesh
  28535. */
  28536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28537. /**
  28538. * Creates new normals data for the mesh
  28539. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28540. * @returns the current mesh
  28541. */
  28542. createNormals(updatable: boolean): AbstractMesh;
  28543. /**
  28544. * Align the mesh with a normal
  28545. * @param normal defines the normal to use
  28546. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28547. * @returns the current mesh
  28548. */
  28549. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28550. /** @hidden */
  28551. _checkOcclusionQuery(): boolean;
  28552. /**
  28553. * Disables the mesh edge rendering mode
  28554. * @returns the currentAbstractMesh
  28555. */
  28556. disableEdgesRendering(): AbstractMesh;
  28557. /**
  28558. * Enables the edge rendering mode on the mesh.
  28559. * This mode makes the mesh edges visible
  28560. * @param epsilon defines the maximal distance between two angles to detect a face
  28561. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28562. * @returns the currentAbstractMesh
  28563. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28564. */
  28565. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28566. }
  28567. }
  28568. declare module BABYLON {
  28569. /**
  28570. * Interface used to define ActionEvent
  28571. */
  28572. export interface IActionEvent {
  28573. /** The mesh or sprite that triggered the action */
  28574. source: any;
  28575. /** The X mouse cursor position at the time of the event */
  28576. pointerX: number;
  28577. /** The Y mouse cursor position at the time of the event */
  28578. pointerY: number;
  28579. /** The mesh that is currently pointed at (can be null) */
  28580. meshUnderPointer: Nullable<AbstractMesh>;
  28581. /** the original (browser) event that triggered the ActionEvent */
  28582. sourceEvent?: any;
  28583. /** additional data for the event */
  28584. additionalData?: any;
  28585. }
  28586. /**
  28587. * ActionEvent is the event being sent when an action is triggered.
  28588. */
  28589. export class ActionEvent implements IActionEvent {
  28590. /** The mesh or sprite that triggered the action */
  28591. source: any;
  28592. /** The X mouse cursor position at the time of the event */
  28593. pointerX: number;
  28594. /** The Y mouse cursor position at the time of the event */
  28595. pointerY: number;
  28596. /** The mesh that is currently pointed at (can be null) */
  28597. meshUnderPointer: Nullable<AbstractMesh>;
  28598. /** the original (browser) event that triggered the ActionEvent */
  28599. sourceEvent?: any;
  28600. /** additional data for the event */
  28601. additionalData?: any;
  28602. /**
  28603. * Creates a new ActionEvent
  28604. * @param source The mesh or sprite that triggered the action
  28605. * @param pointerX The X mouse cursor position at the time of the event
  28606. * @param pointerY The Y mouse cursor position at the time of the event
  28607. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28608. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28609. * @param additionalData additional data for the event
  28610. */
  28611. constructor(
  28612. /** The mesh or sprite that triggered the action */
  28613. source: any,
  28614. /** The X mouse cursor position at the time of the event */
  28615. pointerX: number,
  28616. /** The Y mouse cursor position at the time of the event */
  28617. pointerY: number,
  28618. /** The mesh that is currently pointed at (can be null) */
  28619. meshUnderPointer: Nullable<AbstractMesh>,
  28620. /** the original (browser) event that triggered the ActionEvent */
  28621. sourceEvent?: any,
  28622. /** additional data for the event */
  28623. additionalData?: any);
  28624. /**
  28625. * Helper function to auto-create an ActionEvent from a source mesh.
  28626. * @param source The source mesh that triggered the event
  28627. * @param evt The original (browser) event
  28628. * @param additionalData additional data for the event
  28629. * @returns the new ActionEvent
  28630. */
  28631. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28632. /**
  28633. * Helper function to auto-create an ActionEvent from a source sprite
  28634. * @param source The source sprite that triggered the event
  28635. * @param scene Scene associated with the sprite
  28636. * @param evt The original (browser) event
  28637. * @param additionalData additional data for the event
  28638. * @returns the new ActionEvent
  28639. */
  28640. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28641. /**
  28642. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28643. * @param scene the scene where the event occurred
  28644. * @param evt The original (browser) event
  28645. * @returns the new ActionEvent
  28646. */
  28647. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28648. /**
  28649. * Helper function to auto-create an ActionEvent from a primitive
  28650. * @param prim defines the target primitive
  28651. * @param pointerPos defines the pointer position
  28652. * @param evt The original (browser) event
  28653. * @param additionalData additional data for the event
  28654. * @returns the new ActionEvent
  28655. */
  28656. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * Abstract class used to decouple action Manager from scene and meshes.
  28662. * Do not instantiate.
  28663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28664. */
  28665. export abstract class AbstractActionManager implements IDisposable {
  28666. /** Gets the list of active triggers */
  28667. static Triggers: {
  28668. [key: string]: number;
  28669. };
  28670. /** Gets the cursor to use when hovering items */
  28671. hoverCursor: string;
  28672. /** Gets the list of actions */
  28673. actions: IAction[];
  28674. /**
  28675. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28676. */
  28677. isRecursive: boolean;
  28678. /**
  28679. * Releases all associated resources
  28680. */
  28681. abstract dispose(): void;
  28682. /**
  28683. * Does this action manager has pointer triggers
  28684. */
  28685. abstract get hasPointerTriggers(): boolean;
  28686. /**
  28687. * Does this action manager has pick triggers
  28688. */
  28689. abstract get hasPickTriggers(): boolean;
  28690. /**
  28691. * Process a specific trigger
  28692. * @param trigger defines the trigger to process
  28693. * @param evt defines the event details to be processed
  28694. */
  28695. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28696. /**
  28697. * Does this action manager handles actions of any of the given triggers
  28698. * @param triggers defines the triggers to be tested
  28699. * @return a boolean indicating whether one (or more) of the triggers is handled
  28700. */
  28701. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28702. /**
  28703. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28704. * speed.
  28705. * @param triggerA defines the trigger to be tested
  28706. * @param triggerB defines the trigger to be tested
  28707. * @return a boolean indicating whether one (or more) of the triggers is handled
  28708. */
  28709. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28710. /**
  28711. * Does this action manager handles actions of a given trigger
  28712. * @param trigger defines the trigger to be tested
  28713. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28714. * @return whether the trigger is handled
  28715. */
  28716. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28717. /**
  28718. * Serialize this manager to a JSON object
  28719. * @param name defines the property name to store this manager
  28720. * @returns a JSON representation of this manager
  28721. */
  28722. abstract serialize(name: string): any;
  28723. /**
  28724. * Registers an action to this action manager
  28725. * @param action defines the action to be registered
  28726. * @return the action amended (prepared) after registration
  28727. */
  28728. abstract registerAction(action: IAction): Nullable<IAction>;
  28729. /**
  28730. * Unregisters an action to this action manager
  28731. * @param action defines the action to be unregistered
  28732. * @return a boolean indicating whether the action has been unregistered
  28733. */
  28734. abstract unregisterAction(action: IAction): Boolean;
  28735. /**
  28736. * Does exist one action manager with at least one trigger
  28737. **/
  28738. static get HasTriggers(): boolean;
  28739. /**
  28740. * Does exist one action manager with at least one pick trigger
  28741. **/
  28742. static get HasPickTriggers(): boolean;
  28743. /**
  28744. * Does exist one action manager that handles actions of a given trigger
  28745. * @param trigger defines the trigger to be tested
  28746. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28747. **/
  28748. static HasSpecificTrigger(trigger: number): boolean;
  28749. }
  28750. }
  28751. declare module BABYLON {
  28752. /**
  28753. * Defines how a node can be built from a string name.
  28754. */
  28755. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28756. /**
  28757. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28758. */
  28759. export class Node implements IBehaviorAware<Node> {
  28760. /** @hidden */
  28761. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28762. private static _NodeConstructors;
  28763. /**
  28764. * Add a new node constructor
  28765. * @param type defines the type name of the node to construct
  28766. * @param constructorFunc defines the constructor function
  28767. */
  28768. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28769. /**
  28770. * Returns a node constructor based on type name
  28771. * @param type defines the type name
  28772. * @param name defines the new node name
  28773. * @param scene defines the hosting scene
  28774. * @param options defines optional options to transmit to constructors
  28775. * @returns the new constructor or null
  28776. */
  28777. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28778. /**
  28779. * Gets or sets the name of the node
  28780. */
  28781. name: string;
  28782. /**
  28783. * Gets or sets the id of the node
  28784. */
  28785. id: string;
  28786. /**
  28787. * Gets or sets the unique id of the node
  28788. */
  28789. uniqueId: number;
  28790. /**
  28791. * Gets or sets a string used to store user defined state for the node
  28792. */
  28793. state: string;
  28794. /**
  28795. * Gets or sets an object used to store user defined information for the node
  28796. */
  28797. metadata: any;
  28798. /**
  28799. * For internal use only. Please do not use.
  28800. */
  28801. reservedDataStore: any;
  28802. /**
  28803. * List of inspectable custom properties (used by the Inspector)
  28804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28805. */
  28806. inspectableCustomProperties: IInspectable[];
  28807. private _doNotSerialize;
  28808. /**
  28809. * Gets or sets a boolean used to define if the node must be serialized
  28810. */
  28811. get doNotSerialize(): boolean;
  28812. set doNotSerialize(value: boolean);
  28813. /** @hidden */
  28814. _isDisposed: boolean;
  28815. /**
  28816. * Gets a list of Animations associated with the node
  28817. */
  28818. animations: Animation[];
  28819. protected _ranges: {
  28820. [name: string]: Nullable<AnimationRange>;
  28821. };
  28822. /**
  28823. * Callback raised when the node is ready to be used
  28824. */
  28825. onReady: Nullable<(node: Node) => void>;
  28826. private _isEnabled;
  28827. private _isParentEnabled;
  28828. private _isReady;
  28829. /** @hidden */
  28830. _currentRenderId: number;
  28831. private _parentUpdateId;
  28832. /** @hidden */
  28833. _childUpdateId: number;
  28834. /** @hidden */
  28835. _waitingParentId: Nullable<string>;
  28836. /** @hidden */
  28837. _scene: Scene;
  28838. /** @hidden */
  28839. _cache: any;
  28840. private _parentNode;
  28841. private _children;
  28842. /** @hidden */
  28843. _worldMatrix: Matrix;
  28844. /** @hidden */
  28845. _worldMatrixDeterminant: number;
  28846. /** @hidden */
  28847. _worldMatrixDeterminantIsDirty: boolean;
  28848. /** @hidden */
  28849. private _sceneRootNodesIndex;
  28850. /**
  28851. * Gets a boolean indicating if the node has been disposed
  28852. * @returns true if the node was disposed
  28853. */
  28854. isDisposed(): boolean;
  28855. /**
  28856. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28857. * @see https://doc.babylonjs.com/how_to/parenting
  28858. */
  28859. set parent(parent: Nullable<Node>);
  28860. get parent(): Nullable<Node>;
  28861. /** @hidden */
  28862. _addToSceneRootNodes(): void;
  28863. /** @hidden */
  28864. _removeFromSceneRootNodes(): void;
  28865. private _animationPropertiesOverride;
  28866. /**
  28867. * Gets or sets the animation properties override
  28868. */
  28869. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28870. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28871. /**
  28872. * Gets a string idenfifying the name of the class
  28873. * @returns "Node" string
  28874. */
  28875. getClassName(): string;
  28876. /** @hidden */
  28877. readonly _isNode: boolean;
  28878. /**
  28879. * An event triggered when the mesh is disposed
  28880. */
  28881. onDisposeObservable: Observable<Node>;
  28882. private _onDisposeObserver;
  28883. /**
  28884. * Sets a callback that will be raised when the node will be disposed
  28885. */
  28886. set onDispose(callback: () => void);
  28887. /**
  28888. * Creates a new Node
  28889. * @param name the name and id to be given to this node
  28890. * @param scene the scene this node will be added to
  28891. */
  28892. constructor(name: string, scene?: Nullable<Scene>);
  28893. /**
  28894. * Gets the scene of the node
  28895. * @returns a scene
  28896. */
  28897. getScene(): Scene;
  28898. /**
  28899. * Gets the engine of the node
  28900. * @returns a Engine
  28901. */
  28902. getEngine(): Engine;
  28903. private _behaviors;
  28904. /**
  28905. * Attach a behavior to the node
  28906. * @see http://doc.babylonjs.com/features/behaviour
  28907. * @param behavior defines the behavior to attach
  28908. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28909. * @returns the current Node
  28910. */
  28911. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28912. /**
  28913. * Remove an attached behavior
  28914. * @see http://doc.babylonjs.com/features/behaviour
  28915. * @param behavior defines the behavior to attach
  28916. * @returns the current Node
  28917. */
  28918. removeBehavior(behavior: Behavior<Node>): Node;
  28919. /**
  28920. * Gets the list of attached behaviors
  28921. * @see http://doc.babylonjs.com/features/behaviour
  28922. */
  28923. get behaviors(): Behavior<Node>[];
  28924. /**
  28925. * Gets an attached behavior by name
  28926. * @param name defines the name of the behavior to look for
  28927. * @see http://doc.babylonjs.com/features/behaviour
  28928. * @returns null if behavior was not found else the requested behavior
  28929. */
  28930. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28931. /**
  28932. * Returns the latest update of the World matrix
  28933. * @returns a Matrix
  28934. */
  28935. getWorldMatrix(): Matrix;
  28936. /** @hidden */
  28937. _getWorldMatrixDeterminant(): number;
  28938. /**
  28939. * Returns directly the latest state of the mesh World matrix.
  28940. * A Matrix is returned.
  28941. */
  28942. get worldMatrixFromCache(): Matrix;
  28943. /** @hidden */
  28944. _initCache(): void;
  28945. /** @hidden */
  28946. updateCache(force?: boolean): void;
  28947. /** @hidden */
  28948. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28949. /** @hidden */
  28950. _updateCache(ignoreParentClass?: boolean): void;
  28951. /** @hidden */
  28952. _isSynchronized(): boolean;
  28953. /** @hidden */
  28954. _markSyncedWithParent(): void;
  28955. /** @hidden */
  28956. isSynchronizedWithParent(): boolean;
  28957. /** @hidden */
  28958. isSynchronized(): boolean;
  28959. /**
  28960. * Is this node ready to be used/rendered
  28961. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28962. * @return true if the node is ready
  28963. */
  28964. isReady(completeCheck?: boolean): boolean;
  28965. /**
  28966. * Is this node enabled?
  28967. * 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
  28968. * @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
  28969. * @return whether this node (and its parent) is enabled
  28970. */
  28971. isEnabled(checkAncestors?: boolean): boolean;
  28972. /** @hidden */
  28973. protected _syncParentEnabledState(): void;
  28974. /**
  28975. * Set the enabled state of this node
  28976. * @param value defines the new enabled state
  28977. */
  28978. setEnabled(value: boolean): void;
  28979. /**
  28980. * Is this node a descendant of the given node?
  28981. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28982. * @param ancestor defines the parent node to inspect
  28983. * @returns a boolean indicating if this node is a descendant of the given node
  28984. */
  28985. isDescendantOf(ancestor: Node): boolean;
  28986. /** @hidden */
  28987. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28988. /**
  28989. * Will return all nodes that have this node as ascendant
  28990. * @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
  28991. * @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
  28992. * @return all children nodes of all types
  28993. */
  28994. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28995. /**
  28996. * Get all child-meshes of this node
  28997. * @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)
  28998. * @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
  28999. * @returns an array of AbstractMesh
  29000. */
  29001. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29002. /**
  29003. * Get all direct children of this node
  29004. * @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
  29005. * @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)
  29006. * @returns an array of Node
  29007. */
  29008. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29009. /** @hidden */
  29010. _setReady(state: boolean): void;
  29011. /**
  29012. * Get an animation by name
  29013. * @param name defines the name of the animation to look for
  29014. * @returns null if not found else the requested animation
  29015. */
  29016. getAnimationByName(name: string): Nullable<Animation>;
  29017. /**
  29018. * Creates an animation range for this node
  29019. * @param name defines the name of the range
  29020. * @param from defines the starting key
  29021. * @param to defines the end key
  29022. */
  29023. createAnimationRange(name: string, from: number, to: number): void;
  29024. /**
  29025. * Delete a specific animation range
  29026. * @param name defines the name of the range to delete
  29027. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29028. */
  29029. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29030. /**
  29031. * Get an animation range by name
  29032. * @param name defines the name of the animation range to look for
  29033. * @returns null if not found else the requested animation range
  29034. */
  29035. getAnimationRange(name: string): Nullable<AnimationRange>;
  29036. /**
  29037. * Gets the list of all animation ranges defined on this node
  29038. * @returns an array
  29039. */
  29040. getAnimationRanges(): Nullable<AnimationRange>[];
  29041. /**
  29042. * Will start the animation sequence
  29043. * @param name defines the range frames for animation sequence
  29044. * @param loop defines if the animation should loop (false by default)
  29045. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29046. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29047. * @returns the object created for this animation. If range does not exist, it will return null
  29048. */
  29049. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29050. /**
  29051. * Serialize animation ranges into a JSON compatible object
  29052. * @returns serialization object
  29053. */
  29054. serializeAnimationRanges(): any;
  29055. /**
  29056. * Computes the world matrix of the node
  29057. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29058. * @returns the world matrix
  29059. */
  29060. computeWorldMatrix(force?: boolean): Matrix;
  29061. /**
  29062. * Releases resources associated with this node.
  29063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29065. */
  29066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29067. /**
  29068. * Parse animation range data from a serialization object and store them into a given node
  29069. * @param node defines where to store the animation ranges
  29070. * @param parsedNode defines the serialization object to read data from
  29071. * @param scene defines the hosting scene
  29072. */
  29073. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29074. /**
  29075. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29076. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29077. * @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
  29078. * @returns the new bounding vectors
  29079. */
  29080. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29081. min: Vector3;
  29082. max: Vector3;
  29083. };
  29084. }
  29085. }
  29086. declare module BABYLON {
  29087. /**
  29088. * @hidden
  29089. */
  29090. export class _IAnimationState {
  29091. key: number;
  29092. repeatCount: number;
  29093. workValue?: any;
  29094. loopMode?: number;
  29095. offsetValue?: any;
  29096. highLimitValue?: any;
  29097. }
  29098. /**
  29099. * Class used to store any kind of animation
  29100. */
  29101. export class Animation {
  29102. /**Name of the animation */
  29103. name: string;
  29104. /**Property to animate */
  29105. targetProperty: string;
  29106. /**The frames per second of the animation */
  29107. framePerSecond: number;
  29108. /**The data type of the animation */
  29109. dataType: number;
  29110. /**The loop mode of the animation */
  29111. loopMode?: number | undefined;
  29112. /**Specifies if blending should be enabled */
  29113. enableBlending?: boolean | undefined;
  29114. /**
  29115. * Use matrix interpolation instead of using direct key value when animating matrices
  29116. */
  29117. static AllowMatricesInterpolation: boolean;
  29118. /**
  29119. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29120. */
  29121. static AllowMatrixDecomposeForInterpolation: boolean;
  29122. /**
  29123. * Stores the key frames of the animation
  29124. */
  29125. private _keys;
  29126. /**
  29127. * Stores the easing function of the animation
  29128. */
  29129. private _easingFunction;
  29130. /**
  29131. * @hidden Internal use only
  29132. */
  29133. _runtimeAnimations: RuntimeAnimation[];
  29134. /**
  29135. * The set of event that will be linked to this animation
  29136. */
  29137. private _events;
  29138. /**
  29139. * Stores an array of target property paths
  29140. */
  29141. targetPropertyPath: string[];
  29142. /**
  29143. * Stores the blending speed of the animation
  29144. */
  29145. blendingSpeed: number;
  29146. /**
  29147. * Stores the animation ranges for the animation
  29148. */
  29149. private _ranges;
  29150. /**
  29151. * @hidden Internal use
  29152. */
  29153. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29154. /**
  29155. * Sets up an animation
  29156. * @param property The property to animate
  29157. * @param animationType The animation type to apply
  29158. * @param framePerSecond The frames per second of the animation
  29159. * @param easingFunction The easing function used in the animation
  29160. * @returns The created animation
  29161. */
  29162. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29163. /**
  29164. * Create and start an animation on a node
  29165. * @param name defines the name of the global animation that will be run on all nodes
  29166. * @param node defines the root node where the animation will take place
  29167. * @param targetProperty defines property to animate
  29168. * @param framePerSecond defines the number of frame per second yo use
  29169. * @param totalFrame defines the number of frames in total
  29170. * @param from defines the initial value
  29171. * @param to defines the final value
  29172. * @param loopMode defines which loop mode you want to use (off by default)
  29173. * @param easingFunction defines the easing function to use (linear by default)
  29174. * @param onAnimationEnd defines the callback to call when animation end
  29175. * @returns the animatable created for this animation
  29176. */
  29177. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29178. /**
  29179. * Create and start an animation on a node and its descendants
  29180. * @param name defines the name of the global animation that will be run on all nodes
  29181. * @param node defines the root node where the animation will take place
  29182. * @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
  29183. * @param targetProperty defines property to animate
  29184. * @param framePerSecond defines the number of frame per second to use
  29185. * @param totalFrame defines the number of frames in total
  29186. * @param from defines the initial value
  29187. * @param to defines the final value
  29188. * @param loopMode defines which loop mode you want to use (off by default)
  29189. * @param easingFunction defines the easing function to use (linear by default)
  29190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29191. * @returns the list of animatables created for all nodes
  29192. * @example https://www.babylonjs-playground.com/#MH0VLI
  29193. */
  29194. 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[]>;
  29195. /**
  29196. * Creates a new animation, merges it with the existing animations and starts it
  29197. * @param name Name of the animation
  29198. * @param node Node which contains the scene that begins the animations
  29199. * @param targetProperty Specifies which property to animate
  29200. * @param framePerSecond The frames per second of the animation
  29201. * @param totalFrame The total number of frames
  29202. * @param from The frame at the beginning of the animation
  29203. * @param to The frame at the end of the animation
  29204. * @param loopMode Specifies the loop mode of the animation
  29205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29206. * @param onAnimationEnd Callback to run once the animation is complete
  29207. * @returns Nullable animation
  29208. */
  29209. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29210. /**
  29211. * Transition property of an host to the target Value
  29212. * @param property The property to transition
  29213. * @param targetValue The target Value of the property
  29214. * @param host The object where the property to animate belongs
  29215. * @param scene Scene used to run the animation
  29216. * @param frameRate Framerate (in frame/s) to use
  29217. * @param transition The transition type we want to use
  29218. * @param duration The duration of the animation, in milliseconds
  29219. * @param onAnimationEnd Callback trigger at the end of the animation
  29220. * @returns Nullable animation
  29221. */
  29222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29223. /**
  29224. * Return the array of runtime animations currently using this animation
  29225. */
  29226. get runtimeAnimations(): RuntimeAnimation[];
  29227. /**
  29228. * Specifies if any of the runtime animations are currently running
  29229. */
  29230. get hasRunningRuntimeAnimations(): boolean;
  29231. /**
  29232. * Initializes the animation
  29233. * @param name Name of the animation
  29234. * @param targetProperty Property to animate
  29235. * @param framePerSecond The frames per second of the animation
  29236. * @param dataType The data type of the animation
  29237. * @param loopMode The loop mode of the animation
  29238. * @param enableBlending Specifies if blending should be enabled
  29239. */
  29240. constructor(
  29241. /**Name of the animation */
  29242. name: string,
  29243. /**Property to animate */
  29244. targetProperty: string,
  29245. /**The frames per second of the animation */
  29246. framePerSecond: number,
  29247. /**The data type of the animation */
  29248. dataType: number,
  29249. /**The loop mode of the animation */
  29250. loopMode?: number | undefined,
  29251. /**Specifies if blending should be enabled */
  29252. enableBlending?: boolean | undefined);
  29253. /**
  29254. * Converts the animation to a string
  29255. * @param fullDetails support for multiple levels of logging within scene loading
  29256. * @returns String form of the animation
  29257. */
  29258. toString(fullDetails?: boolean): string;
  29259. /**
  29260. * Add an event to this animation
  29261. * @param event Event to add
  29262. */
  29263. addEvent(event: AnimationEvent): void;
  29264. /**
  29265. * Remove all events found at the given frame
  29266. * @param frame The frame to remove events from
  29267. */
  29268. removeEvents(frame: number): void;
  29269. /**
  29270. * Retrieves all the events from the animation
  29271. * @returns Events from the animation
  29272. */
  29273. getEvents(): AnimationEvent[];
  29274. /**
  29275. * Creates an animation range
  29276. * @param name Name of the animation range
  29277. * @param from Starting frame of the animation range
  29278. * @param to Ending frame of the animation
  29279. */
  29280. createRange(name: string, from: number, to: number): void;
  29281. /**
  29282. * Deletes an animation range by name
  29283. * @param name Name of the animation range to delete
  29284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29285. */
  29286. deleteRange(name: string, deleteFrames?: boolean): void;
  29287. /**
  29288. * Gets the animation range by name, or null if not defined
  29289. * @param name Name of the animation range
  29290. * @returns Nullable animation range
  29291. */
  29292. getRange(name: string): Nullable<AnimationRange>;
  29293. /**
  29294. * Gets the key frames from the animation
  29295. * @returns The key frames of the animation
  29296. */
  29297. getKeys(): Array<IAnimationKey>;
  29298. /**
  29299. * Gets the highest frame rate of the animation
  29300. * @returns Highest frame rate of the animation
  29301. */
  29302. getHighestFrame(): number;
  29303. /**
  29304. * Gets the easing function of the animation
  29305. * @returns Easing function of the animation
  29306. */
  29307. getEasingFunction(): IEasingFunction;
  29308. /**
  29309. * Sets the easing function of the animation
  29310. * @param easingFunction A custom mathematical formula for animation
  29311. */
  29312. setEasingFunction(easingFunction: EasingFunction): void;
  29313. /**
  29314. * Interpolates a scalar linearly
  29315. * @param startValue Start value of the animation curve
  29316. * @param endValue End value of the animation curve
  29317. * @param gradient Scalar amount to interpolate
  29318. * @returns Interpolated scalar value
  29319. */
  29320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29321. /**
  29322. * Interpolates a scalar cubically
  29323. * @param startValue Start value of the animation curve
  29324. * @param outTangent End tangent of the animation
  29325. * @param endValue End value of the animation curve
  29326. * @param inTangent Start tangent of the animation curve
  29327. * @param gradient Scalar amount to interpolate
  29328. * @returns Interpolated scalar value
  29329. */
  29330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29331. /**
  29332. * Interpolates a quaternion using a spherical linear interpolation
  29333. * @param startValue Start value of the animation curve
  29334. * @param endValue End value of the animation curve
  29335. * @param gradient Scalar amount to interpolate
  29336. * @returns Interpolated quaternion value
  29337. */
  29338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29339. /**
  29340. * Interpolates a quaternion cubically
  29341. * @param startValue Start value of the animation curve
  29342. * @param outTangent End tangent of the animation curve
  29343. * @param endValue End value of the animation curve
  29344. * @param inTangent Start tangent of the animation curve
  29345. * @param gradient Scalar amount to interpolate
  29346. * @returns Interpolated quaternion value
  29347. */
  29348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29349. /**
  29350. * Interpolates a Vector3 linearl
  29351. * @param startValue Start value of the animation curve
  29352. * @param endValue End value of the animation curve
  29353. * @param gradient Scalar amount to interpolate
  29354. * @returns Interpolated scalar value
  29355. */
  29356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29357. /**
  29358. * Interpolates a Vector3 cubically
  29359. * @param startValue Start value of the animation curve
  29360. * @param outTangent End tangent of the animation
  29361. * @param endValue End value of the animation curve
  29362. * @param inTangent Start tangent of the animation curve
  29363. * @param gradient Scalar amount to interpolate
  29364. * @returns InterpolatedVector3 value
  29365. */
  29366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29367. /**
  29368. * Interpolates a Vector2 linearly
  29369. * @param startValue Start value of the animation curve
  29370. * @param endValue End value of the animation curve
  29371. * @param gradient Scalar amount to interpolate
  29372. * @returns Interpolated Vector2 value
  29373. */
  29374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29375. /**
  29376. * Interpolates a Vector2 cubically
  29377. * @param startValue Start value of the animation curve
  29378. * @param outTangent End tangent of the animation
  29379. * @param endValue End value of the animation curve
  29380. * @param inTangent Start tangent of the animation curve
  29381. * @param gradient Scalar amount to interpolate
  29382. * @returns Interpolated Vector2 value
  29383. */
  29384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29385. /**
  29386. * Interpolates a size linearly
  29387. * @param startValue Start value of the animation curve
  29388. * @param endValue End value of the animation curve
  29389. * @param gradient Scalar amount to interpolate
  29390. * @returns Interpolated Size value
  29391. */
  29392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29393. /**
  29394. * Interpolates a Color3 linearly
  29395. * @param startValue Start value of the animation curve
  29396. * @param endValue End value of the animation curve
  29397. * @param gradient Scalar amount to interpolate
  29398. * @returns Interpolated Color3 value
  29399. */
  29400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29401. /**
  29402. * Interpolates a Color4 linearly
  29403. * @param startValue Start value of the animation curve
  29404. * @param endValue End value of the animation curve
  29405. * @param gradient Scalar amount to interpolate
  29406. * @returns Interpolated Color3 value
  29407. */
  29408. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29409. /**
  29410. * @hidden Internal use only
  29411. */
  29412. _getKeyValue(value: any): any;
  29413. /**
  29414. * @hidden Internal use only
  29415. */
  29416. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29417. /**
  29418. * Defines the function to use to interpolate matrices
  29419. * @param startValue defines the start matrix
  29420. * @param endValue defines the end matrix
  29421. * @param gradient defines the gradient between both matrices
  29422. * @param result defines an optional target matrix where to store the interpolation
  29423. * @returns the interpolated matrix
  29424. */
  29425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29426. /**
  29427. * Makes a copy of the animation
  29428. * @returns Cloned animation
  29429. */
  29430. clone(): Animation;
  29431. /**
  29432. * Sets the key frames of the animation
  29433. * @param values The animation key frames to set
  29434. */
  29435. setKeys(values: Array<IAnimationKey>): void;
  29436. /**
  29437. * Serializes the animation to an object
  29438. * @returns Serialized object
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Float animation type
  29443. */
  29444. static readonly ANIMATIONTYPE_FLOAT: number;
  29445. /**
  29446. * Vector3 animation type
  29447. */
  29448. static readonly ANIMATIONTYPE_VECTOR3: number;
  29449. /**
  29450. * Quaternion animation type
  29451. */
  29452. static readonly ANIMATIONTYPE_QUATERNION: number;
  29453. /**
  29454. * Matrix animation type
  29455. */
  29456. static readonly ANIMATIONTYPE_MATRIX: number;
  29457. /**
  29458. * Color3 animation type
  29459. */
  29460. static readonly ANIMATIONTYPE_COLOR3: number;
  29461. /**
  29462. * Color3 animation type
  29463. */
  29464. static readonly ANIMATIONTYPE_COLOR4: number;
  29465. /**
  29466. * Vector2 animation type
  29467. */
  29468. static readonly ANIMATIONTYPE_VECTOR2: number;
  29469. /**
  29470. * Size animation type
  29471. */
  29472. static readonly ANIMATIONTYPE_SIZE: number;
  29473. /**
  29474. * Relative Loop Mode
  29475. */
  29476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29477. /**
  29478. * Cycle Loop Mode
  29479. */
  29480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29481. /**
  29482. * Constant Loop Mode
  29483. */
  29484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29485. /** @hidden */
  29486. static _UniversalLerp(left: any, right: any, amount: number): any;
  29487. /**
  29488. * Parses an animation object and creates an animation
  29489. * @param parsedAnimation Parsed animation object
  29490. * @returns Animation object
  29491. */
  29492. static Parse(parsedAnimation: any): Animation;
  29493. /**
  29494. * Appends the serialized animations from the source animations
  29495. * @param source Source containing the animations
  29496. * @param destination Target to store the animations
  29497. */
  29498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29499. }
  29500. }
  29501. declare module BABYLON {
  29502. /**
  29503. * Interface containing an array of animations
  29504. */
  29505. export interface IAnimatable {
  29506. /**
  29507. * Array of animations
  29508. */
  29509. animations: Nullable<Array<Animation>>;
  29510. }
  29511. }
  29512. declare module BABYLON {
  29513. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29514. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29515. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29516. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29517. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29518. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29519. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29520. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29521. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29523. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29524. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29525. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. /**
  29527. * Decorator used to define property that can be serialized as reference to a camera
  29528. * @param sourceName defines the name of the property to decorate
  29529. */
  29530. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29531. /**
  29532. * Class used to help serialization objects
  29533. */
  29534. export class SerializationHelper {
  29535. /** @hidden */
  29536. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29537. /** @hidden */
  29538. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29539. /** @hidden */
  29540. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29541. /** @hidden */
  29542. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29543. /**
  29544. * Appends the serialized animations from the source animations
  29545. * @param source Source containing the animations
  29546. * @param destination Target to store the animations
  29547. */
  29548. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29549. /**
  29550. * Static function used to serialized a specific entity
  29551. * @param entity defines the entity to serialize
  29552. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29553. * @returns a JSON compatible object representing the serialization of the entity
  29554. */
  29555. static Serialize<T>(entity: T, serializationObject?: any): any;
  29556. /**
  29557. * Creates a new entity from a serialization data object
  29558. * @param creationFunction defines a function used to instanciated the new entity
  29559. * @param source defines the source serialization data
  29560. * @param scene defines the hosting scene
  29561. * @param rootUrl defines the root url for resources
  29562. * @returns a new entity
  29563. */
  29564. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29565. /**
  29566. * Clones an object
  29567. * @param creationFunction defines the function used to instanciate the new object
  29568. * @param source defines the source object
  29569. * @returns the cloned object
  29570. */
  29571. static Clone<T>(creationFunction: () => T, source: T): T;
  29572. /**
  29573. * Instanciates a new object based on a source one (some data will be shared between both object)
  29574. * @param creationFunction defines the function used to instanciate the new object
  29575. * @param source defines the source object
  29576. * @returns the new object
  29577. */
  29578. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29579. }
  29580. }
  29581. declare module BABYLON {
  29582. /**
  29583. * Class used to manipulate GUIDs
  29584. */
  29585. export class GUID {
  29586. /**
  29587. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29588. * Be aware Math.random() could cause collisions, but:
  29589. * "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"
  29590. * @returns a pseudo random id
  29591. */
  29592. static RandomId(): string;
  29593. }
  29594. }
  29595. declare module BABYLON {
  29596. /**
  29597. * Base class of all the textures in babylon.
  29598. * It groups all the common properties the materials, post process, lights... might need
  29599. * in order to make a correct use of the texture.
  29600. */
  29601. export class BaseTexture implements IAnimatable {
  29602. /**
  29603. * Default anisotropic filtering level for the application.
  29604. * It is set to 4 as a good tradeoff between perf and quality.
  29605. */
  29606. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29607. /**
  29608. * Gets or sets the unique id of the texture
  29609. */
  29610. uniqueId: number;
  29611. /**
  29612. * Define the name of the texture.
  29613. */
  29614. name: string;
  29615. /**
  29616. * Gets or sets an object used to store user defined information.
  29617. */
  29618. metadata: any;
  29619. /**
  29620. * For internal use only. Please do not use.
  29621. */
  29622. reservedDataStore: any;
  29623. private _hasAlpha;
  29624. /**
  29625. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29626. */
  29627. set hasAlpha(value: boolean);
  29628. get hasAlpha(): boolean;
  29629. /**
  29630. * Defines if the alpha value should be determined via the rgb values.
  29631. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29632. */
  29633. getAlphaFromRGB: boolean;
  29634. /**
  29635. * Intensity or strength of the texture.
  29636. * It is commonly used by materials to fine tune the intensity of the texture
  29637. */
  29638. level: number;
  29639. /**
  29640. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29641. * This is part of the texture as textures usually maps to one uv set.
  29642. */
  29643. coordinatesIndex: number;
  29644. private _coordinatesMode;
  29645. /**
  29646. * How a texture is mapped.
  29647. *
  29648. * | Value | Type | Description |
  29649. * | ----- | ----------------------------------- | ----------- |
  29650. * | 0 | EXPLICIT_MODE | |
  29651. * | 1 | SPHERICAL_MODE | |
  29652. * | 2 | PLANAR_MODE | |
  29653. * | 3 | CUBIC_MODE | |
  29654. * | 4 | PROJECTION_MODE | |
  29655. * | 5 | SKYBOX_MODE | |
  29656. * | 6 | INVCUBIC_MODE | |
  29657. * | 7 | EQUIRECTANGULAR_MODE | |
  29658. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29659. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29660. */
  29661. set coordinatesMode(value: number);
  29662. get coordinatesMode(): number;
  29663. /**
  29664. * | Value | Type | Description |
  29665. * | ----- | ------------------ | ----------- |
  29666. * | 0 | CLAMP_ADDRESSMODE | |
  29667. * | 1 | WRAP_ADDRESSMODE | |
  29668. * | 2 | MIRROR_ADDRESSMODE | |
  29669. */
  29670. wrapU: number;
  29671. /**
  29672. * | Value | Type | Description |
  29673. * | ----- | ------------------ | ----------- |
  29674. * | 0 | CLAMP_ADDRESSMODE | |
  29675. * | 1 | WRAP_ADDRESSMODE | |
  29676. * | 2 | MIRROR_ADDRESSMODE | |
  29677. */
  29678. wrapV: number;
  29679. /**
  29680. * | Value | Type | Description |
  29681. * | ----- | ------------------ | ----------- |
  29682. * | 0 | CLAMP_ADDRESSMODE | |
  29683. * | 1 | WRAP_ADDRESSMODE | |
  29684. * | 2 | MIRROR_ADDRESSMODE | |
  29685. */
  29686. wrapR: number;
  29687. /**
  29688. * With compliant hardware and browser (supporting anisotropic filtering)
  29689. * this defines the level of anisotropic filtering in the texture.
  29690. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29691. */
  29692. anisotropicFilteringLevel: number;
  29693. /**
  29694. * Define if the texture is a cube texture or if false a 2d texture.
  29695. */
  29696. get isCube(): boolean;
  29697. set isCube(value: boolean);
  29698. /**
  29699. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29700. */
  29701. get is3D(): boolean;
  29702. set is3D(value: boolean);
  29703. /**
  29704. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29705. */
  29706. get is2DArray(): boolean;
  29707. set is2DArray(value: boolean);
  29708. /**
  29709. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29710. * HDR texture are usually stored in linear space.
  29711. * This only impacts the PBR and Background materials
  29712. */
  29713. gammaSpace: boolean;
  29714. /**
  29715. * Gets or sets whether or not the texture contains RGBD data.
  29716. */
  29717. get isRGBD(): boolean;
  29718. set isRGBD(value: boolean);
  29719. /**
  29720. * Is Z inverted in the texture (useful in a cube texture).
  29721. */
  29722. invertZ: boolean;
  29723. /**
  29724. * Are mip maps generated for this texture or not.
  29725. */
  29726. get noMipmap(): boolean;
  29727. /**
  29728. * @hidden
  29729. */
  29730. lodLevelInAlpha: boolean;
  29731. /**
  29732. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29733. */
  29734. get lodGenerationOffset(): number;
  29735. set lodGenerationOffset(value: number);
  29736. /**
  29737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29738. */
  29739. get lodGenerationScale(): number;
  29740. set lodGenerationScale(value: number);
  29741. /**
  29742. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29743. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29744. * average roughness values.
  29745. */
  29746. get linearSpecularLOD(): boolean;
  29747. set linearSpecularLOD(value: boolean);
  29748. /**
  29749. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29750. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29751. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29752. */
  29753. get irradianceTexture(): Nullable<BaseTexture>;
  29754. set irradianceTexture(value: Nullable<BaseTexture>);
  29755. /**
  29756. * Define if the texture is a render target.
  29757. */
  29758. isRenderTarget: boolean;
  29759. /**
  29760. * Define the unique id of the texture in the scene.
  29761. */
  29762. get uid(): string;
  29763. /**
  29764. * Return a string representation of the texture.
  29765. * @returns the texture as a string
  29766. */
  29767. toString(): string;
  29768. /**
  29769. * Get the class name of the texture.
  29770. * @returns "BaseTexture"
  29771. */
  29772. getClassName(): string;
  29773. /**
  29774. * Define the list of animation attached to the texture.
  29775. */
  29776. animations: Animation[];
  29777. /**
  29778. * An event triggered when the texture is disposed.
  29779. */
  29780. onDisposeObservable: Observable<BaseTexture>;
  29781. private _onDisposeObserver;
  29782. /**
  29783. * Callback triggered when the texture has been disposed.
  29784. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29785. */
  29786. set onDispose(callback: () => void);
  29787. /**
  29788. * Define the current state of the loading sequence when in delayed load mode.
  29789. */
  29790. delayLoadState: number;
  29791. private _scene;
  29792. /** @hidden */
  29793. _texture: Nullable<InternalTexture>;
  29794. private _uid;
  29795. /**
  29796. * Define if the texture is preventinga material to render or not.
  29797. * If not and the texture is not ready, the engine will use a default black texture instead.
  29798. */
  29799. get isBlocking(): boolean;
  29800. /**
  29801. * Instantiates a new BaseTexture.
  29802. * Base class of all the textures in babylon.
  29803. * It groups all the common properties the materials, post process, lights... might need
  29804. * in order to make a correct use of the texture.
  29805. * @param scene Define the scene the texture blongs to
  29806. */
  29807. constructor(scene: Nullable<Scene>);
  29808. /**
  29809. * Get the scene the texture belongs to.
  29810. * @returns the scene or null if undefined
  29811. */
  29812. getScene(): Nullable<Scene>;
  29813. /**
  29814. * Get the texture transform matrix used to offset tile the texture for istance.
  29815. * @returns the transformation matrix
  29816. */
  29817. getTextureMatrix(): Matrix;
  29818. /**
  29819. * Get the texture reflection matrix used to rotate/transform the reflection.
  29820. * @returns the reflection matrix
  29821. */
  29822. getReflectionTextureMatrix(): Matrix;
  29823. /**
  29824. * Get the underlying lower level texture from Babylon.
  29825. * @returns the insternal texture
  29826. */
  29827. getInternalTexture(): Nullable<InternalTexture>;
  29828. /**
  29829. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29830. * @returns true if ready or not blocking
  29831. */
  29832. isReadyOrNotBlocking(): boolean;
  29833. /**
  29834. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29835. * @returns true if fully ready
  29836. */
  29837. isReady(): boolean;
  29838. private _cachedSize;
  29839. /**
  29840. * Get the size of the texture.
  29841. * @returns the texture size.
  29842. */
  29843. getSize(): ISize;
  29844. /**
  29845. * Get the base size of the texture.
  29846. * It can be different from the size if the texture has been resized for POT for instance
  29847. * @returns the base size
  29848. */
  29849. getBaseSize(): ISize;
  29850. /**
  29851. * Update the sampling mode of the texture.
  29852. * Default is Trilinear mode.
  29853. *
  29854. * | Value | Type | Description |
  29855. * | ----- | ------------------ | ----------- |
  29856. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29857. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29858. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29859. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29860. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29861. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29862. * | 7 | NEAREST_LINEAR | |
  29863. * | 8 | NEAREST_NEAREST | |
  29864. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29865. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29866. * | 11 | LINEAR_LINEAR | |
  29867. * | 12 | LINEAR_NEAREST | |
  29868. *
  29869. * > _mag_: magnification filter (close to the viewer)
  29870. * > _min_: minification filter (far from the viewer)
  29871. * > _mip_: filter used between mip map levels
  29872. *@param samplingMode Define the new sampling mode of the texture
  29873. */
  29874. updateSamplingMode(samplingMode: number): void;
  29875. /**
  29876. * Scales the texture if is `canRescale()`
  29877. * @param ratio the resize factor we want to use to rescale
  29878. */
  29879. scale(ratio: number): void;
  29880. /**
  29881. * Get if the texture can rescale.
  29882. */
  29883. get canRescale(): boolean;
  29884. /** @hidden */
  29885. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29886. /** @hidden */
  29887. _rebuild(): void;
  29888. /**
  29889. * Triggers the load sequence in delayed load mode.
  29890. */
  29891. delayLoad(): void;
  29892. /**
  29893. * Clones the texture.
  29894. * @returns the cloned texture
  29895. */
  29896. clone(): Nullable<BaseTexture>;
  29897. /**
  29898. * Get the texture underlying type (INT, FLOAT...)
  29899. */
  29900. get textureType(): number;
  29901. /**
  29902. * Get the texture underlying format (RGB, RGBA...)
  29903. */
  29904. get textureFormat(): number;
  29905. /**
  29906. * Indicates that textures need to be re-calculated for all materials
  29907. */
  29908. protected _markAllSubMeshesAsTexturesDirty(): void;
  29909. /**
  29910. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29911. * This will returns an RGBA array buffer containing either in values (0-255) or
  29912. * float values (0-1) depending of the underlying buffer type.
  29913. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29914. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29915. * @param buffer defines a user defined buffer to fill with data (can be null)
  29916. * @returns The Array buffer containing the pixels data.
  29917. */
  29918. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29919. /**
  29920. * Release and destroy the underlying lower level texture aka internalTexture.
  29921. */
  29922. releaseInternalTexture(): void;
  29923. /** @hidden */
  29924. get _lodTextureHigh(): Nullable<BaseTexture>;
  29925. /** @hidden */
  29926. get _lodTextureMid(): Nullable<BaseTexture>;
  29927. /** @hidden */
  29928. get _lodTextureLow(): Nullable<BaseTexture>;
  29929. /**
  29930. * Dispose the texture and release its associated resources.
  29931. */
  29932. dispose(): void;
  29933. /**
  29934. * Serialize the texture into a JSON representation that can be parsed later on.
  29935. * @returns the JSON representation of the texture
  29936. */
  29937. serialize(): any;
  29938. /**
  29939. * Helper function to be called back once a list of texture contains only ready textures.
  29940. * @param textures Define the list of textures to wait for
  29941. * @param callback Define the callback triggered once the entire list will be ready
  29942. */
  29943. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29944. }
  29945. }
  29946. declare module BABYLON {
  29947. /**
  29948. * Options to be used when creating an effect.
  29949. */
  29950. export interface IEffectCreationOptions {
  29951. /**
  29952. * Atrributes that will be used in the shader.
  29953. */
  29954. attributes: string[];
  29955. /**
  29956. * Uniform varible names that will be set in the shader.
  29957. */
  29958. uniformsNames: string[];
  29959. /**
  29960. * Uniform buffer variable names that will be set in the shader.
  29961. */
  29962. uniformBuffersNames: string[];
  29963. /**
  29964. * Sampler texture variable names that will be set in the shader.
  29965. */
  29966. samplers: string[];
  29967. /**
  29968. * Define statements that will be set in the shader.
  29969. */
  29970. defines: any;
  29971. /**
  29972. * Possible fallbacks for this effect to improve performance when needed.
  29973. */
  29974. fallbacks: Nullable<IEffectFallbacks>;
  29975. /**
  29976. * Callback that will be called when the shader is compiled.
  29977. */
  29978. onCompiled: Nullable<(effect: Effect) => void>;
  29979. /**
  29980. * Callback that will be called if an error occurs during shader compilation.
  29981. */
  29982. onError: Nullable<(effect: Effect, errors: string) => void>;
  29983. /**
  29984. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29985. */
  29986. indexParameters?: any;
  29987. /**
  29988. * Max number of lights that can be used in the shader.
  29989. */
  29990. maxSimultaneousLights?: number;
  29991. /**
  29992. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29993. */
  29994. transformFeedbackVaryings?: Nullable<string[]>;
  29995. }
  29996. /**
  29997. * Effect containing vertex and fragment shader that can be executed on an object.
  29998. */
  29999. export class Effect implements IDisposable {
  30000. /**
  30001. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30002. */
  30003. static ShadersRepository: string;
  30004. /**
  30005. * Name of the effect.
  30006. */
  30007. name: any;
  30008. /**
  30009. * String container all the define statements that should be set on the shader.
  30010. */
  30011. defines: string;
  30012. /**
  30013. * Callback that will be called when the shader is compiled.
  30014. */
  30015. onCompiled: Nullable<(effect: Effect) => void>;
  30016. /**
  30017. * Callback that will be called if an error occurs during shader compilation.
  30018. */
  30019. onError: Nullable<(effect: Effect, errors: string) => void>;
  30020. /**
  30021. * Callback that will be called when effect is bound.
  30022. */
  30023. onBind: Nullable<(effect: Effect) => void>;
  30024. /**
  30025. * Unique ID of the effect.
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Observable that will be called when the shader is compiled.
  30030. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30031. */
  30032. onCompileObservable: Observable<Effect>;
  30033. /**
  30034. * Observable that will be called if an error occurs during shader compilation.
  30035. */
  30036. onErrorObservable: Observable<Effect>;
  30037. /** @hidden */
  30038. _onBindObservable: Nullable<Observable<Effect>>;
  30039. /**
  30040. * @hidden
  30041. * Specifies if the effect was previously ready
  30042. */
  30043. _wasPreviouslyReady: boolean;
  30044. /**
  30045. * Observable that will be called when effect is bound.
  30046. */
  30047. get onBindObservable(): Observable<Effect>;
  30048. /** @hidden */
  30049. _bonesComputationForcedToCPU: boolean;
  30050. private static _uniqueIdSeed;
  30051. private _engine;
  30052. private _uniformBuffersNames;
  30053. private _uniformsNames;
  30054. private _samplerList;
  30055. private _samplers;
  30056. private _isReady;
  30057. private _compilationError;
  30058. private _allFallbacksProcessed;
  30059. private _attributesNames;
  30060. private _attributes;
  30061. private _attributeLocationByName;
  30062. private _uniforms;
  30063. /**
  30064. * Key for the effect.
  30065. * @hidden
  30066. */
  30067. _key: string;
  30068. private _indexParameters;
  30069. private _fallbacks;
  30070. private _vertexSourceCode;
  30071. private _fragmentSourceCode;
  30072. private _vertexSourceCodeOverride;
  30073. private _fragmentSourceCodeOverride;
  30074. private _transformFeedbackVaryings;
  30075. /**
  30076. * Compiled shader to webGL program.
  30077. * @hidden
  30078. */
  30079. _pipelineContext: Nullable<IPipelineContext>;
  30080. private _valueCache;
  30081. private static _baseCache;
  30082. /**
  30083. * Instantiates an effect.
  30084. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30085. * @param baseName Name of the effect.
  30086. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30087. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30088. * @param samplers List of sampler variables that will be passed to the shader.
  30089. * @param engine Engine to be used to render the effect
  30090. * @param defines Define statements to be added to the shader.
  30091. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30092. * @param onCompiled Callback that will be called when the shader is compiled.
  30093. * @param onError Callback that will be called if an error occurs during shader compilation.
  30094. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30095. */
  30096. 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);
  30097. private _useFinalCode;
  30098. /**
  30099. * Unique key for this effect
  30100. */
  30101. get key(): string;
  30102. /**
  30103. * If the effect has been compiled and prepared.
  30104. * @returns if the effect is compiled and prepared.
  30105. */
  30106. isReady(): boolean;
  30107. private _isReadyInternal;
  30108. /**
  30109. * The engine the effect was initialized with.
  30110. * @returns the engine.
  30111. */
  30112. getEngine(): Engine;
  30113. /**
  30114. * The pipeline context for this effect
  30115. * @returns the associated pipeline context
  30116. */
  30117. getPipelineContext(): Nullable<IPipelineContext>;
  30118. /**
  30119. * The set of names of attribute variables for the shader.
  30120. * @returns An array of attribute names.
  30121. */
  30122. getAttributesNames(): string[];
  30123. /**
  30124. * Returns the attribute at the given index.
  30125. * @param index The index of the attribute.
  30126. * @returns The location of the attribute.
  30127. */
  30128. getAttributeLocation(index: number): number;
  30129. /**
  30130. * Returns the attribute based on the name of the variable.
  30131. * @param name of the attribute to look up.
  30132. * @returns the attribute location.
  30133. */
  30134. getAttributeLocationByName(name: string): number;
  30135. /**
  30136. * The number of attributes.
  30137. * @returns the numnber of attributes.
  30138. */
  30139. getAttributesCount(): number;
  30140. /**
  30141. * Gets the index of a uniform variable.
  30142. * @param uniformName of the uniform to look up.
  30143. * @returns the index.
  30144. */
  30145. getUniformIndex(uniformName: string): number;
  30146. /**
  30147. * Returns the attribute based on the name of the variable.
  30148. * @param uniformName of the uniform to look up.
  30149. * @returns the location of the uniform.
  30150. */
  30151. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30152. /**
  30153. * Returns an array of sampler variable names
  30154. * @returns The array of sampler variable neames.
  30155. */
  30156. getSamplers(): string[];
  30157. /**
  30158. * The error from the last compilation.
  30159. * @returns the error string.
  30160. */
  30161. getCompilationError(): string;
  30162. /**
  30163. * Gets a boolean indicating that all fallbacks were used during compilation
  30164. * @returns true if all fallbacks were used
  30165. */
  30166. allFallbacksProcessed(): boolean;
  30167. /**
  30168. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30169. * @param func The callback to be used.
  30170. */
  30171. executeWhenCompiled(func: (effect: Effect) => void): void;
  30172. private _checkIsReady;
  30173. private _loadShader;
  30174. /**
  30175. * Recompiles the webGL program
  30176. * @param vertexSourceCode The source code for the vertex shader.
  30177. * @param fragmentSourceCode The source code for the fragment shader.
  30178. * @param onCompiled Callback called when completed.
  30179. * @param onError Callback called on error.
  30180. * @hidden
  30181. */
  30182. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30183. /**
  30184. * Prepares the effect
  30185. * @hidden
  30186. */
  30187. _prepareEffect(): void;
  30188. private _processCompilationErrors;
  30189. /**
  30190. * Checks if the effect is supported. (Must be called after compilation)
  30191. */
  30192. get isSupported(): boolean;
  30193. /**
  30194. * Binds a texture to the engine to be used as output of the shader.
  30195. * @param channel Name of the output variable.
  30196. * @param texture Texture to bind.
  30197. * @hidden
  30198. */
  30199. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30200. /**
  30201. * Sets a texture on the engine to be used in the shader.
  30202. * @param channel Name of the sampler variable.
  30203. * @param texture Texture to set.
  30204. */
  30205. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30206. /**
  30207. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30208. * @param channel Name of the sampler variable.
  30209. * @param texture Texture to set.
  30210. */
  30211. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30212. /**
  30213. * Sets an array of textures on the engine to be used in the shader.
  30214. * @param channel Name of the variable.
  30215. * @param textures Textures to set.
  30216. */
  30217. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30218. /**
  30219. * 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)
  30220. * @param channel Name of the sampler variable.
  30221. * @param postProcess Post process to get the input texture from.
  30222. */
  30223. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30224. /**
  30225. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30226. * 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)
  30227. * @param channel Name of the sampler variable.
  30228. * @param postProcess Post process to get the output texture from.
  30229. */
  30230. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30231. /** @hidden */
  30232. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30233. /** @hidden */
  30234. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30235. /** @hidden */
  30236. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30237. /** @hidden */
  30238. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30239. /**
  30240. * Binds a buffer to a uniform.
  30241. * @param buffer Buffer to bind.
  30242. * @param name Name of the uniform variable to bind to.
  30243. */
  30244. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30245. /**
  30246. * Binds block to a uniform.
  30247. * @param blockName Name of the block to bind.
  30248. * @param index Index to bind.
  30249. */
  30250. bindUniformBlock(blockName: string, index: number): void;
  30251. /**
  30252. * Sets an interger value on a uniform variable.
  30253. * @param uniformName Name of the variable.
  30254. * @param value Value to be set.
  30255. * @returns this effect.
  30256. */
  30257. setInt(uniformName: string, value: number): Effect;
  30258. /**
  30259. * Sets an int array on a uniform variable.
  30260. * @param uniformName Name of the variable.
  30261. * @param array array to be set.
  30262. * @returns this effect.
  30263. */
  30264. setIntArray(uniformName: string, array: Int32Array): Effect;
  30265. /**
  30266. * 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)
  30267. * @param uniformName Name of the variable.
  30268. * @param array array to be set.
  30269. * @returns this effect.
  30270. */
  30271. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30272. /**
  30273. * 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)
  30274. * @param uniformName Name of the variable.
  30275. * @param array array to be set.
  30276. * @returns this effect.
  30277. */
  30278. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30279. /**
  30280. * 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)
  30281. * @param uniformName Name of the variable.
  30282. * @param array array to be set.
  30283. * @returns this effect.
  30284. */
  30285. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30286. /**
  30287. * Sets an float array on a uniform variable.
  30288. * @param uniformName Name of the variable.
  30289. * @param array array to be set.
  30290. * @returns this effect.
  30291. */
  30292. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30293. /**
  30294. * 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)
  30295. * @param uniformName Name of the variable.
  30296. * @param array array to be set.
  30297. * @returns this effect.
  30298. */
  30299. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30300. /**
  30301. * 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)
  30302. * @param uniformName Name of the variable.
  30303. * @param array array to be set.
  30304. * @returns this effect.
  30305. */
  30306. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30307. /**
  30308. * 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)
  30309. * @param uniformName Name of the variable.
  30310. * @param array array to be set.
  30311. * @returns this effect.
  30312. */
  30313. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30314. /**
  30315. * Sets an array on a uniform variable.
  30316. * @param uniformName Name of the variable.
  30317. * @param array array to be set.
  30318. * @returns this effect.
  30319. */
  30320. setArray(uniformName: string, array: number[]): Effect;
  30321. /**
  30322. * 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)
  30323. * @param uniformName Name of the variable.
  30324. * @param array array to be set.
  30325. * @returns this effect.
  30326. */
  30327. setArray2(uniformName: string, array: number[]): Effect;
  30328. /**
  30329. * 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)
  30330. * @param uniformName Name of the variable.
  30331. * @param array array to be set.
  30332. * @returns this effect.
  30333. */
  30334. setArray3(uniformName: string, array: number[]): Effect;
  30335. /**
  30336. * 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)
  30337. * @param uniformName Name of the variable.
  30338. * @param array array to be set.
  30339. * @returns this effect.
  30340. */
  30341. setArray4(uniformName: string, array: number[]): Effect;
  30342. /**
  30343. * Sets matrices on a uniform variable.
  30344. * @param uniformName Name of the variable.
  30345. * @param matrices matrices to be set.
  30346. * @returns this effect.
  30347. */
  30348. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30349. /**
  30350. * Sets matrix on a uniform variable.
  30351. * @param uniformName Name of the variable.
  30352. * @param matrix matrix to be set.
  30353. * @returns this effect.
  30354. */
  30355. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30356. /**
  30357. * 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)
  30358. * @param uniformName Name of the variable.
  30359. * @param matrix matrix to be set.
  30360. * @returns this effect.
  30361. */
  30362. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30363. /**
  30364. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30365. * @param uniformName Name of the variable.
  30366. * @param matrix matrix to be set.
  30367. * @returns this effect.
  30368. */
  30369. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30370. /**
  30371. * Sets a float on a uniform variable.
  30372. * @param uniformName Name of the variable.
  30373. * @param value value to be set.
  30374. * @returns this effect.
  30375. */
  30376. setFloat(uniformName: string, value: number): Effect;
  30377. /**
  30378. * Sets a boolean on a uniform variable.
  30379. * @param uniformName Name of the variable.
  30380. * @param bool value to be set.
  30381. * @returns this effect.
  30382. */
  30383. setBool(uniformName: string, bool: boolean): Effect;
  30384. /**
  30385. * Sets a Vector2 on a uniform variable.
  30386. * @param uniformName Name of the variable.
  30387. * @param vector2 vector2 to be set.
  30388. * @returns this effect.
  30389. */
  30390. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30391. /**
  30392. * Sets a float2 on a uniform variable.
  30393. * @param uniformName Name of the variable.
  30394. * @param x First float in float2.
  30395. * @param y Second float in float2.
  30396. * @returns this effect.
  30397. */
  30398. setFloat2(uniformName: string, x: number, y: number): Effect;
  30399. /**
  30400. * Sets a Vector3 on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param vector3 Value to be set.
  30403. * @returns this effect.
  30404. */
  30405. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30406. /**
  30407. * Sets a float3 on a uniform variable.
  30408. * @param uniformName Name of the variable.
  30409. * @param x First float in float3.
  30410. * @param y Second float in float3.
  30411. * @param z Third float in float3.
  30412. * @returns this effect.
  30413. */
  30414. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30415. /**
  30416. * Sets a Vector4 on a uniform variable.
  30417. * @param uniformName Name of the variable.
  30418. * @param vector4 Value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30422. /**
  30423. * Sets a float4 on a uniform variable.
  30424. * @param uniformName Name of the variable.
  30425. * @param x First float in float4.
  30426. * @param y Second float in float4.
  30427. * @param z Third float in float4.
  30428. * @param w Fourth float in float4.
  30429. * @returns this effect.
  30430. */
  30431. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30432. /**
  30433. * Sets a Color3 on a uniform variable.
  30434. * @param uniformName Name of the variable.
  30435. * @param color3 Value to be set.
  30436. * @returns this effect.
  30437. */
  30438. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30439. /**
  30440. * Sets a Color4 on a uniform variable.
  30441. * @param uniformName Name of the variable.
  30442. * @param color3 Value to be set.
  30443. * @param alpha Alpha value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30447. /**
  30448. * Sets a Color4 on a uniform variable
  30449. * @param uniformName defines the name of the variable
  30450. * @param color4 defines the value to be set
  30451. * @returns this effect.
  30452. */
  30453. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30454. /** Release all associated resources */
  30455. dispose(): void;
  30456. /**
  30457. * This function will add a new shader to the shader store
  30458. * @param name the name of the shader
  30459. * @param pixelShader optional pixel shader content
  30460. * @param vertexShader optional vertex shader content
  30461. */
  30462. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30463. /**
  30464. * Store of each shader (The can be looked up using effect.key)
  30465. */
  30466. static ShadersStore: {
  30467. [key: string]: string;
  30468. };
  30469. /**
  30470. * Store of each included file for a shader (The can be looked up using effect.key)
  30471. */
  30472. static IncludesShadersStore: {
  30473. [key: string]: string;
  30474. };
  30475. /**
  30476. * Resets the cache of effects.
  30477. */
  30478. static ResetCache(): void;
  30479. }
  30480. }
  30481. declare module BABYLON {
  30482. /**
  30483. * Interface used to describe the capabilities of the engine relatively to the current browser
  30484. */
  30485. export interface EngineCapabilities {
  30486. /** Maximum textures units per fragment shader */
  30487. maxTexturesImageUnits: number;
  30488. /** Maximum texture units per vertex shader */
  30489. maxVertexTextureImageUnits: number;
  30490. /** Maximum textures units in the entire pipeline */
  30491. maxCombinedTexturesImageUnits: number;
  30492. /** Maximum texture size */
  30493. maxTextureSize: number;
  30494. /** Maximum texture samples */
  30495. maxSamples?: number;
  30496. /** Maximum cube texture size */
  30497. maxCubemapTextureSize: number;
  30498. /** Maximum render texture size */
  30499. maxRenderTextureSize: number;
  30500. /** Maximum number of vertex attributes */
  30501. maxVertexAttribs: number;
  30502. /** Maximum number of varyings */
  30503. maxVaryingVectors: number;
  30504. /** Maximum number of uniforms per vertex shader */
  30505. maxVertexUniformVectors: number;
  30506. /** Maximum number of uniforms per fragment shader */
  30507. maxFragmentUniformVectors: number;
  30508. /** Defines if standard derivates (dx/dy) are supported */
  30509. standardDerivatives: boolean;
  30510. /** Defines if s3tc texture compression is supported */
  30511. s3tc?: WEBGL_compressed_texture_s3tc;
  30512. /** Defines if pvrtc texture compression is supported */
  30513. pvrtc: any;
  30514. /** Defines if etc1 texture compression is supported */
  30515. etc1: any;
  30516. /** Defines if etc2 texture compression is supported */
  30517. etc2: any;
  30518. /** Defines if astc texture compression is supported */
  30519. astc: any;
  30520. /** Defines if float textures are supported */
  30521. textureFloat: boolean;
  30522. /** Defines if vertex array objects are supported */
  30523. vertexArrayObject: boolean;
  30524. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30525. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30526. /** Gets the maximum level of anisotropy supported */
  30527. maxAnisotropy: number;
  30528. /** Defines if instancing is supported */
  30529. instancedArrays: boolean;
  30530. /** Defines if 32 bits indices are supported */
  30531. uintIndices: boolean;
  30532. /** Defines if high precision shaders are supported */
  30533. highPrecisionShaderSupported: boolean;
  30534. /** Defines if depth reading in the fragment shader is supported */
  30535. fragmentDepthSupported: boolean;
  30536. /** Defines if float texture linear filtering is supported*/
  30537. textureFloatLinearFiltering: boolean;
  30538. /** Defines if rendering to float textures is supported */
  30539. textureFloatRender: boolean;
  30540. /** Defines if half float textures are supported*/
  30541. textureHalfFloat: boolean;
  30542. /** Defines if half float texture linear filtering is supported*/
  30543. textureHalfFloatLinearFiltering: boolean;
  30544. /** Defines if rendering to half float textures is supported */
  30545. textureHalfFloatRender: boolean;
  30546. /** Defines if textureLOD shader command is supported */
  30547. textureLOD: boolean;
  30548. /** Defines if draw buffers extension is supported */
  30549. drawBuffersExtension: boolean;
  30550. /** Defines if depth textures are supported */
  30551. depthTextureExtension: boolean;
  30552. /** Defines if float color buffer are supported */
  30553. colorBufferFloat: boolean;
  30554. /** Gets disjoint timer query extension (null if not supported) */
  30555. timerQuery?: EXT_disjoint_timer_query;
  30556. /** Defines if timestamp can be used with timer query */
  30557. canUseTimestampForTimerQuery: boolean;
  30558. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30559. multiview?: any;
  30560. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30561. oculusMultiview?: any;
  30562. /** Function used to let the system compiles shaders in background */
  30563. parallelShaderCompile?: {
  30564. COMPLETION_STATUS_KHR: number;
  30565. };
  30566. /** Max number of texture samples for MSAA */
  30567. maxMSAASamples: number;
  30568. /** Defines if the blend min max extension is supported */
  30569. blendMinMax: boolean;
  30570. }
  30571. }
  30572. declare module BABYLON {
  30573. /**
  30574. * @hidden
  30575. **/
  30576. export class DepthCullingState {
  30577. private _isDepthTestDirty;
  30578. private _isDepthMaskDirty;
  30579. private _isDepthFuncDirty;
  30580. private _isCullFaceDirty;
  30581. private _isCullDirty;
  30582. private _isZOffsetDirty;
  30583. private _isFrontFaceDirty;
  30584. private _depthTest;
  30585. private _depthMask;
  30586. private _depthFunc;
  30587. private _cull;
  30588. private _cullFace;
  30589. private _zOffset;
  30590. private _frontFace;
  30591. /**
  30592. * Initializes the state.
  30593. */
  30594. constructor();
  30595. get isDirty(): boolean;
  30596. get zOffset(): number;
  30597. set zOffset(value: number);
  30598. get cullFace(): Nullable<number>;
  30599. set cullFace(value: Nullable<number>);
  30600. get cull(): Nullable<boolean>;
  30601. set cull(value: Nullable<boolean>);
  30602. get depthFunc(): Nullable<number>;
  30603. set depthFunc(value: Nullable<number>);
  30604. get depthMask(): boolean;
  30605. set depthMask(value: boolean);
  30606. get depthTest(): boolean;
  30607. set depthTest(value: boolean);
  30608. get frontFace(): Nullable<number>;
  30609. set frontFace(value: Nullable<number>);
  30610. reset(): void;
  30611. apply(gl: WebGLRenderingContext): void;
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * @hidden
  30617. **/
  30618. export class StencilState {
  30619. /** 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 */
  30620. static readonly ALWAYS: number;
  30621. /** Passed to stencilOperation to specify that stencil value must be kept */
  30622. static readonly KEEP: number;
  30623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30624. static readonly REPLACE: number;
  30625. private _isStencilTestDirty;
  30626. private _isStencilMaskDirty;
  30627. private _isStencilFuncDirty;
  30628. private _isStencilOpDirty;
  30629. private _stencilTest;
  30630. private _stencilMask;
  30631. private _stencilFunc;
  30632. private _stencilFuncRef;
  30633. private _stencilFuncMask;
  30634. private _stencilOpStencilFail;
  30635. private _stencilOpDepthFail;
  30636. private _stencilOpStencilDepthPass;
  30637. get isDirty(): boolean;
  30638. get stencilFunc(): number;
  30639. set stencilFunc(value: number);
  30640. get stencilFuncRef(): number;
  30641. set stencilFuncRef(value: number);
  30642. get stencilFuncMask(): number;
  30643. set stencilFuncMask(value: number);
  30644. get stencilOpStencilFail(): number;
  30645. set stencilOpStencilFail(value: number);
  30646. get stencilOpDepthFail(): number;
  30647. set stencilOpDepthFail(value: number);
  30648. get stencilOpStencilDepthPass(): number;
  30649. set stencilOpStencilDepthPass(value: number);
  30650. get stencilMask(): number;
  30651. set stencilMask(value: number);
  30652. get stencilTest(): boolean;
  30653. set stencilTest(value: boolean);
  30654. constructor();
  30655. reset(): void;
  30656. apply(gl: WebGLRenderingContext): void;
  30657. }
  30658. }
  30659. declare module BABYLON {
  30660. /**
  30661. * @hidden
  30662. **/
  30663. export class AlphaState {
  30664. private _isAlphaBlendDirty;
  30665. private _isBlendFunctionParametersDirty;
  30666. private _isBlendEquationParametersDirty;
  30667. private _isBlendConstantsDirty;
  30668. private _alphaBlend;
  30669. private _blendFunctionParameters;
  30670. private _blendEquationParameters;
  30671. private _blendConstants;
  30672. /**
  30673. * Initializes the state.
  30674. */
  30675. constructor();
  30676. get isDirty(): boolean;
  30677. get alphaBlend(): boolean;
  30678. set alphaBlend(value: boolean);
  30679. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30680. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30681. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30682. reset(): void;
  30683. apply(gl: WebGLRenderingContext): void;
  30684. }
  30685. }
  30686. declare module BABYLON {
  30687. /** @hidden */
  30688. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30689. attributeProcessor(attribute: string): string;
  30690. varyingProcessor(varying: string, isFragment: boolean): string;
  30691. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30692. }
  30693. }
  30694. declare module BABYLON {
  30695. /**
  30696. * Interface for attribute information associated with buffer instanciation
  30697. */
  30698. export interface InstancingAttributeInfo {
  30699. /**
  30700. * Name of the GLSL attribute
  30701. * if attribute index is not specified, this is used to retrieve the index from the effect
  30702. */
  30703. attributeName: string;
  30704. /**
  30705. * Index/offset of the attribute in the vertex shader
  30706. * if not specified, this will be computes from the name.
  30707. */
  30708. index?: number;
  30709. /**
  30710. * size of the attribute, 1, 2, 3 or 4
  30711. */
  30712. attributeSize: number;
  30713. /**
  30714. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30715. */
  30716. offset: number;
  30717. /**
  30718. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30719. * default to 1
  30720. */
  30721. divisor?: number;
  30722. /**
  30723. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30724. * default is FLOAT
  30725. */
  30726. attributeType?: number;
  30727. /**
  30728. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30729. */
  30730. normalized?: boolean;
  30731. }
  30732. }
  30733. declare module BABYLON {
  30734. interface ThinEngine {
  30735. /**
  30736. * Update a video texture
  30737. * @param texture defines the texture to update
  30738. * @param video defines the video element to use
  30739. * @param invertY defines if data must be stored with Y axis inverted
  30740. */
  30741. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30742. }
  30743. }
  30744. declare module BABYLON {
  30745. /**
  30746. * Settings for finer control over video usage
  30747. */
  30748. export interface VideoTextureSettings {
  30749. /**
  30750. * Applies `autoplay` to video, if specified
  30751. */
  30752. autoPlay?: boolean;
  30753. /**
  30754. * Applies `loop` to video, if specified
  30755. */
  30756. loop?: boolean;
  30757. /**
  30758. * Automatically updates internal texture from video at every frame in the render loop
  30759. */
  30760. autoUpdateTexture: boolean;
  30761. /**
  30762. * Image src displayed during the video loading or until the user interacts with the video.
  30763. */
  30764. poster?: string;
  30765. }
  30766. /**
  30767. * If you want to display a video in your scene, this is the special texture for that.
  30768. * This special texture works similar to other textures, with the exception of a few parameters.
  30769. * @see https://doc.babylonjs.com/how_to/video_texture
  30770. */
  30771. export class VideoTexture extends Texture {
  30772. /**
  30773. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30774. */
  30775. readonly autoUpdateTexture: boolean;
  30776. /**
  30777. * The video instance used by the texture internally
  30778. */
  30779. readonly video: HTMLVideoElement;
  30780. private _onUserActionRequestedObservable;
  30781. /**
  30782. * Event triggerd when a dom action is required by the user to play the video.
  30783. * This happens due to recent changes in browser policies preventing video to auto start.
  30784. */
  30785. get onUserActionRequestedObservable(): Observable<Texture>;
  30786. private _generateMipMaps;
  30787. private _engine;
  30788. private _stillImageCaptured;
  30789. private _displayingPosterTexture;
  30790. private _settings;
  30791. private _createInternalTextureOnEvent;
  30792. private _frameId;
  30793. private _currentSrc;
  30794. /**
  30795. * Creates a video texture.
  30796. * If you want to display a video in your scene, this is the special texture for that.
  30797. * This special texture works similar to other textures, with the exception of a few parameters.
  30798. * @see https://doc.babylonjs.com/how_to/video_texture
  30799. * @param name optional name, will detect from video source, if not defined
  30800. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30801. * @param scene is obviously the current scene.
  30802. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30803. * @param invertY is false by default but can be used to invert video on Y axis
  30804. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30805. * @param settings allows finer control over video usage
  30806. */
  30807. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30808. private _getName;
  30809. private _getVideo;
  30810. private _createInternalTexture;
  30811. private reset;
  30812. /**
  30813. * @hidden Internal method to initiate `update`.
  30814. */
  30815. _rebuild(): void;
  30816. /**
  30817. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30818. */
  30819. update(): void;
  30820. /**
  30821. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30822. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30823. */
  30824. updateTexture(isVisible: boolean): void;
  30825. protected _updateInternalTexture: () => void;
  30826. /**
  30827. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30828. * @param url New url.
  30829. */
  30830. updateURL(url: string): void;
  30831. /**
  30832. * Clones the texture.
  30833. * @returns the cloned texture
  30834. */
  30835. clone(): VideoTexture;
  30836. /**
  30837. * Dispose the texture and release its associated resources.
  30838. */
  30839. dispose(): void;
  30840. /**
  30841. * Creates a video texture straight from a stream.
  30842. * @param scene Define the scene the texture should be created in
  30843. * @param stream Define the stream the texture should be created from
  30844. * @returns The created video texture as a promise
  30845. */
  30846. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30847. /**
  30848. * Creates a video texture straight from your WebCam video feed.
  30849. * @param scene Define the scene the texture should be created in
  30850. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30851. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30852. * @returns The created video texture as a promise
  30853. */
  30854. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30855. minWidth: number;
  30856. maxWidth: number;
  30857. minHeight: number;
  30858. maxHeight: number;
  30859. deviceId: string;
  30860. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30861. /**
  30862. * Creates a video texture straight from your WebCam video feed.
  30863. * @param scene Define the scene the texture should be created in
  30864. * @param onReady Define a callback to triggered once the texture will be ready
  30865. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30866. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30867. */
  30868. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30869. minWidth: number;
  30870. maxWidth: number;
  30871. minHeight: number;
  30872. maxHeight: number;
  30873. deviceId: string;
  30874. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30875. }
  30876. }
  30877. declare module BABYLON {
  30878. /**
  30879. * Defines the interface used by objects working like Scene
  30880. * @hidden
  30881. */
  30882. export interface ISceneLike {
  30883. _addPendingData(data: any): void;
  30884. _removePendingData(data: any): void;
  30885. offlineProvider: IOfflineProvider;
  30886. }
  30887. /** Interface defining initialization parameters for Engine class */
  30888. export interface EngineOptions extends WebGLContextAttributes {
  30889. /**
  30890. * Defines if the engine should no exceed a specified device ratio
  30891. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30892. */
  30893. limitDeviceRatio?: number;
  30894. /**
  30895. * Defines if webvr should be enabled automatically
  30896. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30897. */
  30898. autoEnableWebVR?: boolean;
  30899. /**
  30900. * Defines if webgl2 should be turned off even if supported
  30901. * @see http://doc.babylonjs.com/features/webgl2
  30902. */
  30903. disableWebGL2Support?: boolean;
  30904. /**
  30905. * Defines if webaudio should be initialized as well
  30906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30907. */
  30908. audioEngine?: boolean;
  30909. /**
  30910. * Defines if animations should run using a deterministic lock step
  30911. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30912. */
  30913. deterministicLockstep?: boolean;
  30914. /** Defines the maximum steps to use with deterministic lock step mode */
  30915. lockstepMaxSteps?: number;
  30916. /** Defines the seconds between each deterministic lock step */
  30917. timeStep?: number;
  30918. /**
  30919. * Defines that engine should ignore context lost events
  30920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30921. */
  30922. doNotHandleContextLost?: boolean;
  30923. /**
  30924. * Defines that engine should ignore modifying touch action attribute and style
  30925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30926. */
  30927. doNotHandleTouchAction?: boolean;
  30928. /**
  30929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30930. */
  30931. useHighPrecisionFloats?: boolean;
  30932. }
  30933. /**
  30934. * The base engine class (root of all engines)
  30935. */
  30936. export class ThinEngine {
  30937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30938. static ExceptionList: ({
  30939. key: string;
  30940. capture: string;
  30941. captureConstraint: number;
  30942. targets: string[];
  30943. } | {
  30944. key: string;
  30945. capture: null;
  30946. captureConstraint: null;
  30947. targets: string[];
  30948. })[];
  30949. /** @hidden */
  30950. static _TextureLoaders: IInternalTextureLoader[];
  30951. /**
  30952. * Returns the current npm package of the sdk
  30953. */
  30954. static get NpmPackage(): string;
  30955. /**
  30956. * Returns the current version of the framework
  30957. */
  30958. static get Version(): string;
  30959. /**
  30960. * Returns a string describing the current engine
  30961. */
  30962. get description(): string;
  30963. /**
  30964. * Gets or sets the epsilon value used by collision engine
  30965. */
  30966. static CollisionsEpsilon: number;
  30967. /**
  30968. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30969. */
  30970. static get ShadersRepository(): string;
  30971. static set ShadersRepository(value: string);
  30972. /** @hidden */
  30973. _shaderProcessor: IShaderProcessor;
  30974. /**
  30975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30976. */
  30977. forcePOTTextures: boolean;
  30978. /**
  30979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30980. */
  30981. isFullscreen: boolean;
  30982. /**
  30983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30984. */
  30985. cullBackFaces: boolean;
  30986. /**
  30987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30988. */
  30989. renderEvenInBackground: boolean;
  30990. /**
  30991. * Gets or sets a boolean indicating that cache can be kept between frames
  30992. */
  30993. preventCacheWipeBetweenFrames: boolean;
  30994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30995. validateShaderPrograms: boolean;
  30996. /**
  30997. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30998. * This can provide greater z depth for distant objects.
  30999. */
  31000. useReverseDepthBuffer: boolean;
  31001. /**
  31002. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31003. */
  31004. disableUniformBuffers: boolean;
  31005. /** @hidden */
  31006. _uniformBuffers: UniformBuffer[];
  31007. /**
  31008. * Gets a boolean indicating that the engine supports uniform buffers
  31009. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31010. */
  31011. get supportsUniformBuffers(): boolean;
  31012. /** @hidden */
  31013. _gl: WebGLRenderingContext;
  31014. /** @hidden */
  31015. _webGLVersion: number;
  31016. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31017. protected _windowIsBackground: boolean;
  31018. protected _creationOptions: EngineOptions;
  31019. protected _highPrecisionShadersAllowed: boolean;
  31020. /** @hidden */
  31021. get _shouldUseHighPrecisionShader(): boolean;
  31022. /**
  31023. * Gets a boolean indicating that only power of 2 textures are supported
  31024. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31025. */
  31026. get needPOTTextures(): boolean;
  31027. /** @hidden */
  31028. _badOS: boolean;
  31029. /** @hidden */
  31030. _badDesktopOS: boolean;
  31031. private _hardwareScalingLevel;
  31032. /** @hidden */
  31033. _caps: EngineCapabilities;
  31034. private _isStencilEnable;
  31035. private _glVersion;
  31036. private _glRenderer;
  31037. private _glVendor;
  31038. /** @hidden */
  31039. _videoTextureSupported: boolean;
  31040. protected _renderingQueueLaunched: boolean;
  31041. protected _activeRenderLoops: (() => void)[];
  31042. /**
  31043. * Observable signaled when a context lost event is raised
  31044. */
  31045. onContextLostObservable: Observable<ThinEngine>;
  31046. /**
  31047. * Observable signaled when a context restored event is raised
  31048. */
  31049. onContextRestoredObservable: Observable<ThinEngine>;
  31050. private _onContextLost;
  31051. private _onContextRestored;
  31052. protected _contextWasLost: boolean;
  31053. /** @hidden */
  31054. _doNotHandleContextLost: boolean;
  31055. /**
  31056. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31058. */
  31059. get doNotHandleContextLost(): boolean;
  31060. set doNotHandleContextLost(value: boolean);
  31061. /**
  31062. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31063. */
  31064. disableVertexArrayObjects: boolean;
  31065. /** @hidden */
  31066. protected _colorWrite: boolean;
  31067. /** @hidden */
  31068. protected _colorWriteChanged: boolean;
  31069. /** @hidden */
  31070. protected _depthCullingState: DepthCullingState;
  31071. /** @hidden */
  31072. protected _stencilState: StencilState;
  31073. /** @hidden */
  31074. _alphaState: AlphaState;
  31075. /** @hidden */
  31076. _alphaMode: number;
  31077. /** @hidden */
  31078. _alphaEquation: number;
  31079. /** @hidden */
  31080. _internalTexturesCache: InternalTexture[];
  31081. /** @hidden */
  31082. protected _activeChannel: number;
  31083. private _currentTextureChannel;
  31084. /** @hidden */
  31085. protected _boundTexturesCache: {
  31086. [key: string]: Nullable<InternalTexture>;
  31087. };
  31088. /** @hidden */
  31089. protected _currentEffect: Nullable<Effect>;
  31090. /** @hidden */
  31091. protected _currentProgram: Nullable<WebGLProgram>;
  31092. private _compiledEffects;
  31093. private _vertexAttribArraysEnabled;
  31094. /** @hidden */
  31095. protected _cachedViewport: Nullable<IViewportLike>;
  31096. private _cachedVertexArrayObject;
  31097. /** @hidden */
  31098. protected _cachedVertexBuffers: any;
  31099. /** @hidden */
  31100. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31101. /** @hidden */
  31102. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31103. /** @hidden */
  31104. _currentRenderTarget: Nullable<InternalTexture>;
  31105. private _uintIndicesCurrentlySet;
  31106. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31107. /** @hidden */
  31108. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31109. private _currentBufferPointers;
  31110. private _currentInstanceLocations;
  31111. private _currentInstanceBuffers;
  31112. private _textureUnits;
  31113. /** @hidden */
  31114. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31115. /** @hidden */
  31116. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31117. /** @hidden */
  31118. _boundRenderFunction: any;
  31119. private _vaoRecordInProgress;
  31120. private _mustWipeVertexAttributes;
  31121. private _emptyTexture;
  31122. private _emptyCubeTexture;
  31123. private _emptyTexture3D;
  31124. private _emptyTexture2DArray;
  31125. /** @hidden */
  31126. _frameHandler: number;
  31127. private _nextFreeTextureSlots;
  31128. private _maxSimultaneousTextures;
  31129. private _activeRequests;
  31130. protected _texturesSupported: string[];
  31131. /** @hidden */
  31132. _textureFormatInUse: Nullable<string>;
  31133. protected get _supportsHardwareTextureRescaling(): boolean;
  31134. /**
  31135. * Gets the list of texture formats supported
  31136. */
  31137. get texturesSupported(): Array<string>;
  31138. /**
  31139. * Gets the list of texture formats in use
  31140. */
  31141. get textureFormatInUse(): Nullable<string>;
  31142. /**
  31143. * Gets the current viewport
  31144. */
  31145. get currentViewport(): Nullable<IViewportLike>;
  31146. /**
  31147. * Gets the default empty texture
  31148. */
  31149. get emptyTexture(): InternalTexture;
  31150. /**
  31151. * Gets the default empty 3D texture
  31152. */
  31153. get emptyTexture3D(): InternalTexture;
  31154. /**
  31155. * Gets the default empty 2D array texture
  31156. */
  31157. get emptyTexture2DArray(): InternalTexture;
  31158. /**
  31159. * Gets the default empty cube texture
  31160. */
  31161. get emptyCubeTexture(): InternalTexture;
  31162. /**
  31163. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31164. */
  31165. readonly premultipliedAlpha: boolean;
  31166. /**
  31167. * Observable event triggered before each texture is initialized
  31168. */
  31169. onBeforeTextureInitObservable: Observable<Texture>;
  31170. /**
  31171. * Creates a new engine
  31172. * @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
  31173. * @param antialias defines enable antialiasing (default: false)
  31174. * @param options defines further options to be sent to the getContext() function
  31175. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31176. */
  31177. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31178. private _rebuildInternalTextures;
  31179. private _rebuildEffects;
  31180. /**
  31181. * Gets a boolean indicating if all created effects are ready
  31182. * @returns true if all effects are ready
  31183. */
  31184. areAllEffectsReady(): boolean;
  31185. protected _rebuildBuffers(): void;
  31186. private _initGLContext;
  31187. /**
  31188. * Gets version of the current webGL context
  31189. */
  31190. get webGLVersion(): number;
  31191. /**
  31192. * Gets a string idenfifying the name of the class
  31193. * @returns "Engine" string
  31194. */
  31195. getClassName(): string;
  31196. /**
  31197. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31198. */
  31199. get isStencilEnable(): boolean;
  31200. /** @hidden */
  31201. _prepareWorkingCanvas(): void;
  31202. /**
  31203. * Reset the texture cache to empty state
  31204. */
  31205. resetTextureCache(): void;
  31206. /**
  31207. * Gets an object containing information about the current webGL context
  31208. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31209. */
  31210. getGlInfo(): {
  31211. vendor: string;
  31212. renderer: string;
  31213. version: string;
  31214. };
  31215. /**
  31216. * Defines the hardware scaling level.
  31217. * By default the hardware scaling level is computed from the window device ratio.
  31218. * 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.
  31219. * @param level defines the level to use
  31220. */
  31221. setHardwareScalingLevel(level: number): void;
  31222. /**
  31223. * Gets the current hardware scaling level.
  31224. * By default the hardware scaling level is computed from the window device ratio.
  31225. * 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.
  31226. * @returns a number indicating the current hardware scaling level
  31227. */
  31228. getHardwareScalingLevel(): number;
  31229. /**
  31230. * Gets the list of loaded textures
  31231. * @returns an array containing all loaded textures
  31232. */
  31233. getLoadedTexturesCache(): InternalTexture[];
  31234. /**
  31235. * Gets the object containing all engine capabilities
  31236. * @returns the EngineCapabilities object
  31237. */
  31238. getCaps(): EngineCapabilities;
  31239. /**
  31240. * stop executing a render loop function and remove it from the execution array
  31241. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31242. */
  31243. stopRenderLoop(renderFunction?: () => void): void;
  31244. /** @hidden */
  31245. _renderLoop(): void;
  31246. /**
  31247. * Gets the HTML canvas attached with the current webGL context
  31248. * @returns a HTML canvas
  31249. */
  31250. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31251. /**
  31252. * Gets host window
  31253. * @returns the host window object
  31254. */
  31255. getHostWindow(): Nullable<Window>;
  31256. /**
  31257. * Gets the current render width
  31258. * @param useScreen defines if screen size must be used (or the current render target if any)
  31259. * @returns a number defining the current render width
  31260. */
  31261. getRenderWidth(useScreen?: boolean): number;
  31262. /**
  31263. * Gets the current render height
  31264. * @param useScreen defines if screen size must be used (or the current render target if any)
  31265. * @returns a number defining the current render height
  31266. */
  31267. getRenderHeight(useScreen?: boolean): number;
  31268. /**
  31269. * Can be used to override the current requestAnimationFrame requester.
  31270. * @hidden
  31271. */
  31272. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31273. /**
  31274. * Register and execute a render loop. The engine can have more than one render function
  31275. * @param renderFunction defines the function to continuously execute
  31276. */
  31277. runRenderLoop(renderFunction: () => void): void;
  31278. /**
  31279. * Clear the current render buffer or the current render target (if any is set up)
  31280. * @param color defines the color to use
  31281. * @param backBuffer defines if the back buffer must be cleared
  31282. * @param depth defines if the depth buffer must be cleared
  31283. * @param stencil defines if the stencil buffer must be cleared
  31284. */
  31285. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31286. private _viewportCached;
  31287. /** @hidden */
  31288. _viewport(x: number, y: number, width: number, height: number): void;
  31289. /**
  31290. * Set the WebGL's viewport
  31291. * @param viewport defines the viewport element to be used
  31292. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31293. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31294. */
  31295. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31296. /**
  31297. * Begin a new frame
  31298. */
  31299. beginFrame(): void;
  31300. /**
  31301. * Enf the current frame
  31302. */
  31303. endFrame(): void;
  31304. /**
  31305. * Resize the view according to the canvas' size
  31306. */
  31307. resize(): void;
  31308. /**
  31309. * Force a specific size of the canvas
  31310. * @param width defines the new canvas' width
  31311. * @param height defines the new canvas' height
  31312. */
  31313. setSize(width: number, height: number): void;
  31314. /**
  31315. * Binds the frame buffer to the specified texture.
  31316. * @param texture The texture to render to or null for the default canvas
  31317. * @param faceIndex The face of the texture to render to in case of cube texture
  31318. * @param requiredWidth The width of the target to render to
  31319. * @param requiredHeight The height of the target to render to
  31320. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31321. * @param lodLevel defines the lod level to bind to the frame buffer
  31322. * @param layer defines the 2d array index to bind to frame buffer to
  31323. */
  31324. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31325. /** @hidden */
  31326. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31327. /**
  31328. * Unbind the current render target texture from the webGL context
  31329. * @param texture defines the render target texture to unbind
  31330. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31331. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31332. */
  31333. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31334. /**
  31335. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31336. */
  31337. flushFramebuffer(): void;
  31338. /**
  31339. * Unbind the current render target and bind the default framebuffer
  31340. */
  31341. restoreDefaultFramebuffer(): void;
  31342. /** @hidden */
  31343. protected _resetVertexBufferBinding(): void;
  31344. /**
  31345. * Creates a vertex buffer
  31346. * @param data the data for the vertex buffer
  31347. * @returns the new WebGL static buffer
  31348. */
  31349. createVertexBuffer(data: DataArray): DataBuffer;
  31350. private _createVertexBuffer;
  31351. /**
  31352. * Creates a dynamic vertex buffer
  31353. * @param data the data for the dynamic vertex buffer
  31354. * @returns the new WebGL dynamic buffer
  31355. */
  31356. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31357. protected _resetIndexBufferBinding(): void;
  31358. /**
  31359. * Creates a new index buffer
  31360. * @param indices defines the content of the index buffer
  31361. * @param updatable defines if the index buffer must be updatable
  31362. * @returns a new webGL buffer
  31363. */
  31364. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31365. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31366. /**
  31367. * Bind a webGL buffer to the webGL context
  31368. * @param buffer defines the buffer to bind
  31369. */
  31370. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31371. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31372. private bindBuffer;
  31373. /**
  31374. * update the bound buffer with the given data
  31375. * @param data defines the data to update
  31376. */
  31377. updateArrayBuffer(data: Float32Array): void;
  31378. private _vertexAttribPointer;
  31379. /** @hidden */
  31380. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31381. private _bindVertexBuffersAttributes;
  31382. /**
  31383. * Records a vertex array object
  31384. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31385. * @param vertexBuffers defines the list of vertex buffers to store
  31386. * @param indexBuffer defines the index buffer to store
  31387. * @param effect defines the effect to store
  31388. * @returns the new vertex array object
  31389. */
  31390. recordVertexArrayObject(vertexBuffers: {
  31391. [key: string]: VertexBuffer;
  31392. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31393. /**
  31394. * Bind a specific vertex array object
  31395. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31396. * @param vertexArrayObject defines the vertex array object to bind
  31397. * @param indexBuffer defines the index buffer to bind
  31398. */
  31399. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31400. /**
  31401. * Bind webGl buffers directly to the webGL context
  31402. * @param vertexBuffer defines the vertex buffer to bind
  31403. * @param indexBuffer defines the index buffer to bind
  31404. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31405. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31406. * @param effect defines the effect associated with the vertex buffer
  31407. */
  31408. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31409. private _unbindVertexArrayObject;
  31410. /**
  31411. * Bind a list of vertex buffers to the webGL context
  31412. * @param vertexBuffers defines the list of vertex buffers to bind
  31413. * @param indexBuffer defines the index buffer to bind
  31414. * @param effect defines the effect associated with the vertex buffers
  31415. */
  31416. bindBuffers(vertexBuffers: {
  31417. [key: string]: Nullable<VertexBuffer>;
  31418. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31419. /**
  31420. * Unbind all instance attributes
  31421. */
  31422. unbindInstanceAttributes(): void;
  31423. /**
  31424. * Release and free the memory of a vertex array object
  31425. * @param vao defines the vertex array object to delete
  31426. */
  31427. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31428. /** @hidden */
  31429. _releaseBuffer(buffer: DataBuffer): boolean;
  31430. protected _deleteBuffer(buffer: DataBuffer): void;
  31431. /**
  31432. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31433. * @param instancesBuffer defines the webGL buffer to update and bind
  31434. * @param data defines the data to store in the buffer
  31435. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31436. */
  31437. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31438. /**
  31439. * Bind the content of a webGL buffer used with instantiation
  31440. * @param instancesBuffer defines the webGL buffer to bind
  31441. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31442. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31443. */
  31444. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31445. /**
  31446. * Disable the instance attribute corresponding to the name in parameter
  31447. * @param name defines the name of the attribute to disable
  31448. */
  31449. disableInstanceAttributeByName(name: string): void;
  31450. /**
  31451. * Disable the instance attribute corresponding to the location in parameter
  31452. * @param attributeLocation defines the attribute location of the attribute to disable
  31453. */
  31454. disableInstanceAttribute(attributeLocation: number): void;
  31455. /**
  31456. * Disable the attribute corresponding to the location in parameter
  31457. * @param attributeLocation defines the attribute location of the attribute to disable
  31458. */
  31459. disableAttributeByIndex(attributeLocation: number): void;
  31460. /**
  31461. * Send a draw order
  31462. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31463. * @param indexStart defines the starting index
  31464. * @param indexCount defines the number of index to draw
  31465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31466. */
  31467. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31468. /**
  31469. * Draw a list of points
  31470. * @param verticesStart defines the index of first vertex to draw
  31471. * @param verticesCount defines the count of vertices to draw
  31472. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31473. */
  31474. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31475. /**
  31476. * Draw a list of unindexed primitives
  31477. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31478. * @param verticesStart defines the index of first vertex to draw
  31479. * @param verticesCount defines the count of vertices to draw
  31480. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31481. */
  31482. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31483. /**
  31484. * Draw a list of indexed primitives
  31485. * @param fillMode defines the primitive to use
  31486. * @param indexStart defines the starting index
  31487. * @param indexCount defines the number of index to draw
  31488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31489. */
  31490. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31491. /**
  31492. * Draw a list of unindexed primitives
  31493. * @param fillMode defines the primitive to use
  31494. * @param verticesStart defines the index of first vertex to draw
  31495. * @param verticesCount defines the count of vertices to draw
  31496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31497. */
  31498. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31499. private _drawMode;
  31500. /** @hidden */
  31501. protected _reportDrawCall(): void;
  31502. /** @hidden */
  31503. _releaseEffect(effect: Effect): void;
  31504. /** @hidden */
  31505. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31506. /**
  31507. * Create a new effect (used to store vertex/fragment shaders)
  31508. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31509. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31510. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31511. * @param samplers defines an array of string used to represent textures
  31512. * @param defines defines the string containing the defines to use to compile the shaders
  31513. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31514. * @param onCompiled defines a function to call when the effect creation is successful
  31515. * @param onError defines a function to call when the effect creation has failed
  31516. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31517. * @returns the new Effect
  31518. */
  31519. 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;
  31520. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31521. private _compileShader;
  31522. private _compileRawShader;
  31523. /**
  31524. * Directly creates a webGL program
  31525. * @param pipelineContext defines the pipeline context to attach to
  31526. * @param vertexCode defines the vertex shader code to use
  31527. * @param fragmentCode defines the fragment shader code to use
  31528. * @param context defines the webGL context to use (if not set, the current one will be used)
  31529. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31530. * @returns the new webGL program
  31531. */
  31532. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31533. /**
  31534. * Creates a webGL program
  31535. * @param pipelineContext defines the pipeline context to attach to
  31536. * @param vertexCode defines the vertex shader code to use
  31537. * @param fragmentCode defines the fragment shader code to use
  31538. * @param defines defines the string containing the defines to use to compile the shaders
  31539. * @param context defines the webGL context to use (if not set, the current one will be used)
  31540. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31541. * @returns the new webGL program
  31542. */
  31543. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31544. /**
  31545. * Creates a new pipeline context
  31546. * @returns the new pipeline
  31547. */
  31548. createPipelineContext(): IPipelineContext;
  31549. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31550. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31551. /** @hidden */
  31552. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31553. /** @hidden */
  31554. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31555. /** @hidden */
  31556. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31557. /**
  31558. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31559. * @param pipelineContext defines the pipeline context to use
  31560. * @param uniformsNames defines the list of uniform names
  31561. * @returns an array of webGL uniform locations
  31562. */
  31563. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31564. /**
  31565. * Gets the lsit of active attributes for a given webGL program
  31566. * @param pipelineContext defines the pipeline context to use
  31567. * @param attributesNames defines the list of attribute names to get
  31568. * @returns an array of indices indicating the offset of each attribute
  31569. */
  31570. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31571. /**
  31572. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31573. * @param effect defines the effect to activate
  31574. */
  31575. enableEffect(effect: Nullable<Effect>): void;
  31576. /**
  31577. * Set the value of an uniform to a number (int)
  31578. * @param uniform defines the webGL uniform location where to store the value
  31579. * @param value defines the int number to store
  31580. */
  31581. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31582. /**
  31583. * Set the value of an uniform to an array of int32
  31584. * @param uniform defines the webGL uniform location where to store the value
  31585. * @param array defines the array of int32 to store
  31586. */
  31587. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31588. /**
  31589. * Set the value of an uniform to an array of int32 (stored as vec2)
  31590. * @param uniform defines the webGL uniform location where to store the value
  31591. * @param array defines the array of int32 to store
  31592. */
  31593. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31594. /**
  31595. * Set the value of an uniform to an array of int32 (stored as vec3)
  31596. * @param uniform defines the webGL uniform location where to store the value
  31597. * @param array defines the array of int32 to store
  31598. */
  31599. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31600. /**
  31601. * Set the value of an uniform to an array of int32 (stored as vec4)
  31602. * @param uniform defines the webGL uniform location where to store the value
  31603. * @param array defines the array of int32 to store
  31604. */
  31605. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31606. /**
  31607. * Set the value of an uniform to an array of number
  31608. * @param uniform defines the webGL uniform location where to store the value
  31609. * @param array defines the array of number to store
  31610. */
  31611. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31612. /**
  31613. * Set the value of an uniform to an array of number (stored as vec2)
  31614. * @param uniform defines the webGL uniform location where to store the value
  31615. * @param array defines the array of number to store
  31616. */
  31617. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31618. /**
  31619. * Set the value of an uniform to an array of number (stored as vec3)
  31620. * @param uniform defines the webGL uniform location where to store the value
  31621. * @param array defines the array of number to store
  31622. */
  31623. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31624. /**
  31625. * Set the value of an uniform to an array of number (stored as vec4)
  31626. * @param uniform defines the webGL uniform location where to store the value
  31627. * @param array defines the array of number to store
  31628. */
  31629. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31630. /**
  31631. * Set the value of an uniform to an array of float32 (stored as matrices)
  31632. * @param uniform defines the webGL uniform location where to store the value
  31633. * @param matrices defines the array of float32 to store
  31634. */
  31635. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31636. /**
  31637. * Set the value of an uniform to a matrix (3x3)
  31638. * @param uniform defines the webGL uniform location where to store the value
  31639. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31640. */
  31641. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31642. /**
  31643. * Set the value of an uniform to a matrix (2x2)
  31644. * @param uniform defines the webGL uniform location where to store the value
  31645. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31646. */
  31647. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31648. /**
  31649. * Set the value of an uniform to a number (float)
  31650. * @param uniform defines the webGL uniform location where to store the value
  31651. * @param value defines the float number to store
  31652. */
  31653. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31654. /**
  31655. * Set the value of an uniform to a vec2
  31656. * @param uniform defines the webGL uniform location where to store the value
  31657. * @param x defines the 1st component of the value
  31658. * @param y defines the 2nd component of the value
  31659. */
  31660. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31661. /**
  31662. * Set the value of an uniform to a vec3
  31663. * @param uniform defines the webGL uniform location where to store the value
  31664. * @param x defines the 1st component of the value
  31665. * @param y defines the 2nd component of the value
  31666. * @param z defines the 3rd component of the value
  31667. */
  31668. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31669. /**
  31670. * Set the value of an uniform to a vec4
  31671. * @param uniform defines the webGL uniform location where to store the value
  31672. * @param x defines the 1st component of the value
  31673. * @param y defines the 2nd component of the value
  31674. * @param z defines the 3rd component of the value
  31675. * @param w defines the 4th component of the value
  31676. */
  31677. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31678. /**
  31679. * Apply all cached states (depth, culling, stencil and alpha)
  31680. */
  31681. applyStates(): void;
  31682. /**
  31683. * Enable or disable color writing
  31684. * @param enable defines the state to set
  31685. */
  31686. setColorWrite(enable: boolean): void;
  31687. /**
  31688. * Gets a boolean indicating if color writing is enabled
  31689. * @returns the current color writing state
  31690. */
  31691. getColorWrite(): boolean;
  31692. /**
  31693. * Gets the depth culling state manager
  31694. */
  31695. get depthCullingState(): DepthCullingState;
  31696. /**
  31697. * Gets the alpha state manager
  31698. */
  31699. get alphaState(): AlphaState;
  31700. /**
  31701. * Gets the stencil state manager
  31702. */
  31703. get stencilState(): StencilState;
  31704. /**
  31705. * Clears the list of texture accessible through engine.
  31706. * This can help preventing texture load conflict due to name collision.
  31707. */
  31708. clearInternalTexturesCache(): void;
  31709. /**
  31710. * Force the entire cache to be cleared
  31711. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31712. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31713. */
  31714. wipeCaches(bruteForce?: boolean): void;
  31715. /** @hidden */
  31716. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31717. min: number;
  31718. mag: number;
  31719. };
  31720. /** @hidden */
  31721. _createTexture(): WebGLTexture;
  31722. /**
  31723. * Usually called from Texture.ts.
  31724. * Passed information to create a WebGLTexture
  31725. * @param urlArg defines a value which contains one of the following:
  31726. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31727. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31728. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31729. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31730. * @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)
  31731. * @param scene needed for loading to the correct scene
  31732. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31733. * @param onLoad optional callback to be called upon successful completion
  31734. * @param onError optional callback to be called upon failure
  31735. * @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
  31736. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31737. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31738. * @param forcedExtension defines the extension to use to pick the right loader
  31739. * @param mimeType defines an optional mime type
  31740. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31741. */
  31742. 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>, mimeType?: string): InternalTexture;
  31743. /**
  31744. * Loads an image as an HTMLImageElement.
  31745. * @param input url string, ArrayBuffer, or Blob to load
  31746. * @param onLoad callback called when the image successfully loads
  31747. * @param onError callback called when the image fails to load
  31748. * @param offlineProvider offline provider for caching
  31749. * @param mimeType optional mime type
  31750. * @returns the HTMLImageElement of the loaded image
  31751. * @hidden
  31752. */
  31753. 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>;
  31754. /**
  31755. * @hidden
  31756. */
  31757. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31758. /**
  31759. * Creates a raw texture
  31760. * @param data defines the data to store in the texture
  31761. * @param width defines the width of the texture
  31762. * @param height defines the height of the texture
  31763. * @param format defines the format of the data
  31764. * @param generateMipMaps defines if the engine should generate the mip levels
  31765. * @param invertY defines if data must be stored with Y axis inverted
  31766. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31767. * @param compression defines the compression used (null by default)
  31768. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31769. * @returns the raw texture inside an InternalTexture
  31770. */
  31771. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31772. /**
  31773. * Creates a new raw cube texture
  31774. * @param data defines the array of data to use to create each face
  31775. * @param size defines the size of the textures
  31776. * @param format defines the format of the data
  31777. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31778. * @param generateMipMaps defines if the engine should generate the mip levels
  31779. * @param invertY defines if data must be stored with Y axis inverted
  31780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31781. * @param compression defines the compression used (null by default)
  31782. * @returns the cube texture as an InternalTexture
  31783. */
  31784. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31785. /**
  31786. * Creates a new raw 3D texture
  31787. * @param data defines the data used to create the texture
  31788. * @param width defines the width of the texture
  31789. * @param height defines the height of the texture
  31790. * @param depth defines the depth of the texture
  31791. * @param format defines the format of the texture
  31792. * @param generateMipMaps defines if the engine must generate mip levels
  31793. * @param invertY defines if data must be stored with Y axis inverted
  31794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31795. * @param compression defines the compressed used (can be null)
  31796. * @param textureType defines the compressed used (can be null)
  31797. * @returns a new raw 3D texture (stored in an InternalTexture)
  31798. */
  31799. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31800. /**
  31801. * Creates a new raw 2D array texture
  31802. * @param data defines the data used to create the texture
  31803. * @param width defines the width of the texture
  31804. * @param height defines the height of the texture
  31805. * @param depth defines the number of layers of the texture
  31806. * @param format defines the format of the texture
  31807. * @param generateMipMaps defines if the engine must generate mip levels
  31808. * @param invertY defines if data must be stored with Y axis inverted
  31809. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31810. * @param compression defines the compressed used (can be null)
  31811. * @param textureType defines the compressed used (can be null)
  31812. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31813. */
  31814. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31815. private _unpackFlipYCached;
  31816. /**
  31817. * In case you are sharing the context with other applications, it might
  31818. * be interested to not cache the unpack flip y state to ensure a consistent
  31819. * value would be set.
  31820. */
  31821. enableUnpackFlipYCached: boolean;
  31822. /** @hidden */
  31823. _unpackFlipY(value: boolean): void;
  31824. /** @hidden */
  31825. _getUnpackAlignement(): number;
  31826. private _getTextureTarget;
  31827. /**
  31828. * Update the sampling mode of a given texture
  31829. * @param samplingMode defines the required sampling mode
  31830. * @param texture defines the texture to update
  31831. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31832. */
  31833. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31834. /**
  31835. * Update the sampling mode of a given texture
  31836. * @param texture defines the texture to update
  31837. * @param wrapU defines the texture wrap mode of the u coordinates
  31838. * @param wrapV defines the texture wrap mode of the v coordinates
  31839. * @param wrapR defines the texture wrap mode of the r coordinates
  31840. */
  31841. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31842. /** @hidden */
  31843. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31844. width: number;
  31845. height: number;
  31846. layers?: number;
  31847. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31848. /** @hidden */
  31849. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31850. /** @hidden */
  31851. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31852. /**
  31853. * Update a portion of an internal texture
  31854. * @param texture defines the texture to update
  31855. * @param imageData defines the data to store into the texture
  31856. * @param xOffset defines the x coordinates of the update rectangle
  31857. * @param yOffset defines the y coordinates of the update rectangle
  31858. * @param width defines the width of the update rectangle
  31859. * @param height defines the height of the update rectangle
  31860. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31861. * @param lod defines the lod level to update (0 by default)
  31862. */
  31863. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31864. /** @hidden */
  31865. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31866. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31867. private _prepareWebGLTexture;
  31868. /** @hidden */
  31869. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31870. private _getDepthStencilBuffer;
  31871. /** @hidden */
  31872. _releaseFramebufferObjects(texture: InternalTexture): void;
  31873. /** @hidden */
  31874. _releaseTexture(texture: InternalTexture): void;
  31875. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31876. protected _setProgram(program: WebGLProgram): void;
  31877. protected _boundUniforms: {
  31878. [key: number]: WebGLUniformLocation;
  31879. };
  31880. /**
  31881. * Binds an effect to the webGL context
  31882. * @param effect defines the effect to bind
  31883. */
  31884. bindSamplers(effect: Effect): void;
  31885. private _activateCurrentTexture;
  31886. /** @hidden */
  31887. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31888. /** @hidden */
  31889. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31890. /**
  31891. * Unbind all textures from the webGL context
  31892. */
  31893. unbindAllTextures(): void;
  31894. /**
  31895. * Sets a texture to the according uniform.
  31896. * @param channel The texture channel
  31897. * @param uniform The uniform to set
  31898. * @param texture The texture to apply
  31899. */
  31900. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31901. private _bindSamplerUniformToChannel;
  31902. private _getTextureWrapMode;
  31903. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31904. /**
  31905. * Sets an array of texture to the webGL context
  31906. * @param channel defines the channel where the texture array must be set
  31907. * @param uniform defines the associated uniform location
  31908. * @param textures defines the array of textures to bind
  31909. */
  31910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31911. /** @hidden */
  31912. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31913. private _setTextureParameterFloat;
  31914. private _setTextureParameterInteger;
  31915. /**
  31916. * Unbind all vertex attributes from the webGL context
  31917. */
  31918. unbindAllAttributes(): void;
  31919. /**
  31920. * 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
  31921. */
  31922. releaseEffects(): void;
  31923. /**
  31924. * Dispose and release all associated resources
  31925. */
  31926. dispose(): void;
  31927. /**
  31928. * Attach a new callback raised when context lost event is fired
  31929. * @param callback defines the callback to call
  31930. */
  31931. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31932. /**
  31933. * Attach a new callback raised when context restored event is fired
  31934. * @param callback defines the callback to call
  31935. */
  31936. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31937. /**
  31938. * Get the current error code of the webGL context
  31939. * @returns the error code
  31940. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31941. */
  31942. getError(): number;
  31943. private _canRenderToFloatFramebuffer;
  31944. private _canRenderToHalfFloatFramebuffer;
  31945. private _canRenderToFramebuffer;
  31946. /** @hidden */
  31947. _getWebGLTextureType(type: number): number;
  31948. /** @hidden */
  31949. _getInternalFormat(format: number): number;
  31950. /** @hidden */
  31951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31952. /** @hidden */
  31953. _getRGBAMultiSampleBufferFormat(type: number): number;
  31954. /** @hidden */
  31955. _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;
  31956. /**
  31957. * Loads a file from a url
  31958. * @param url url to load
  31959. * @param onSuccess callback called when the file successfully loads
  31960. * @param onProgress callback called while file is loading (if the server supports this mode)
  31961. * @param offlineProvider defines the offline provider for caching
  31962. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31963. * @param onError callback called when the file fails to load
  31964. * @returns a file request object
  31965. * @hidden
  31966. */
  31967. 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;
  31968. /**
  31969. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31970. * @param x defines the x coordinate of the rectangle where pixels must be read
  31971. * @param y defines the y coordinate of the rectangle where pixels must be read
  31972. * @param width defines the width of the rectangle where pixels must be read
  31973. * @param height defines the height of the rectangle where pixels must be read
  31974. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31975. * @returns a Uint8Array containing RGBA colors
  31976. */
  31977. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31978. private static _isSupported;
  31979. /**
  31980. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31981. * @returns true if the engine can be created
  31982. * @ignorenaming
  31983. */
  31984. static isSupported(): boolean;
  31985. /**
  31986. * Find the next highest power of two.
  31987. * @param x Number to start search from.
  31988. * @return Next highest power of two.
  31989. */
  31990. static CeilingPOT(x: number): number;
  31991. /**
  31992. * Find the next lowest power of two.
  31993. * @param x Number to start search from.
  31994. * @return Next lowest power of two.
  31995. */
  31996. static FloorPOT(x: number): number;
  31997. /**
  31998. * Find the nearest power of two.
  31999. * @param x Number to start search from.
  32000. * @return Next nearest power of two.
  32001. */
  32002. static NearestPOT(x: number): number;
  32003. /**
  32004. * Get the closest exponent of two
  32005. * @param value defines the value to approximate
  32006. * @param max defines the maximum value to return
  32007. * @param mode defines how to define the closest value
  32008. * @returns closest exponent of two of the given value
  32009. */
  32010. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32011. /**
  32012. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32013. * @param func - the function to be called
  32014. * @param requester - the object that will request the next frame. Falls back to window.
  32015. * @returns frame number
  32016. */
  32017. static QueueNewFrame(func: () => void, requester?: any): number;
  32018. /**
  32019. * Gets host document
  32020. * @returns the host document object
  32021. */
  32022. getHostDocument(): Nullable<Document>;
  32023. }
  32024. }
  32025. declare module BABYLON {
  32026. /**
  32027. * Class representing spherical harmonics coefficients to the 3rd degree
  32028. */
  32029. export class SphericalHarmonics {
  32030. /**
  32031. * Defines whether or not the harmonics have been prescaled for rendering.
  32032. */
  32033. preScaled: boolean;
  32034. /**
  32035. * The l0,0 coefficients of the spherical harmonics
  32036. */
  32037. l00: Vector3;
  32038. /**
  32039. * The l1,-1 coefficients of the spherical harmonics
  32040. */
  32041. l1_1: Vector3;
  32042. /**
  32043. * The l1,0 coefficients of the spherical harmonics
  32044. */
  32045. l10: Vector3;
  32046. /**
  32047. * The l1,1 coefficients of the spherical harmonics
  32048. */
  32049. l11: Vector3;
  32050. /**
  32051. * The l2,-2 coefficients of the spherical harmonics
  32052. */
  32053. l2_2: Vector3;
  32054. /**
  32055. * The l2,-1 coefficients of the spherical harmonics
  32056. */
  32057. l2_1: Vector3;
  32058. /**
  32059. * The l2,0 coefficients of the spherical harmonics
  32060. */
  32061. l20: Vector3;
  32062. /**
  32063. * The l2,1 coefficients of the spherical harmonics
  32064. */
  32065. l21: Vector3;
  32066. /**
  32067. * The l2,2 coefficients of the spherical harmonics
  32068. */
  32069. l22: Vector3;
  32070. /**
  32071. * Adds a light to the spherical harmonics
  32072. * @param direction the direction of the light
  32073. * @param color the color of the light
  32074. * @param deltaSolidAngle the delta solid angle of the light
  32075. */
  32076. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32077. /**
  32078. * Scales the spherical harmonics by the given amount
  32079. * @param scale the amount to scale
  32080. */
  32081. scaleInPlace(scale: number): void;
  32082. /**
  32083. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32084. *
  32085. * ```
  32086. * E_lm = A_l * L_lm
  32087. * ```
  32088. *
  32089. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32090. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32091. * the scaling factors are given in equation 9.
  32092. */
  32093. convertIncidentRadianceToIrradiance(): void;
  32094. /**
  32095. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32096. *
  32097. * ```
  32098. * L = (1/pi) * E * rho
  32099. * ```
  32100. *
  32101. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32102. */
  32103. convertIrradianceToLambertianRadiance(): void;
  32104. /**
  32105. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32106. * required operations at run time.
  32107. *
  32108. * This is simply done by scaling back the SH with Ylm constants parameter.
  32109. * The trigonometric part being applied by the shader at run time.
  32110. */
  32111. preScaleForRendering(): void;
  32112. /**
  32113. * Constructs a spherical harmonics from an array.
  32114. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32115. * @returns the spherical harmonics
  32116. */
  32117. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32118. /**
  32119. * Gets the spherical harmonics from polynomial
  32120. * @param polynomial the spherical polynomial
  32121. * @returns the spherical harmonics
  32122. */
  32123. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32124. }
  32125. /**
  32126. * Class representing spherical polynomial coefficients to the 3rd degree
  32127. */
  32128. export class SphericalPolynomial {
  32129. private _harmonics;
  32130. /**
  32131. * The spherical harmonics used to create the polynomials.
  32132. */
  32133. get preScaledHarmonics(): SphericalHarmonics;
  32134. /**
  32135. * The x coefficients of the spherical polynomial
  32136. */
  32137. x: Vector3;
  32138. /**
  32139. * The y coefficients of the spherical polynomial
  32140. */
  32141. y: Vector3;
  32142. /**
  32143. * The z coefficients of the spherical polynomial
  32144. */
  32145. z: Vector3;
  32146. /**
  32147. * The xx coefficients of the spherical polynomial
  32148. */
  32149. xx: Vector3;
  32150. /**
  32151. * The yy coefficients of the spherical polynomial
  32152. */
  32153. yy: Vector3;
  32154. /**
  32155. * The zz coefficients of the spherical polynomial
  32156. */
  32157. zz: Vector3;
  32158. /**
  32159. * The xy coefficients of the spherical polynomial
  32160. */
  32161. xy: Vector3;
  32162. /**
  32163. * The yz coefficients of the spherical polynomial
  32164. */
  32165. yz: Vector3;
  32166. /**
  32167. * The zx coefficients of the spherical polynomial
  32168. */
  32169. zx: Vector3;
  32170. /**
  32171. * Adds an ambient color to the spherical polynomial
  32172. * @param color the color to add
  32173. */
  32174. addAmbient(color: Color3): void;
  32175. /**
  32176. * Scales the spherical polynomial by the given amount
  32177. * @param scale the amount to scale
  32178. */
  32179. scaleInPlace(scale: number): void;
  32180. /**
  32181. * Gets the spherical polynomial from harmonics
  32182. * @param harmonics the spherical harmonics
  32183. * @returns the spherical polynomial
  32184. */
  32185. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32186. /**
  32187. * Constructs a spherical polynomial from an array.
  32188. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32189. * @returns the spherical polynomial
  32190. */
  32191. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32192. }
  32193. }
  32194. declare module BABYLON {
  32195. /**
  32196. * Defines the source of the internal texture
  32197. */
  32198. export enum InternalTextureSource {
  32199. /**
  32200. * The source of the texture data is unknown
  32201. */
  32202. Unknown = 0,
  32203. /**
  32204. * Texture data comes from an URL
  32205. */
  32206. Url = 1,
  32207. /**
  32208. * Texture data is only used for temporary storage
  32209. */
  32210. Temp = 2,
  32211. /**
  32212. * Texture data comes from raw data (ArrayBuffer)
  32213. */
  32214. Raw = 3,
  32215. /**
  32216. * Texture content is dynamic (video or dynamic texture)
  32217. */
  32218. Dynamic = 4,
  32219. /**
  32220. * Texture content is generated by rendering to it
  32221. */
  32222. RenderTarget = 5,
  32223. /**
  32224. * Texture content is part of a multi render target process
  32225. */
  32226. MultiRenderTarget = 6,
  32227. /**
  32228. * Texture data comes from a cube data file
  32229. */
  32230. Cube = 7,
  32231. /**
  32232. * Texture data comes from a raw cube data
  32233. */
  32234. CubeRaw = 8,
  32235. /**
  32236. * Texture data come from a prefiltered cube data file
  32237. */
  32238. CubePrefiltered = 9,
  32239. /**
  32240. * Texture content is raw 3D data
  32241. */
  32242. Raw3D = 10,
  32243. /**
  32244. * Texture content is raw 2D array data
  32245. */
  32246. Raw2DArray = 11,
  32247. /**
  32248. * Texture content is a depth texture
  32249. */
  32250. Depth = 12,
  32251. /**
  32252. * Texture data comes from a raw cube data encoded with RGBD
  32253. */
  32254. CubeRawRGBD = 13
  32255. }
  32256. /**
  32257. * Class used to store data associated with WebGL texture data for the engine
  32258. * This class should not be used directly
  32259. */
  32260. export class InternalTexture {
  32261. /** @hidden */
  32262. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32263. /**
  32264. * Defines if the texture is ready
  32265. */
  32266. isReady: boolean;
  32267. /**
  32268. * Defines if the texture is a cube texture
  32269. */
  32270. isCube: boolean;
  32271. /**
  32272. * Defines if the texture contains 3D data
  32273. */
  32274. is3D: boolean;
  32275. /**
  32276. * Defines if the texture contains 2D array data
  32277. */
  32278. is2DArray: boolean;
  32279. /**
  32280. * Defines if the texture contains multiview data
  32281. */
  32282. isMultiview: boolean;
  32283. /**
  32284. * Gets the URL used to load this texture
  32285. */
  32286. url: string;
  32287. /**
  32288. * Gets the sampling mode of the texture
  32289. */
  32290. samplingMode: number;
  32291. /**
  32292. * Gets a boolean indicating if the texture needs mipmaps generation
  32293. */
  32294. generateMipMaps: boolean;
  32295. /**
  32296. * Gets the number of samples used by the texture (WebGL2+ only)
  32297. */
  32298. samples: number;
  32299. /**
  32300. * Gets the type of the texture (int, float...)
  32301. */
  32302. type: number;
  32303. /**
  32304. * Gets the format of the texture (RGB, RGBA...)
  32305. */
  32306. format: number;
  32307. /**
  32308. * Observable called when the texture is loaded
  32309. */
  32310. onLoadedObservable: Observable<InternalTexture>;
  32311. /**
  32312. * Gets the width of the texture
  32313. */
  32314. width: number;
  32315. /**
  32316. * Gets the height of the texture
  32317. */
  32318. height: number;
  32319. /**
  32320. * Gets the depth of the texture
  32321. */
  32322. depth: number;
  32323. /**
  32324. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32325. */
  32326. baseWidth: number;
  32327. /**
  32328. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32329. */
  32330. baseHeight: number;
  32331. /**
  32332. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32333. */
  32334. baseDepth: number;
  32335. /**
  32336. * Gets a boolean indicating if the texture is inverted on Y axis
  32337. */
  32338. invertY: boolean;
  32339. /** @hidden */
  32340. _invertVScale: boolean;
  32341. /** @hidden */
  32342. _associatedChannel: number;
  32343. /** @hidden */
  32344. _source: InternalTextureSource;
  32345. /** @hidden */
  32346. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32347. /** @hidden */
  32348. _bufferView: Nullable<ArrayBufferView>;
  32349. /** @hidden */
  32350. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32351. /** @hidden */
  32352. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32353. /** @hidden */
  32354. _size: number;
  32355. /** @hidden */
  32356. _extension: string;
  32357. /** @hidden */
  32358. _files: Nullable<string[]>;
  32359. /** @hidden */
  32360. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32361. /** @hidden */
  32362. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32363. /** @hidden */
  32364. _framebuffer: Nullable<WebGLFramebuffer>;
  32365. /** @hidden */
  32366. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32367. /** @hidden */
  32368. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32369. /** @hidden */
  32370. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32371. /** @hidden */
  32372. _attachments: Nullable<number[]>;
  32373. /** @hidden */
  32374. _cachedCoordinatesMode: Nullable<number>;
  32375. /** @hidden */
  32376. _cachedWrapU: Nullable<number>;
  32377. /** @hidden */
  32378. _cachedWrapV: Nullable<number>;
  32379. /** @hidden */
  32380. _cachedWrapR: Nullable<number>;
  32381. /** @hidden */
  32382. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32383. /** @hidden */
  32384. _isDisabled: boolean;
  32385. /** @hidden */
  32386. _compression: Nullable<string>;
  32387. /** @hidden */
  32388. _generateStencilBuffer: boolean;
  32389. /** @hidden */
  32390. _generateDepthBuffer: boolean;
  32391. /** @hidden */
  32392. _comparisonFunction: number;
  32393. /** @hidden */
  32394. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32395. /** @hidden */
  32396. _lodGenerationScale: number;
  32397. /** @hidden */
  32398. _lodGenerationOffset: number;
  32399. /** @hidden */
  32400. _depthStencilTexture: Nullable<InternalTexture>;
  32401. /** @hidden */
  32402. _colorTextureArray: Nullable<WebGLTexture>;
  32403. /** @hidden */
  32404. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32405. /** @hidden */
  32406. _lodTextureHigh: Nullable<BaseTexture>;
  32407. /** @hidden */
  32408. _lodTextureMid: Nullable<BaseTexture>;
  32409. /** @hidden */
  32410. _lodTextureLow: Nullable<BaseTexture>;
  32411. /** @hidden */
  32412. _isRGBD: boolean;
  32413. /** @hidden */
  32414. _linearSpecularLOD: boolean;
  32415. /** @hidden */
  32416. _irradianceTexture: Nullable<BaseTexture>;
  32417. /** @hidden */
  32418. _webGLTexture: Nullable<WebGLTexture>;
  32419. /** @hidden */
  32420. _references: number;
  32421. private _engine;
  32422. /**
  32423. * Gets the Engine the texture belongs to.
  32424. * @returns The babylon engine
  32425. */
  32426. getEngine(): ThinEngine;
  32427. /**
  32428. * Gets the data source type of the texture
  32429. */
  32430. get source(): InternalTextureSource;
  32431. /**
  32432. * Creates a new InternalTexture
  32433. * @param engine defines the engine to use
  32434. * @param source defines the type of data that will be used
  32435. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32436. */
  32437. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32438. /**
  32439. * Increments the number of references (ie. the number of Texture that point to it)
  32440. */
  32441. incrementReferences(): void;
  32442. /**
  32443. * Change the size of the texture (not the size of the content)
  32444. * @param width defines the new width
  32445. * @param height defines the new height
  32446. * @param depth defines the new depth (1 by default)
  32447. */
  32448. updateSize(width: int, height: int, depth?: int): void;
  32449. /** @hidden */
  32450. _rebuild(): void;
  32451. /** @hidden */
  32452. _swapAndDie(target: InternalTexture): void;
  32453. /**
  32454. * Dispose the current allocated resources
  32455. */
  32456. dispose(): void;
  32457. }
  32458. }
  32459. declare module BABYLON {
  32460. /**
  32461. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32463. */
  32464. export class Analyser {
  32465. /**
  32466. * Gets or sets the smoothing
  32467. * @ignorenaming
  32468. */
  32469. SMOOTHING: number;
  32470. /**
  32471. * Gets or sets the FFT table size
  32472. * @ignorenaming
  32473. */
  32474. FFT_SIZE: number;
  32475. /**
  32476. * Gets or sets the bar graph amplitude
  32477. * @ignorenaming
  32478. */
  32479. BARGRAPHAMPLITUDE: number;
  32480. /**
  32481. * Gets or sets the position of the debug canvas
  32482. * @ignorenaming
  32483. */
  32484. DEBUGCANVASPOS: {
  32485. x: number;
  32486. y: number;
  32487. };
  32488. /**
  32489. * Gets or sets the debug canvas size
  32490. * @ignorenaming
  32491. */
  32492. DEBUGCANVASSIZE: {
  32493. width: number;
  32494. height: number;
  32495. };
  32496. private _byteFreqs;
  32497. private _byteTime;
  32498. private _floatFreqs;
  32499. private _webAudioAnalyser;
  32500. private _debugCanvas;
  32501. private _debugCanvasContext;
  32502. private _scene;
  32503. private _registerFunc;
  32504. private _audioEngine;
  32505. /**
  32506. * Creates a new analyser
  32507. * @param scene defines hosting scene
  32508. */
  32509. constructor(scene: Scene);
  32510. /**
  32511. * Get the number of data values you will have to play with for the visualization
  32512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32513. * @returns a number
  32514. */
  32515. getFrequencyBinCount(): number;
  32516. /**
  32517. * Gets the current frequency data as a byte array
  32518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32519. * @returns a Uint8Array
  32520. */
  32521. getByteFrequencyData(): Uint8Array;
  32522. /**
  32523. * Gets the current waveform as a byte array
  32524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32525. * @returns a Uint8Array
  32526. */
  32527. getByteTimeDomainData(): Uint8Array;
  32528. /**
  32529. * Gets the current frequency data as a float array
  32530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32531. * @returns a Float32Array
  32532. */
  32533. getFloatFrequencyData(): Float32Array;
  32534. /**
  32535. * Renders the debug canvas
  32536. */
  32537. drawDebugCanvas(): void;
  32538. /**
  32539. * Stops rendering the debug canvas and removes it
  32540. */
  32541. stopDebugCanvas(): void;
  32542. /**
  32543. * Connects two audio nodes
  32544. * @param inputAudioNode defines first node to connect
  32545. * @param outputAudioNode defines second node to connect
  32546. */
  32547. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32548. /**
  32549. * Releases all associated resources
  32550. */
  32551. dispose(): void;
  32552. }
  32553. }
  32554. declare module BABYLON {
  32555. /**
  32556. * This represents an audio engine and it is responsible
  32557. * to play, synchronize and analyse sounds throughout the application.
  32558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32559. */
  32560. export interface IAudioEngine extends IDisposable {
  32561. /**
  32562. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32563. */
  32564. readonly canUseWebAudio: boolean;
  32565. /**
  32566. * Gets the current AudioContext if available.
  32567. */
  32568. readonly audioContext: Nullable<AudioContext>;
  32569. /**
  32570. * The master gain node defines the global audio volume of your audio engine.
  32571. */
  32572. readonly masterGain: GainNode;
  32573. /**
  32574. * Gets whether or not mp3 are supported by your browser.
  32575. */
  32576. readonly isMP3supported: boolean;
  32577. /**
  32578. * Gets whether or not ogg are supported by your browser.
  32579. */
  32580. readonly isOGGsupported: boolean;
  32581. /**
  32582. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32583. * @ignoreNaming
  32584. */
  32585. WarnedWebAudioUnsupported: boolean;
  32586. /**
  32587. * Defines if the audio engine relies on a custom unlocked button.
  32588. * In this case, the embedded button will not be displayed.
  32589. */
  32590. useCustomUnlockedButton: boolean;
  32591. /**
  32592. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32593. */
  32594. readonly unlocked: boolean;
  32595. /**
  32596. * Event raised when audio has been unlocked on the browser.
  32597. */
  32598. onAudioUnlockedObservable: Observable<AudioEngine>;
  32599. /**
  32600. * Event raised when audio has been locked on the browser.
  32601. */
  32602. onAudioLockedObservable: Observable<AudioEngine>;
  32603. /**
  32604. * Flags the audio engine in Locked state.
  32605. * This happens due to new browser policies preventing audio to autoplay.
  32606. */
  32607. lock(): void;
  32608. /**
  32609. * Unlocks the audio engine once a user action has been done on the dom.
  32610. * This is helpful to resume play once browser policies have been satisfied.
  32611. */
  32612. unlock(): void;
  32613. }
  32614. /**
  32615. * This represents the default audio engine used in babylon.
  32616. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32618. */
  32619. export class AudioEngine implements IAudioEngine {
  32620. private _audioContext;
  32621. private _audioContextInitialized;
  32622. private _muteButton;
  32623. private _hostElement;
  32624. /**
  32625. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32626. */
  32627. canUseWebAudio: boolean;
  32628. /**
  32629. * The master gain node defines the global audio volume of your audio engine.
  32630. */
  32631. masterGain: GainNode;
  32632. /**
  32633. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32634. * @ignoreNaming
  32635. */
  32636. WarnedWebAudioUnsupported: boolean;
  32637. /**
  32638. * Gets whether or not mp3 are supported by your browser.
  32639. */
  32640. isMP3supported: boolean;
  32641. /**
  32642. * Gets whether or not ogg are supported by your browser.
  32643. */
  32644. isOGGsupported: boolean;
  32645. /**
  32646. * Gets whether audio has been unlocked on the device.
  32647. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32648. * a user interaction has happened.
  32649. */
  32650. unlocked: boolean;
  32651. /**
  32652. * Defines if the audio engine relies on a custom unlocked button.
  32653. * In this case, the embedded button will not be displayed.
  32654. */
  32655. useCustomUnlockedButton: boolean;
  32656. /**
  32657. * Event raised when audio has been unlocked on the browser.
  32658. */
  32659. onAudioUnlockedObservable: Observable<AudioEngine>;
  32660. /**
  32661. * Event raised when audio has been locked on the browser.
  32662. */
  32663. onAudioLockedObservable: Observable<AudioEngine>;
  32664. /**
  32665. * Gets the current AudioContext if available.
  32666. */
  32667. get audioContext(): Nullable<AudioContext>;
  32668. private _connectedAnalyser;
  32669. /**
  32670. * Instantiates a new audio engine.
  32671. *
  32672. * There should be only one per page as some browsers restrict the number
  32673. * of audio contexts you can create.
  32674. * @param hostElement defines the host element where to display the mute icon if necessary
  32675. */
  32676. constructor(hostElement?: Nullable<HTMLElement>);
  32677. /**
  32678. * Flags the audio engine in Locked state.
  32679. * This happens due to new browser policies preventing audio to autoplay.
  32680. */
  32681. lock(): void;
  32682. /**
  32683. * Unlocks the audio engine once a user action has been done on the dom.
  32684. * This is helpful to resume play once browser policies have been satisfied.
  32685. */
  32686. unlock(): void;
  32687. private _resumeAudioContext;
  32688. private _initializeAudioContext;
  32689. private _tryToRun;
  32690. private _triggerRunningState;
  32691. private _triggerSuspendedState;
  32692. private _displayMuteButton;
  32693. private _moveButtonToTopLeft;
  32694. private _onResize;
  32695. private _hideMuteButton;
  32696. /**
  32697. * Destroy and release the resources associated with the audio ccontext.
  32698. */
  32699. dispose(): void;
  32700. /**
  32701. * Gets the global volume sets on the master gain.
  32702. * @returns the global volume if set or -1 otherwise
  32703. */
  32704. getGlobalVolume(): number;
  32705. /**
  32706. * Sets the global volume of your experience (sets on the master gain).
  32707. * @param newVolume Defines the new global volume of the application
  32708. */
  32709. setGlobalVolume(newVolume: number): void;
  32710. /**
  32711. * Connect the audio engine to an audio analyser allowing some amazing
  32712. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32714. * @param analyser The analyser to connect to the engine
  32715. */
  32716. connectToAnalyser(analyser: Analyser): void;
  32717. }
  32718. }
  32719. declare module BABYLON {
  32720. /**
  32721. * Interface used to present a loading screen while loading a scene
  32722. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32723. */
  32724. export interface ILoadingScreen {
  32725. /**
  32726. * Function called to display the loading screen
  32727. */
  32728. displayLoadingUI: () => void;
  32729. /**
  32730. * Function called to hide the loading screen
  32731. */
  32732. hideLoadingUI: () => void;
  32733. /**
  32734. * Gets or sets the color to use for the background
  32735. */
  32736. loadingUIBackgroundColor: string;
  32737. /**
  32738. * Gets or sets the text to display while loading
  32739. */
  32740. loadingUIText: string;
  32741. }
  32742. /**
  32743. * Class used for the default loading screen
  32744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32745. */
  32746. export class DefaultLoadingScreen implements ILoadingScreen {
  32747. private _renderingCanvas;
  32748. private _loadingText;
  32749. private _loadingDivBackgroundColor;
  32750. private _loadingDiv;
  32751. private _loadingTextDiv;
  32752. /** Gets or sets the logo url to use for the default loading screen */
  32753. static DefaultLogoUrl: string;
  32754. /** Gets or sets the spinner url to use for the default loading screen */
  32755. static DefaultSpinnerUrl: string;
  32756. /**
  32757. * Creates a new default loading screen
  32758. * @param _renderingCanvas defines the canvas used to render the scene
  32759. * @param _loadingText defines the default text to display
  32760. * @param _loadingDivBackgroundColor defines the default background color
  32761. */
  32762. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32763. /**
  32764. * Function called to display the loading screen
  32765. */
  32766. displayLoadingUI(): void;
  32767. /**
  32768. * Function called to hide the loading screen
  32769. */
  32770. hideLoadingUI(): void;
  32771. /**
  32772. * Gets or sets the text to display while loading
  32773. */
  32774. set loadingUIText(text: string);
  32775. get loadingUIText(): string;
  32776. /**
  32777. * Gets or sets the color to use for the background
  32778. */
  32779. get loadingUIBackgroundColor(): string;
  32780. set loadingUIBackgroundColor(color: string);
  32781. private _resizeLoadingUI;
  32782. }
  32783. }
  32784. declare module BABYLON {
  32785. /**
  32786. * Interface for any object that can request an animation frame
  32787. */
  32788. export interface ICustomAnimationFrameRequester {
  32789. /**
  32790. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32791. */
  32792. renderFunction?: Function;
  32793. /**
  32794. * Called to request the next frame to render to
  32795. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32796. */
  32797. requestAnimationFrame: Function;
  32798. /**
  32799. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32800. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32801. */
  32802. requestID?: number;
  32803. }
  32804. }
  32805. declare module BABYLON {
  32806. /**
  32807. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32808. */
  32809. export class PerformanceMonitor {
  32810. private _enabled;
  32811. private _rollingFrameTime;
  32812. private _lastFrameTimeMs;
  32813. /**
  32814. * constructor
  32815. * @param frameSampleSize The number of samples required to saturate the sliding window
  32816. */
  32817. constructor(frameSampleSize?: number);
  32818. /**
  32819. * Samples current frame
  32820. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32821. */
  32822. sampleFrame(timeMs?: number): void;
  32823. /**
  32824. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32825. */
  32826. get averageFrameTime(): number;
  32827. /**
  32828. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32829. */
  32830. get averageFrameTimeVariance(): number;
  32831. /**
  32832. * Returns the frame time of the most recent frame
  32833. */
  32834. get instantaneousFrameTime(): number;
  32835. /**
  32836. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32837. */
  32838. get averageFPS(): number;
  32839. /**
  32840. * Returns the average framerate in frames per second using the most recent frame time
  32841. */
  32842. get instantaneousFPS(): number;
  32843. /**
  32844. * Returns true if enough samples have been taken to completely fill the sliding window
  32845. */
  32846. get isSaturated(): boolean;
  32847. /**
  32848. * Enables contributions to the sliding window sample set
  32849. */
  32850. enable(): void;
  32851. /**
  32852. * Disables contributions to the sliding window sample set
  32853. * Samples will not be interpolated over the disabled period
  32854. */
  32855. disable(): void;
  32856. /**
  32857. * Returns true if sampling is enabled
  32858. */
  32859. get isEnabled(): boolean;
  32860. /**
  32861. * Resets performance monitor
  32862. */
  32863. reset(): void;
  32864. }
  32865. /**
  32866. * RollingAverage
  32867. *
  32868. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32869. */
  32870. export class RollingAverage {
  32871. /**
  32872. * Current average
  32873. */
  32874. average: number;
  32875. /**
  32876. * Current variance
  32877. */
  32878. variance: number;
  32879. protected _samples: Array<number>;
  32880. protected _sampleCount: number;
  32881. protected _pos: number;
  32882. protected _m2: number;
  32883. /**
  32884. * constructor
  32885. * @param length The number of samples required to saturate the sliding window
  32886. */
  32887. constructor(length: number);
  32888. /**
  32889. * Adds a sample to the sample set
  32890. * @param v The sample value
  32891. */
  32892. add(v: number): void;
  32893. /**
  32894. * Returns previously added values or null if outside of history or outside the sliding window domain
  32895. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32896. * @return Value previously recorded with add() or null if outside of range
  32897. */
  32898. history(i: number): number;
  32899. /**
  32900. * Returns true if enough samples have been taken to completely fill the sliding window
  32901. * @return true if sample-set saturated
  32902. */
  32903. isSaturated(): boolean;
  32904. /**
  32905. * Resets the rolling average (equivalent to 0 samples taken so far)
  32906. */
  32907. reset(): void;
  32908. /**
  32909. * Wraps a value around the sample range boundaries
  32910. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32911. * @return Wrapped position in sample range
  32912. */
  32913. protected _wrapPosition(i: number): number;
  32914. }
  32915. }
  32916. declare module BABYLON {
  32917. /**
  32918. * This class is used to track a performance counter which is number based.
  32919. * The user has access to many properties which give statistics of different nature.
  32920. *
  32921. * The implementer can track two kinds of Performance Counter: time and count.
  32922. * 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.
  32923. * 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.
  32924. */
  32925. export class PerfCounter {
  32926. /**
  32927. * Gets or sets a global boolean to turn on and off all the counters
  32928. */
  32929. static Enabled: boolean;
  32930. /**
  32931. * Returns the smallest value ever
  32932. */
  32933. get min(): number;
  32934. /**
  32935. * Returns the biggest value ever
  32936. */
  32937. get max(): number;
  32938. /**
  32939. * Returns the average value since the performance counter is running
  32940. */
  32941. get average(): number;
  32942. /**
  32943. * Returns the average value of the last second the counter was monitored
  32944. */
  32945. get lastSecAverage(): number;
  32946. /**
  32947. * Returns the current value
  32948. */
  32949. get current(): number;
  32950. /**
  32951. * Gets the accumulated total
  32952. */
  32953. get total(): number;
  32954. /**
  32955. * Gets the total value count
  32956. */
  32957. get count(): number;
  32958. /**
  32959. * Creates a new counter
  32960. */
  32961. constructor();
  32962. /**
  32963. * Call this method to start monitoring a new frame.
  32964. * 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.
  32965. */
  32966. fetchNewFrame(): void;
  32967. /**
  32968. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32969. * @param newCount the count value to add to the monitored count
  32970. * @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.
  32971. */
  32972. addCount(newCount: number, fetchResult: boolean): void;
  32973. /**
  32974. * Start monitoring this performance counter
  32975. */
  32976. beginMonitoring(): void;
  32977. /**
  32978. * Compute the time lapsed since the previous beginMonitoring() call.
  32979. * @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
  32980. */
  32981. endMonitoring(newFrame?: boolean): void;
  32982. private _fetchResult;
  32983. private _startMonitoringTime;
  32984. private _min;
  32985. private _max;
  32986. private _average;
  32987. private _current;
  32988. private _totalValueCount;
  32989. private _totalAccumulated;
  32990. private _lastSecAverage;
  32991. private _lastSecAccumulated;
  32992. private _lastSecTime;
  32993. private _lastSecValueCount;
  32994. }
  32995. }
  32996. declare module BABYLON {
  32997. interface ThinEngine {
  32998. /**
  32999. * Sets alpha constants used by some alpha blending modes
  33000. * @param r defines the red component
  33001. * @param g defines the green component
  33002. * @param b defines the blue component
  33003. * @param a defines the alpha component
  33004. */
  33005. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33006. /**
  33007. * Sets the current alpha mode
  33008. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33009. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33011. */
  33012. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33013. /**
  33014. * Gets the current alpha mode
  33015. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33016. * @returns the current alpha mode
  33017. */
  33018. getAlphaMode(): number;
  33019. /**
  33020. * Sets the current alpha equation
  33021. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33022. */
  33023. setAlphaEquation(equation: number): void;
  33024. /**
  33025. * Gets the current alpha equation.
  33026. * @returns the current alpha equation
  33027. */
  33028. getAlphaEquation(): number;
  33029. }
  33030. }
  33031. declare module BABYLON {
  33032. /**
  33033. * Defines the interface used by display changed events
  33034. */
  33035. export interface IDisplayChangedEventArgs {
  33036. /** Gets the vrDisplay object (if any) */
  33037. vrDisplay: Nullable<any>;
  33038. /** Gets a boolean indicating if webVR is supported */
  33039. vrSupported: boolean;
  33040. }
  33041. /**
  33042. * Defines the interface used by objects containing a viewport (like a camera)
  33043. */
  33044. interface IViewportOwnerLike {
  33045. /**
  33046. * Gets or sets the viewport
  33047. */
  33048. viewport: IViewportLike;
  33049. }
  33050. /**
  33051. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33052. */
  33053. export class Engine extends ThinEngine {
  33054. /** Defines that alpha blending is disabled */
  33055. static readonly ALPHA_DISABLE: number;
  33056. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33057. static readonly ALPHA_ADD: number;
  33058. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33059. static readonly ALPHA_COMBINE: number;
  33060. /** Defines that alpha blending to DEST - SRC * DEST */
  33061. static readonly ALPHA_SUBTRACT: number;
  33062. /** Defines that alpha blending to SRC * DEST */
  33063. static readonly ALPHA_MULTIPLY: number;
  33064. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33065. static readonly ALPHA_MAXIMIZED: number;
  33066. /** Defines that alpha blending to SRC + DEST */
  33067. static readonly ALPHA_ONEONE: number;
  33068. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33069. static readonly ALPHA_PREMULTIPLIED: number;
  33070. /**
  33071. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33072. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33073. */
  33074. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33075. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33076. static readonly ALPHA_INTERPOLATE: number;
  33077. /**
  33078. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33079. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33080. */
  33081. static readonly ALPHA_SCREENMODE: number;
  33082. /** Defines that the ressource is not delayed*/
  33083. static readonly DELAYLOADSTATE_NONE: number;
  33084. /** Defines that the ressource was successfully delay loaded */
  33085. static readonly DELAYLOADSTATE_LOADED: number;
  33086. /** Defines that the ressource is currently delay loading */
  33087. static readonly DELAYLOADSTATE_LOADING: number;
  33088. /** Defines that the ressource is delayed and has not started loading */
  33089. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33091. static readonly NEVER: number;
  33092. /** 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 */
  33093. static readonly ALWAYS: number;
  33094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33095. static readonly LESS: number;
  33096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33097. static readonly EQUAL: number;
  33098. /** 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 */
  33099. static readonly LEQUAL: number;
  33100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33101. static readonly GREATER: number;
  33102. /** 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 */
  33103. static readonly GEQUAL: number;
  33104. /** 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 */
  33105. static readonly NOTEQUAL: number;
  33106. /** Passed to stencilOperation to specify that stencil value must be kept */
  33107. static readonly KEEP: number;
  33108. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33109. static readonly REPLACE: number;
  33110. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33111. static readonly INCR: number;
  33112. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33113. static readonly DECR: number;
  33114. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33115. static readonly INVERT: number;
  33116. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33117. static readonly INCR_WRAP: number;
  33118. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33119. static readonly DECR_WRAP: number;
  33120. /** Texture is not repeating outside of 0..1 UVs */
  33121. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33122. /** Texture is repeating outside of 0..1 UVs */
  33123. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33124. /** Texture is repeating and mirrored */
  33125. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33126. /** ALPHA */
  33127. static readonly TEXTUREFORMAT_ALPHA: number;
  33128. /** LUMINANCE */
  33129. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33130. /** LUMINANCE_ALPHA */
  33131. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33132. /** RGB */
  33133. static readonly TEXTUREFORMAT_RGB: number;
  33134. /** RGBA */
  33135. static readonly TEXTUREFORMAT_RGBA: number;
  33136. /** RED */
  33137. static readonly TEXTUREFORMAT_RED: number;
  33138. /** RED (2nd reference) */
  33139. static readonly TEXTUREFORMAT_R: number;
  33140. /** RG */
  33141. static readonly TEXTUREFORMAT_RG: number;
  33142. /** RED_INTEGER */
  33143. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33144. /** RED_INTEGER (2nd reference) */
  33145. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33146. /** RG_INTEGER */
  33147. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33148. /** RGB_INTEGER */
  33149. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33150. /** RGBA_INTEGER */
  33151. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33152. /** UNSIGNED_BYTE */
  33153. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33154. /** UNSIGNED_BYTE (2nd reference) */
  33155. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33156. /** FLOAT */
  33157. static readonly TEXTURETYPE_FLOAT: number;
  33158. /** HALF_FLOAT */
  33159. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33160. /** BYTE */
  33161. static readonly TEXTURETYPE_BYTE: number;
  33162. /** SHORT */
  33163. static readonly TEXTURETYPE_SHORT: number;
  33164. /** UNSIGNED_SHORT */
  33165. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33166. /** INT */
  33167. static readonly TEXTURETYPE_INT: number;
  33168. /** UNSIGNED_INT */
  33169. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33170. /** UNSIGNED_SHORT_4_4_4_4 */
  33171. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33172. /** UNSIGNED_SHORT_5_5_5_1 */
  33173. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33174. /** UNSIGNED_SHORT_5_6_5 */
  33175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33176. /** UNSIGNED_INT_2_10_10_10_REV */
  33177. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33178. /** UNSIGNED_INT_24_8 */
  33179. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33180. /** UNSIGNED_INT_10F_11F_11F_REV */
  33181. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33182. /** UNSIGNED_INT_5_9_9_9_REV */
  33183. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33184. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33185. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33186. /** nearest is mag = nearest and min = nearest and mip = linear */
  33187. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33189. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33190. /** Trilinear is mag = linear and min = linear and mip = linear */
  33191. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33192. /** nearest is mag = nearest and min = nearest and mip = linear */
  33193. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33194. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33195. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33196. /** Trilinear is mag = linear and min = linear and mip = linear */
  33197. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33198. /** mag = nearest and min = nearest and mip = nearest */
  33199. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33200. /** mag = nearest and min = linear and mip = nearest */
  33201. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33202. /** mag = nearest and min = linear and mip = linear */
  33203. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33204. /** mag = nearest and min = linear and mip = none */
  33205. static readonly TEXTURE_NEAREST_LINEAR: number;
  33206. /** mag = nearest and min = nearest and mip = none */
  33207. static readonly TEXTURE_NEAREST_NEAREST: number;
  33208. /** mag = linear and min = nearest and mip = nearest */
  33209. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33210. /** mag = linear and min = nearest and mip = linear */
  33211. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33212. /** mag = linear and min = linear and mip = none */
  33213. static readonly TEXTURE_LINEAR_LINEAR: number;
  33214. /** mag = linear and min = nearest and mip = none */
  33215. static readonly TEXTURE_LINEAR_NEAREST: number;
  33216. /** Explicit coordinates mode */
  33217. static readonly TEXTURE_EXPLICIT_MODE: number;
  33218. /** Spherical coordinates mode */
  33219. static readonly TEXTURE_SPHERICAL_MODE: number;
  33220. /** Planar coordinates mode */
  33221. static readonly TEXTURE_PLANAR_MODE: number;
  33222. /** Cubic coordinates mode */
  33223. static readonly TEXTURE_CUBIC_MODE: number;
  33224. /** Projection coordinates mode */
  33225. static readonly TEXTURE_PROJECTION_MODE: number;
  33226. /** Skybox coordinates mode */
  33227. static readonly TEXTURE_SKYBOX_MODE: number;
  33228. /** Inverse Cubic coordinates mode */
  33229. static readonly TEXTURE_INVCUBIC_MODE: number;
  33230. /** Equirectangular coordinates mode */
  33231. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33232. /** Equirectangular Fixed coordinates mode */
  33233. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33234. /** Equirectangular Fixed Mirrored coordinates mode */
  33235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33236. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33237. static readonly SCALEMODE_FLOOR: number;
  33238. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33239. static readonly SCALEMODE_NEAREST: number;
  33240. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33241. static readonly SCALEMODE_CEILING: number;
  33242. /**
  33243. * Returns the current npm package of the sdk
  33244. */
  33245. static get NpmPackage(): string;
  33246. /**
  33247. * Returns the current version of the framework
  33248. */
  33249. static get Version(): string;
  33250. /** Gets the list of created engines */
  33251. static get Instances(): Engine[];
  33252. /**
  33253. * Gets the latest created engine
  33254. */
  33255. static get LastCreatedEngine(): Nullable<Engine>;
  33256. /**
  33257. * Gets the latest created scene
  33258. */
  33259. static get LastCreatedScene(): Nullable<Scene>;
  33260. /**
  33261. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33262. * @param flag defines which part of the materials must be marked as dirty
  33263. * @param predicate defines a predicate used to filter which materials should be affected
  33264. */
  33265. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33266. /**
  33267. * Method called to create the default loading screen.
  33268. * This can be overriden in your own app.
  33269. * @param canvas The rendering canvas element
  33270. * @returns The loading screen
  33271. */
  33272. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33273. /**
  33274. * Method called to create the default rescale post process on each engine.
  33275. */
  33276. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33277. /**
  33278. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33279. **/
  33280. enableOfflineSupport: boolean;
  33281. /**
  33282. * 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)
  33283. **/
  33284. disableManifestCheck: boolean;
  33285. /**
  33286. * Gets the list of created scenes
  33287. */
  33288. scenes: Scene[];
  33289. /**
  33290. * Event raised when a new scene is created
  33291. */
  33292. onNewSceneAddedObservable: Observable<Scene>;
  33293. /**
  33294. * Gets the list of created postprocesses
  33295. */
  33296. postProcesses: PostProcess[];
  33297. /**
  33298. * Gets a boolean indicating if the pointer is currently locked
  33299. */
  33300. isPointerLock: boolean;
  33301. /**
  33302. * Observable event triggered each time the rendering canvas is resized
  33303. */
  33304. onResizeObservable: Observable<Engine>;
  33305. /**
  33306. * Observable event triggered each time the canvas loses focus
  33307. */
  33308. onCanvasBlurObservable: Observable<Engine>;
  33309. /**
  33310. * Observable event triggered each time the canvas gains focus
  33311. */
  33312. onCanvasFocusObservable: Observable<Engine>;
  33313. /**
  33314. * Observable event triggered each time the canvas receives pointerout event
  33315. */
  33316. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33317. /**
  33318. * Observable raised when the engine begins a new frame
  33319. */
  33320. onBeginFrameObservable: Observable<Engine>;
  33321. /**
  33322. * If set, will be used to request the next animation frame for the render loop
  33323. */
  33324. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33325. /**
  33326. * Observable raised when the engine ends the current frame
  33327. */
  33328. onEndFrameObservable: Observable<Engine>;
  33329. /**
  33330. * Observable raised when the engine is about to compile a shader
  33331. */
  33332. onBeforeShaderCompilationObservable: Observable<Engine>;
  33333. /**
  33334. * Observable raised when the engine has jsut compiled a shader
  33335. */
  33336. onAfterShaderCompilationObservable: Observable<Engine>;
  33337. /**
  33338. * Gets the audio engine
  33339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33340. * @ignorenaming
  33341. */
  33342. static audioEngine: IAudioEngine;
  33343. /**
  33344. * Default AudioEngine factory responsible of creating the Audio Engine.
  33345. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33346. */
  33347. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33348. /**
  33349. * Default offline support factory responsible of creating a tool used to store data locally.
  33350. * By default, this will create a Database object if the workload has been embedded.
  33351. */
  33352. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33353. private _loadingScreen;
  33354. private _pointerLockRequested;
  33355. private _dummyFramebuffer;
  33356. private _rescalePostProcess;
  33357. private _deterministicLockstep;
  33358. private _lockstepMaxSteps;
  33359. private _timeStep;
  33360. protected get _supportsHardwareTextureRescaling(): boolean;
  33361. private _fps;
  33362. private _deltaTime;
  33363. /** @hidden */
  33364. _drawCalls: PerfCounter;
  33365. /** 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 */
  33366. canvasTabIndex: number;
  33367. /**
  33368. * Turn this value on if you want to pause FPS computation when in background
  33369. */
  33370. disablePerformanceMonitorInBackground: boolean;
  33371. private _performanceMonitor;
  33372. /**
  33373. * Gets the performance monitor attached to this engine
  33374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33375. */
  33376. get performanceMonitor(): PerformanceMonitor;
  33377. private _onFocus;
  33378. private _onBlur;
  33379. private _onCanvasPointerOut;
  33380. private _onCanvasBlur;
  33381. private _onCanvasFocus;
  33382. private _onFullscreenChange;
  33383. private _onPointerLockChange;
  33384. /**
  33385. * Gets the HTML element used to attach event listeners
  33386. * @returns a HTML element
  33387. */
  33388. getInputElement(): Nullable<HTMLElement>;
  33389. /**
  33390. * Creates a new engine
  33391. * @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
  33392. * @param antialias defines enable antialiasing (default: false)
  33393. * @param options defines further options to be sent to the getContext() function
  33394. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33395. */
  33396. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33397. /**
  33398. * Gets current aspect ratio
  33399. * @param viewportOwner defines the camera to use to get the aspect ratio
  33400. * @param useScreen defines if screen size must be used (or the current render target if any)
  33401. * @returns a number defining the aspect ratio
  33402. */
  33403. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33404. /**
  33405. * Gets current screen aspect ratio
  33406. * @returns a number defining the aspect ratio
  33407. */
  33408. getScreenAspectRatio(): number;
  33409. /**
  33410. * Gets the client rect of the HTML canvas attached with the current webGL context
  33411. * @returns a client rectanglee
  33412. */
  33413. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33414. /**
  33415. * Gets the client rect of the HTML element used for events
  33416. * @returns a client rectanglee
  33417. */
  33418. getInputElementClientRect(): Nullable<ClientRect>;
  33419. /**
  33420. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33422. * @returns true if engine is in deterministic lock step mode
  33423. */
  33424. isDeterministicLockStep(): boolean;
  33425. /**
  33426. * Gets the max steps when engine is running in deterministic lock step
  33427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33428. * @returns the max steps
  33429. */
  33430. getLockstepMaxSteps(): number;
  33431. /**
  33432. * Returns the time in ms between steps when using deterministic lock step.
  33433. * @returns time step in (ms)
  33434. */
  33435. getTimeStep(): number;
  33436. /**
  33437. * Force the mipmap generation for the given render target texture
  33438. * @param texture defines the render target texture to use
  33439. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33440. */
  33441. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33442. /** States */
  33443. /**
  33444. * Set various states to the webGL context
  33445. * @param culling defines backface culling state
  33446. * @param zOffset defines the value to apply to zOffset (0 by default)
  33447. * @param force defines if states must be applied even if cache is up to date
  33448. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33449. */
  33450. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33451. /**
  33452. * Set the z offset to apply to current rendering
  33453. * @param value defines the offset to apply
  33454. */
  33455. setZOffset(value: number): void;
  33456. /**
  33457. * Gets the current value of the zOffset
  33458. * @returns the current zOffset state
  33459. */
  33460. getZOffset(): number;
  33461. /**
  33462. * Enable or disable depth buffering
  33463. * @param enable defines the state to set
  33464. */
  33465. setDepthBuffer(enable: boolean): void;
  33466. /**
  33467. * Gets a boolean indicating if depth writing is enabled
  33468. * @returns the current depth writing state
  33469. */
  33470. getDepthWrite(): boolean;
  33471. /**
  33472. * Enable or disable depth writing
  33473. * @param enable defines the state to set
  33474. */
  33475. setDepthWrite(enable: boolean): void;
  33476. /**
  33477. * Gets a boolean indicating if stencil buffer is enabled
  33478. * @returns the current stencil buffer state
  33479. */
  33480. getStencilBuffer(): boolean;
  33481. /**
  33482. * Enable or disable the stencil buffer
  33483. * @param enable defines if the stencil buffer must be enabled or disabled
  33484. */
  33485. setStencilBuffer(enable: boolean): void;
  33486. /**
  33487. * Gets the current stencil mask
  33488. * @returns a number defining the new stencil mask to use
  33489. */
  33490. getStencilMask(): number;
  33491. /**
  33492. * Sets the current stencil mask
  33493. * @param mask defines the new stencil mask to use
  33494. */
  33495. setStencilMask(mask: number): void;
  33496. /**
  33497. * Gets the current stencil function
  33498. * @returns a number defining the stencil function to use
  33499. */
  33500. getStencilFunction(): number;
  33501. /**
  33502. * Gets the current stencil reference value
  33503. * @returns a number defining the stencil reference value to use
  33504. */
  33505. getStencilFunctionReference(): number;
  33506. /**
  33507. * Gets the current stencil mask
  33508. * @returns a number defining the stencil mask to use
  33509. */
  33510. getStencilFunctionMask(): number;
  33511. /**
  33512. * Sets the current stencil function
  33513. * @param stencilFunc defines the new stencil function to use
  33514. */
  33515. setStencilFunction(stencilFunc: number): void;
  33516. /**
  33517. * Sets the current stencil reference
  33518. * @param reference defines the new stencil reference to use
  33519. */
  33520. setStencilFunctionReference(reference: number): void;
  33521. /**
  33522. * Sets the current stencil mask
  33523. * @param mask defines the new stencil mask to use
  33524. */
  33525. setStencilFunctionMask(mask: number): void;
  33526. /**
  33527. * Gets the current stencil operation when stencil fails
  33528. * @returns a number defining stencil operation to use when stencil fails
  33529. */
  33530. getStencilOperationFail(): number;
  33531. /**
  33532. * Gets the current stencil operation when depth fails
  33533. * @returns a number defining stencil operation to use when depth fails
  33534. */
  33535. getStencilOperationDepthFail(): number;
  33536. /**
  33537. * Gets the current stencil operation when stencil passes
  33538. * @returns a number defining stencil operation to use when stencil passes
  33539. */
  33540. getStencilOperationPass(): number;
  33541. /**
  33542. * Sets the stencil operation to use when stencil fails
  33543. * @param operation defines the stencil operation to use when stencil fails
  33544. */
  33545. setStencilOperationFail(operation: number): void;
  33546. /**
  33547. * Sets the stencil operation to use when depth fails
  33548. * @param operation defines the stencil operation to use when depth fails
  33549. */
  33550. setStencilOperationDepthFail(operation: number): void;
  33551. /**
  33552. * Sets the stencil operation to use when stencil passes
  33553. * @param operation defines the stencil operation to use when stencil passes
  33554. */
  33555. setStencilOperationPass(operation: number): void;
  33556. /**
  33557. * Sets a boolean indicating if the dithering state is enabled or disabled
  33558. * @param value defines the dithering state
  33559. */
  33560. setDitheringState(value: boolean): void;
  33561. /**
  33562. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33563. * @param value defines the rasterizer state
  33564. */
  33565. setRasterizerState(value: boolean): void;
  33566. /**
  33567. * Gets the current depth function
  33568. * @returns a number defining the depth function
  33569. */
  33570. getDepthFunction(): Nullable<number>;
  33571. /**
  33572. * Sets the current depth function
  33573. * @param depthFunc defines the function to use
  33574. */
  33575. setDepthFunction(depthFunc: number): void;
  33576. /**
  33577. * Sets the current depth function to GREATER
  33578. */
  33579. setDepthFunctionToGreater(): void;
  33580. /**
  33581. * Sets the current depth function to GEQUAL
  33582. */
  33583. setDepthFunctionToGreaterOrEqual(): void;
  33584. /**
  33585. * Sets the current depth function to LESS
  33586. */
  33587. setDepthFunctionToLess(): void;
  33588. /**
  33589. * Sets the current depth function to LEQUAL
  33590. */
  33591. setDepthFunctionToLessOrEqual(): void;
  33592. private _cachedStencilBuffer;
  33593. private _cachedStencilFunction;
  33594. private _cachedStencilMask;
  33595. private _cachedStencilOperationPass;
  33596. private _cachedStencilOperationFail;
  33597. private _cachedStencilOperationDepthFail;
  33598. private _cachedStencilReference;
  33599. /**
  33600. * Caches the the state of the stencil buffer
  33601. */
  33602. cacheStencilState(): void;
  33603. /**
  33604. * Restores the state of the stencil buffer
  33605. */
  33606. restoreStencilState(): void;
  33607. /**
  33608. * Directly set the WebGL Viewport
  33609. * @param x defines the x coordinate of the viewport (in screen space)
  33610. * @param y defines the y coordinate of the viewport (in screen space)
  33611. * @param width defines the width of the viewport (in screen space)
  33612. * @param height defines the height of the viewport (in screen space)
  33613. * @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
  33614. */
  33615. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33616. /**
  33617. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33618. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33619. * @param y defines the y-coordinate of the corner of the clear rectangle
  33620. * @param width defines the width of the clear rectangle
  33621. * @param height defines the height of the clear rectangle
  33622. * @param clearColor defines the clear color
  33623. */
  33624. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33625. /**
  33626. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33627. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33628. * @param y defines the y-coordinate of the corner of the clear rectangle
  33629. * @param width defines the width of the clear rectangle
  33630. * @param height defines the height of the clear rectangle
  33631. */
  33632. enableScissor(x: number, y: number, width: number, height: number): void;
  33633. /**
  33634. * Disable previously set scissor test rectangle
  33635. */
  33636. disableScissor(): void;
  33637. protected _reportDrawCall(): void;
  33638. /**
  33639. * Initializes a webVR display and starts listening to display change events
  33640. * The onVRDisplayChangedObservable will be notified upon these changes
  33641. * @returns The onVRDisplayChangedObservable
  33642. */
  33643. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33644. /** @hidden */
  33645. _prepareVRComponent(): void;
  33646. /** @hidden */
  33647. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33648. /** @hidden */
  33649. _submitVRFrame(): void;
  33650. /**
  33651. * Call this function to leave webVR mode
  33652. * Will do nothing if webVR is not supported or if there is no webVR device
  33653. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33654. */
  33655. disableVR(): void;
  33656. /**
  33657. * Gets a boolean indicating that the system is in VR mode and is presenting
  33658. * @returns true if VR mode is engaged
  33659. */
  33660. isVRPresenting(): boolean;
  33661. /** @hidden */
  33662. _requestVRFrame(): void;
  33663. /** @hidden */
  33664. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33665. /**
  33666. * Gets the source code of the vertex shader associated with a specific webGL program
  33667. * @param program defines the program to use
  33668. * @returns a string containing the source code of the vertex shader associated with the program
  33669. */
  33670. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33671. /**
  33672. * Gets the source code of the fragment shader associated with a specific webGL program
  33673. * @param program defines the program to use
  33674. * @returns a string containing the source code of the fragment shader associated with the program
  33675. */
  33676. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33677. /**
  33678. * Sets a depth stencil texture from a render target to the according uniform.
  33679. * @param channel The texture channel
  33680. * @param uniform The uniform to set
  33681. * @param texture The render target texture containing the depth stencil texture to apply
  33682. */
  33683. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33684. /**
  33685. * Sets a texture to the webGL context from a postprocess
  33686. * @param channel defines the channel to use
  33687. * @param postProcess defines the source postprocess
  33688. */
  33689. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33690. /**
  33691. * Binds the output of the passed in post process to the texture channel specified
  33692. * @param channel The channel the texture should be bound to
  33693. * @param postProcess The post process which's output should be bound
  33694. */
  33695. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33696. /** @hidden */
  33697. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33698. protected _rebuildBuffers(): void;
  33699. /** @hidden */
  33700. _renderFrame(): void;
  33701. _renderLoop(): void;
  33702. /** @hidden */
  33703. _renderViews(): boolean;
  33704. /**
  33705. * Toggle full screen mode
  33706. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33707. */
  33708. switchFullscreen(requestPointerLock: boolean): void;
  33709. /**
  33710. * Enters full screen mode
  33711. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33712. */
  33713. enterFullscreen(requestPointerLock: boolean): void;
  33714. /**
  33715. * Exits full screen mode
  33716. */
  33717. exitFullscreen(): void;
  33718. /**
  33719. * Enters Pointerlock mode
  33720. */
  33721. enterPointerlock(): void;
  33722. /**
  33723. * Exits Pointerlock mode
  33724. */
  33725. exitPointerlock(): void;
  33726. /**
  33727. * Begin a new frame
  33728. */
  33729. beginFrame(): void;
  33730. /**
  33731. * Enf the current frame
  33732. */
  33733. endFrame(): void;
  33734. resize(): void;
  33735. /**
  33736. * Force a specific size of the canvas
  33737. * @param width defines the new canvas' width
  33738. * @param height defines the new canvas' height
  33739. */
  33740. setSize(width: number, height: number): void;
  33741. /**
  33742. * Updates a dynamic vertex buffer.
  33743. * @param vertexBuffer the vertex buffer to update
  33744. * @param data the data used to update the vertex buffer
  33745. * @param byteOffset the byte offset of the data
  33746. * @param byteLength the byte length of the data
  33747. */
  33748. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33749. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33750. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33751. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33752. _releaseTexture(texture: InternalTexture): void;
  33753. /**
  33754. * @hidden
  33755. * Rescales a texture
  33756. * @param source input texutre
  33757. * @param destination destination texture
  33758. * @param scene scene to use to render the resize
  33759. * @param internalFormat format to use when resizing
  33760. * @param onComplete callback to be called when resize has completed
  33761. */
  33762. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33763. /**
  33764. * Gets the current framerate
  33765. * @returns a number representing the framerate
  33766. */
  33767. getFps(): number;
  33768. /**
  33769. * Gets the time spent between current and previous frame
  33770. * @returns a number representing the delta time in ms
  33771. */
  33772. getDeltaTime(): number;
  33773. private _measureFps;
  33774. /** @hidden */
  33775. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33776. /**
  33777. * Update a dynamic index buffer
  33778. * @param indexBuffer defines the target index buffer
  33779. * @param indices defines the data to update
  33780. * @param offset defines the offset in the target index buffer where update should start
  33781. */
  33782. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33783. /**
  33784. * Updates the sample count of a render target texture
  33785. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33786. * @param texture defines the texture to update
  33787. * @param samples defines the sample count to set
  33788. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33789. */
  33790. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33791. /**
  33792. * Updates a depth texture Comparison Mode and Function.
  33793. * If the comparison Function is equal to 0, the mode will be set to none.
  33794. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33795. * @param texture The texture to set the comparison function for
  33796. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33797. */
  33798. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33799. /**
  33800. * Creates a webGL buffer to use with instanciation
  33801. * @param capacity defines the size of the buffer
  33802. * @returns the webGL buffer
  33803. */
  33804. createInstancesBuffer(capacity: number): DataBuffer;
  33805. /**
  33806. * Delete a webGL buffer used with instanciation
  33807. * @param buffer defines the webGL buffer to delete
  33808. */
  33809. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33810. private _clientWaitAsync;
  33811. /** @hidden */
  33812. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33813. /** @hidden */
  33814. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33815. dispose(): void;
  33816. private _disableTouchAction;
  33817. /**
  33818. * Display the loading screen
  33819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33820. */
  33821. displayLoadingUI(): void;
  33822. /**
  33823. * Hide the loading screen
  33824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33825. */
  33826. hideLoadingUI(): void;
  33827. /**
  33828. * Gets the current loading screen object
  33829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33830. */
  33831. get loadingScreen(): ILoadingScreen;
  33832. /**
  33833. * Sets the current loading screen object
  33834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33835. */
  33836. set loadingScreen(loadingScreen: ILoadingScreen);
  33837. /**
  33838. * Sets the current loading screen text
  33839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33840. */
  33841. set loadingUIText(text: string);
  33842. /**
  33843. * Sets the current loading screen background color
  33844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33845. */
  33846. set loadingUIBackgroundColor(color: string);
  33847. /** Pointerlock and fullscreen */
  33848. /**
  33849. * Ask the browser to promote the current element to pointerlock mode
  33850. * @param element defines the DOM element to promote
  33851. */
  33852. static _RequestPointerlock(element: HTMLElement): void;
  33853. /**
  33854. * Asks the browser to exit pointerlock mode
  33855. */
  33856. static _ExitPointerlock(): void;
  33857. /**
  33858. * Ask the browser to promote the current element to fullscreen rendering mode
  33859. * @param element defines the DOM element to promote
  33860. */
  33861. static _RequestFullscreen(element: HTMLElement): void;
  33862. /**
  33863. * Asks the browser to exit fullscreen mode
  33864. */
  33865. static _ExitFullscreen(): void;
  33866. }
  33867. }
  33868. declare module BABYLON {
  33869. /**
  33870. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33871. * during the life time of the application.
  33872. */
  33873. export class EngineStore {
  33874. /** Gets the list of created engines */
  33875. static Instances: Engine[];
  33876. /** @hidden */
  33877. static _LastCreatedScene: Nullable<Scene>;
  33878. /**
  33879. * Gets the latest created engine
  33880. */
  33881. static get LastCreatedEngine(): Nullable<Engine>;
  33882. /**
  33883. * Gets the latest created scene
  33884. */
  33885. static get LastCreatedScene(): Nullable<Scene>;
  33886. /**
  33887. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33888. * @ignorenaming
  33889. */
  33890. static UseFallbackTexture: boolean;
  33891. /**
  33892. * Texture content used if a texture cannot loaded
  33893. * @ignorenaming
  33894. */
  33895. static FallbackTexture: string;
  33896. }
  33897. }
  33898. declare module BABYLON {
  33899. /**
  33900. * Helper class that provides a small promise polyfill
  33901. */
  33902. export class PromisePolyfill {
  33903. /**
  33904. * Static function used to check if the polyfill is required
  33905. * If this is the case then the function will inject the polyfill to window.Promise
  33906. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33907. */
  33908. static Apply(force?: boolean): void;
  33909. }
  33910. }
  33911. declare module BABYLON {
  33912. /**
  33913. * Interface for screenshot methods with describe argument called `size` as object with options
  33914. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33915. */
  33916. export interface IScreenshotSize {
  33917. /**
  33918. * number in pixels for canvas height
  33919. */
  33920. height?: number;
  33921. /**
  33922. * multiplier allowing render at a higher or lower resolution
  33923. * If value is defined then height and width will be ignored and taken from camera
  33924. */
  33925. precision?: number;
  33926. /**
  33927. * number in pixels for canvas width
  33928. */
  33929. width?: number;
  33930. }
  33931. }
  33932. declare module BABYLON {
  33933. interface IColor4Like {
  33934. r: float;
  33935. g: float;
  33936. b: float;
  33937. a: float;
  33938. }
  33939. /**
  33940. * Class containing a set of static utilities functions
  33941. */
  33942. export class Tools {
  33943. /**
  33944. * Gets or sets the base URL to use to load assets
  33945. */
  33946. static get BaseUrl(): string;
  33947. static set BaseUrl(value: string);
  33948. /**
  33949. * Enable/Disable Custom HTTP Request Headers globally.
  33950. * default = false
  33951. * @see CustomRequestHeaders
  33952. */
  33953. static UseCustomRequestHeaders: boolean;
  33954. /**
  33955. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33956. * i.e. when loading files, where the server/service expects an Authorization header
  33957. */
  33958. static CustomRequestHeaders: {
  33959. [key: string]: string;
  33960. };
  33961. /**
  33962. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33963. */
  33964. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33965. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33966. /**
  33967. * Default behaviour for cors in the application.
  33968. * It can be a string if the expected behavior is identical in the entire app.
  33969. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33970. */
  33971. static CorsBehavior: string | ((url: string | string[]) => string);
  33972. /**
  33973. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33974. * @ignorenaming
  33975. */
  33976. static get UseFallbackTexture(): boolean;
  33977. static set UseFallbackTexture(value: boolean);
  33978. /**
  33979. * Use this object to register external classes like custom textures or material
  33980. * to allow the laoders to instantiate them
  33981. */
  33982. static get RegisteredExternalClasses(): {
  33983. [key: string]: Object;
  33984. };
  33985. static set RegisteredExternalClasses(classes: {
  33986. [key: string]: Object;
  33987. });
  33988. /**
  33989. * Texture content used if a texture cannot loaded
  33990. * @ignorenaming
  33991. */
  33992. static get fallbackTexture(): string;
  33993. static set fallbackTexture(value: string);
  33994. /**
  33995. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33996. * @param u defines the coordinate on X axis
  33997. * @param v defines the coordinate on Y axis
  33998. * @param width defines the width of the source data
  33999. * @param height defines the height of the source data
  34000. * @param pixels defines the source byte array
  34001. * @param color defines the output color
  34002. */
  34003. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34004. /**
  34005. * Interpolates between a and b via alpha
  34006. * @param a The lower value (returned when alpha = 0)
  34007. * @param b The upper value (returned when alpha = 1)
  34008. * @param alpha The interpolation-factor
  34009. * @return The mixed value
  34010. */
  34011. static Mix(a: number, b: number, alpha: number): number;
  34012. /**
  34013. * Tries to instantiate a new object from a given class name
  34014. * @param className defines the class name to instantiate
  34015. * @returns the new object or null if the system was not able to do the instantiation
  34016. */
  34017. static Instantiate(className: string): any;
  34018. /**
  34019. * Provides a slice function that will work even on IE
  34020. * @param data defines the array to slice
  34021. * @param start defines the start of the data (optional)
  34022. * @param end defines the end of the data (optional)
  34023. * @returns the new sliced array
  34024. */
  34025. static Slice<T>(data: T, start?: number, end?: number): T;
  34026. /**
  34027. * Polyfill for setImmediate
  34028. * @param action defines the action to execute after the current execution block
  34029. */
  34030. static SetImmediate(action: () => void): void;
  34031. /**
  34032. * Function indicating if a number is an exponent of 2
  34033. * @param value defines the value to test
  34034. * @returns true if the value is an exponent of 2
  34035. */
  34036. static IsExponentOfTwo(value: number): boolean;
  34037. private static _tmpFloatArray;
  34038. /**
  34039. * Returns the nearest 32-bit single precision float representation of a Number
  34040. * @param value A Number. If the parameter is of a different type, it will get converted
  34041. * to a number or to NaN if it cannot be converted
  34042. * @returns number
  34043. */
  34044. static FloatRound(value: number): number;
  34045. /**
  34046. * Extracts the filename from a path
  34047. * @param path defines the path to use
  34048. * @returns the filename
  34049. */
  34050. static GetFilename(path: string): string;
  34051. /**
  34052. * Extracts the "folder" part of a path (everything before the filename).
  34053. * @param uri The URI to extract the info from
  34054. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34055. * @returns The "folder" part of the path
  34056. */
  34057. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34058. /**
  34059. * Extracts text content from a DOM element hierarchy
  34060. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34061. */
  34062. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34063. /**
  34064. * Convert an angle in radians to degrees
  34065. * @param angle defines the angle to convert
  34066. * @returns the angle in degrees
  34067. */
  34068. static ToDegrees(angle: number): number;
  34069. /**
  34070. * Convert an angle in degrees to radians
  34071. * @param angle defines the angle to convert
  34072. * @returns the angle in radians
  34073. */
  34074. static ToRadians(angle: number): number;
  34075. /**
  34076. * Returns an array if obj is not an array
  34077. * @param obj defines the object to evaluate as an array
  34078. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34079. * @returns either obj directly if obj is an array or a new array containing obj
  34080. */
  34081. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34082. /**
  34083. * Gets the pointer prefix to use
  34084. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34085. */
  34086. static GetPointerPrefix(): string;
  34087. /**
  34088. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34089. * @param url define the url we are trying
  34090. * @param element define the dom element where to configure the cors policy
  34091. */
  34092. static SetCorsBehavior(url: string | string[], element: {
  34093. crossOrigin: string | null;
  34094. }): void;
  34095. /**
  34096. * Removes unwanted characters from an url
  34097. * @param url defines the url to clean
  34098. * @returns the cleaned url
  34099. */
  34100. static CleanUrl(url: string): string;
  34101. /**
  34102. * Gets or sets a function used to pre-process url before using them to load assets
  34103. */
  34104. static get PreprocessUrl(): (url: string) => string;
  34105. static set PreprocessUrl(processor: (url: string) => string);
  34106. /**
  34107. * Loads an image as an HTMLImageElement.
  34108. * @param input url string, ArrayBuffer, or Blob to load
  34109. * @param onLoad callback called when the image successfully loads
  34110. * @param onError callback called when the image fails to load
  34111. * @param offlineProvider offline provider for caching
  34112. * @param mimeType optional mime type
  34113. * @returns the HTMLImageElement of the loaded image
  34114. */
  34115. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34116. /**
  34117. * Loads a file from a url
  34118. * @param url url string, ArrayBuffer, or Blob to load
  34119. * @param onSuccess callback called when the file successfully loads
  34120. * @param onProgress callback called while file is loading (if the server supports this mode)
  34121. * @param offlineProvider defines the offline provider for caching
  34122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34123. * @param onError callback called when the file fails to load
  34124. * @returns a file request object
  34125. */
  34126. 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;
  34127. /**
  34128. * Loads a file from a url
  34129. * @param url the file url to load
  34130. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34131. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34132. */
  34133. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34134. /**
  34135. * Load a script (identified by an url). When the url returns, the
  34136. * content of this file is added into a new script element, attached to the DOM (body element)
  34137. * @param scriptUrl defines the url of the script to laod
  34138. * @param onSuccess defines the callback called when the script is loaded
  34139. * @param onError defines the callback to call if an error occurs
  34140. * @param scriptId defines the id of the script element
  34141. */
  34142. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34143. /**
  34144. * Load an asynchronous script (identified by an url). When the url returns, the
  34145. * content of this file is added into a new script element, attached to the DOM (body element)
  34146. * @param scriptUrl defines the url of the script to laod
  34147. * @param scriptId defines the id of the script element
  34148. * @returns a promise request object
  34149. */
  34150. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34151. /**
  34152. * Loads a file from a blob
  34153. * @param fileToLoad defines the blob to use
  34154. * @param callback defines the callback to call when data is loaded
  34155. * @param progressCallback defines the callback to call during loading process
  34156. * @returns a file request object
  34157. */
  34158. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34159. /**
  34160. * Reads a file from a File object
  34161. * @param file defines the file to load
  34162. * @param onSuccess defines the callback to call when data is loaded
  34163. * @param onProgress defines the callback to call during loading process
  34164. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34165. * @param onError defines the callback to call when an error occurs
  34166. * @returns a file request object
  34167. */
  34168. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34169. /**
  34170. * Creates a data url from a given string content
  34171. * @param content defines the content to convert
  34172. * @returns the new data url link
  34173. */
  34174. static FileAsURL(content: string): string;
  34175. /**
  34176. * Format the given number to a specific decimal format
  34177. * @param value defines the number to format
  34178. * @param decimals defines the number of decimals to use
  34179. * @returns the formatted string
  34180. */
  34181. static Format(value: number, decimals?: number): string;
  34182. /**
  34183. * Tries to copy an object by duplicating every property
  34184. * @param source defines the source object
  34185. * @param destination defines the target object
  34186. * @param doNotCopyList defines a list of properties to avoid
  34187. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34188. */
  34189. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34190. /**
  34191. * Gets a boolean indicating if the given object has no own property
  34192. * @param obj defines the object to test
  34193. * @returns true if object has no own property
  34194. */
  34195. static IsEmpty(obj: any): boolean;
  34196. /**
  34197. * Function used to register events at window level
  34198. * @param windowElement defines the Window object to use
  34199. * @param events defines the events to register
  34200. */
  34201. static RegisterTopRootEvents(windowElement: Window, events: {
  34202. name: string;
  34203. handler: Nullable<(e: FocusEvent) => any>;
  34204. }[]): void;
  34205. /**
  34206. * Function used to unregister events from window level
  34207. * @param windowElement defines the Window object to use
  34208. * @param events defines the events to unregister
  34209. */
  34210. static UnregisterTopRootEvents(windowElement: Window, events: {
  34211. name: string;
  34212. handler: Nullable<(e: FocusEvent) => any>;
  34213. }[]): void;
  34214. /**
  34215. * @ignore
  34216. */
  34217. static _ScreenshotCanvas: HTMLCanvasElement;
  34218. /**
  34219. * Dumps the current bound framebuffer
  34220. * @param width defines the rendering width
  34221. * @param height defines the rendering height
  34222. * @param engine defines the hosting engine
  34223. * @param successCallback defines the callback triggered once the data are available
  34224. * @param mimeType defines the mime type of the result
  34225. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34226. */
  34227. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34228. /**
  34229. * Converts the canvas data to blob.
  34230. * This acts as a polyfill for browsers not supporting the to blob function.
  34231. * @param canvas Defines the canvas to extract the data from
  34232. * @param successCallback Defines the callback triggered once the data are available
  34233. * @param mimeType Defines the mime type of the result
  34234. */
  34235. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34236. /**
  34237. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34238. * @param successCallback defines the callback triggered once the data are available
  34239. * @param mimeType defines the mime type of the result
  34240. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34241. */
  34242. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34243. /**
  34244. * Downloads a blob in the browser
  34245. * @param blob defines the blob to download
  34246. * @param fileName defines the name of the downloaded file
  34247. */
  34248. static Download(blob: Blob, fileName: string): void;
  34249. /**
  34250. * Captures a screenshot of the current rendering
  34251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34252. * @param engine defines the rendering engine
  34253. * @param camera defines the source camera
  34254. * @param size This parameter can be set to a single number or to an object with the
  34255. * following (optional) properties: precision, width, height. If a single number is passed,
  34256. * it will be used for both width and height. If an object is passed, the screenshot size
  34257. * will be derived from the parameters. The precision property is a multiplier allowing
  34258. * rendering at a higher or lower resolution
  34259. * @param successCallback defines the callback receives a single parameter which contains the
  34260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34261. * src parameter of an <img> to display it
  34262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34263. * Check your browser for supported MIME types
  34264. */
  34265. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34266. /**
  34267. * Captures a screenshot of the current rendering
  34268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34269. * @param engine defines the rendering engine
  34270. * @param camera defines the source camera
  34271. * @param size This parameter can be set to a single number or to an object with the
  34272. * following (optional) properties: precision, width, height. If a single number is passed,
  34273. * it will be used for both width and height. If an object is passed, the screenshot size
  34274. * will be derived from the parameters. The precision property is a multiplier allowing
  34275. * rendering at a higher or lower resolution
  34276. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34277. * Check your browser for supported MIME types
  34278. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34279. * to the src parameter of an <img> to display it
  34280. */
  34281. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34282. /**
  34283. * Generates an image screenshot from the specified camera.
  34284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34285. * @param engine The engine to use for rendering
  34286. * @param camera The camera to use for rendering
  34287. * @param size This parameter can be set to a single number or to an object with the
  34288. * following (optional) properties: precision, width, height. If a single number is passed,
  34289. * it will be used for both width and height. If an object is passed, the screenshot size
  34290. * will be derived from the parameters. The precision property is a multiplier allowing
  34291. * rendering at a higher or lower resolution
  34292. * @param successCallback The callback receives a single parameter which contains the
  34293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34294. * src parameter of an <img> to display it
  34295. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34296. * Check your browser for supported MIME types
  34297. * @param samples Texture samples (default: 1)
  34298. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34299. * @param fileName A name for for the downloaded file.
  34300. */
  34301. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34302. /**
  34303. * Generates an image screenshot from the specified camera.
  34304. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34305. * @param engine The engine to use for rendering
  34306. * @param camera The camera to use for rendering
  34307. * @param size This parameter can be set to a single number or to an object with the
  34308. * following (optional) properties: precision, width, height. If a single number is passed,
  34309. * it will be used for both width and height. If an object is passed, the screenshot size
  34310. * will be derived from the parameters. The precision property is a multiplier allowing
  34311. * rendering at a higher or lower resolution
  34312. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34313. * Check your browser for supported MIME types
  34314. * @param samples Texture samples (default: 1)
  34315. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34316. * @param fileName A name for for the downloaded file.
  34317. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34318. * to the src parameter of an <img> to display it
  34319. */
  34320. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34321. /**
  34322. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34323. * Be aware Math.random() could cause collisions, but:
  34324. * "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"
  34325. * @returns a pseudo random id
  34326. */
  34327. static RandomId(): string;
  34328. /**
  34329. * Test if the given uri is a base64 string
  34330. * @param uri The uri to test
  34331. * @return True if the uri is a base64 string or false otherwise
  34332. */
  34333. static IsBase64(uri: string): boolean;
  34334. /**
  34335. * Decode the given base64 uri.
  34336. * @param uri The uri to decode
  34337. * @return The decoded base64 data.
  34338. */
  34339. static DecodeBase64(uri: string): ArrayBuffer;
  34340. /**
  34341. * Gets the absolute url.
  34342. * @param url the input url
  34343. * @return the absolute url
  34344. */
  34345. static GetAbsoluteUrl(url: string): string;
  34346. /**
  34347. * No log
  34348. */
  34349. static readonly NoneLogLevel: number;
  34350. /**
  34351. * Only message logs
  34352. */
  34353. static readonly MessageLogLevel: number;
  34354. /**
  34355. * Only warning logs
  34356. */
  34357. static readonly WarningLogLevel: number;
  34358. /**
  34359. * Only error logs
  34360. */
  34361. static readonly ErrorLogLevel: number;
  34362. /**
  34363. * All logs
  34364. */
  34365. static readonly AllLogLevel: number;
  34366. /**
  34367. * Gets a value indicating the number of loading errors
  34368. * @ignorenaming
  34369. */
  34370. static get errorsCount(): number;
  34371. /**
  34372. * Callback called when a new log is added
  34373. */
  34374. static OnNewCacheEntry: (entry: string) => void;
  34375. /**
  34376. * Log a message to the console
  34377. * @param message defines the message to log
  34378. */
  34379. static Log(message: string): void;
  34380. /**
  34381. * Write a warning message to the console
  34382. * @param message defines the message to log
  34383. */
  34384. static Warn(message: string): void;
  34385. /**
  34386. * Write an error message to the console
  34387. * @param message defines the message to log
  34388. */
  34389. static Error(message: string): void;
  34390. /**
  34391. * Gets current log cache (list of logs)
  34392. */
  34393. static get LogCache(): string;
  34394. /**
  34395. * Clears the log cache
  34396. */
  34397. static ClearLogCache(): void;
  34398. /**
  34399. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34400. */
  34401. static set LogLevels(level: number);
  34402. /**
  34403. * Checks if the window object exists
  34404. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34405. */
  34406. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34407. /**
  34408. * No performance log
  34409. */
  34410. static readonly PerformanceNoneLogLevel: number;
  34411. /**
  34412. * Use user marks to log performance
  34413. */
  34414. static readonly PerformanceUserMarkLogLevel: number;
  34415. /**
  34416. * Log performance to the console
  34417. */
  34418. static readonly PerformanceConsoleLogLevel: number;
  34419. private static _performance;
  34420. /**
  34421. * Sets the current performance log level
  34422. */
  34423. static set PerformanceLogLevel(level: number);
  34424. private static _StartPerformanceCounterDisabled;
  34425. private static _EndPerformanceCounterDisabled;
  34426. private static _StartUserMark;
  34427. private static _EndUserMark;
  34428. private static _StartPerformanceConsole;
  34429. private static _EndPerformanceConsole;
  34430. /**
  34431. * Starts a performance counter
  34432. */
  34433. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34434. /**
  34435. * Ends a specific performance coutner
  34436. */
  34437. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34438. /**
  34439. * Gets either window.performance.now() if supported or Date.now() else
  34440. */
  34441. static get Now(): number;
  34442. /**
  34443. * This method will return the name of the class used to create the instance of the given object.
  34444. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34445. * @param object the object to get the class name from
  34446. * @param isType defines if the object is actually a type
  34447. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34448. */
  34449. static GetClassName(object: any, isType?: boolean): string;
  34450. /**
  34451. * Gets the first element of an array satisfying a given predicate
  34452. * @param array defines the array to browse
  34453. * @param predicate defines the predicate to use
  34454. * @returns null if not found or the element
  34455. */
  34456. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34457. /**
  34458. * This method will return the name of the full name of the class, including its owning module (if any).
  34459. * 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).
  34460. * @param object the object to get the class name from
  34461. * @param isType defines if the object is actually a type
  34462. * @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.
  34463. * @ignorenaming
  34464. */
  34465. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34466. /**
  34467. * Returns a promise that resolves after the given amount of time.
  34468. * @param delay Number of milliseconds to delay
  34469. * @returns Promise that resolves after the given amount of time
  34470. */
  34471. static DelayAsync(delay: number): Promise<void>;
  34472. /**
  34473. * Utility function to detect if the current user agent is Safari
  34474. * @returns whether or not the current user agent is safari
  34475. */
  34476. static IsSafari(): boolean;
  34477. }
  34478. /**
  34479. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34480. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34481. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34482. * @param name The name of the class, case should be preserved
  34483. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34484. */
  34485. export function className(name: string, module?: string): (target: Object) => void;
  34486. /**
  34487. * An implementation of a loop for asynchronous functions.
  34488. */
  34489. export class AsyncLoop {
  34490. /**
  34491. * Defines the number of iterations for the loop
  34492. */
  34493. iterations: number;
  34494. /**
  34495. * Defines the current index of the loop.
  34496. */
  34497. index: number;
  34498. private _done;
  34499. private _fn;
  34500. private _successCallback;
  34501. /**
  34502. * Constructor.
  34503. * @param iterations the number of iterations.
  34504. * @param func the function to run each iteration
  34505. * @param successCallback the callback that will be called upon succesful execution
  34506. * @param offset starting offset.
  34507. */
  34508. constructor(
  34509. /**
  34510. * Defines the number of iterations for the loop
  34511. */
  34512. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34513. /**
  34514. * Execute the next iteration. Must be called after the last iteration was finished.
  34515. */
  34516. executeNext(): void;
  34517. /**
  34518. * Break the loop and run the success callback.
  34519. */
  34520. breakLoop(): void;
  34521. /**
  34522. * Create and run an async loop.
  34523. * @param iterations the number of iterations.
  34524. * @param fn the function to run each iteration
  34525. * @param successCallback the callback that will be called upon succesful execution
  34526. * @param offset starting offset.
  34527. * @returns the created async loop object
  34528. */
  34529. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34530. /**
  34531. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34532. * @param iterations total number of iterations
  34533. * @param syncedIterations number of synchronous iterations in each async iteration.
  34534. * @param fn the function to call each iteration.
  34535. * @param callback a success call back that will be called when iterating stops.
  34536. * @param breakFunction a break condition (optional)
  34537. * @param timeout timeout settings for the setTimeout function. default - 0.
  34538. * @returns the created async loop object
  34539. */
  34540. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34541. }
  34542. }
  34543. declare module BABYLON {
  34544. /**
  34545. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34546. * The underlying implementation relies on an associative array to ensure the best performances.
  34547. * The value can be anything including 'null' but except 'undefined'
  34548. */
  34549. export class StringDictionary<T> {
  34550. /**
  34551. * This will clear this dictionary and copy the content from the 'source' one.
  34552. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34553. * @param source the dictionary to take the content from and copy to this dictionary
  34554. */
  34555. copyFrom(source: StringDictionary<T>): void;
  34556. /**
  34557. * Get a value based from its key
  34558. * @param key the given key to get the matching value from
  34559. * @return the value if found, otherwise undefined is returned
  34560. */
  34561. get(key: string): T | undefined;
  34562. /**
  34563. * Get a value from its key or add it if it doesn't exist.
  34564. * This method will ensure you that a given key/data will be present in the dictionary.
  34565. * @param key the given key to get the matching value from
  34566. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34567. * The factory will only be invoked if there's no data for the given key.
  34568. * @return the value corresponding to the key.
  34569. */
  34570. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34571. /**
  34572. * Get a value from its key if present in the dictionary otherwise add it
  34573. * @param key the key to get the value from
  34574. * @param val if there's no such key/value pair in the dictionary add it with this value
  34575. * @return the value corresponding to the key
  34576. */
  34577. getOrAdd(key: string, val: T): T;
  34578. /**
  34579. * Check if there's a given key in the dictionary
  34580. * @param key the key to check for
  34581. * @return true if the key is present, false otherwise
  34582. */
  34583. contains(key: string): boolean;
  34584. /**
  34585. * Add a new key and its corresponding value
  34586. * @param key the key to add
  34587. * @param value the value corresponding to the key
  34588. * @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
  34589. */
  34590. add(key: string, value: T): boolean;
  34591. /**
  34592. * Update a specific value associated to a key
  34593. * @param key defines the key to use
  34594. * @param value defines the value to store
  34595. * @returns true if the value was updated (or false if the key was not found)
  34596. */
  34597. set(key: string, value: T): boolean;
  34598. /**
  34599. * Get the element of the given key and remove it from the dictionary
  34600. * @param key defines the key to search
  34601. * @returns the value associated with the key or null if not found
  34602. */
  34603. getAndRemove(key: string): Nullable<T>;
  34604. /**
  34605. * Remove a key/value from the dictionary.
  34606. * @param key the key to remove
  34607. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34608. */
  34609. remove(key: string): boolean;
  34610. /**
  34611. * Clear the whole content of the dictionary
  34612. */
  34613. clear(): void;
  34614. /**
  34615. * Gets the current count
  34616. */
  34617. get count(): number;
  34618. /**
  34619. * Execute a callback on each key/val of the dictionary.
  34620. * Note that you can remove any element in this dictionary in the callback implementation
  34621. * @param callback the callback to execute on a given key/value pair
  34622. */
  34623. forEach(callback: (key: string, val: T) => void): void;
  34624. /**
  34625. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34626. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34627. * Note that you can remove any element in this dictionary in the callback implementation
  34628. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34629. * @returns the first item
  34630. */
  34631. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34632. private _count;
  34633. private _data;
  34634. }
  34635. }
  34636. declare module BABYLON {
  34637. /** @hidden */
  34638. export interface ICollisionCoordinator {
  34639. createCollider(): Collider;
  34640. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34641. init(scene: Scene): void;
  34642. }
  34643. /** @hidden */
  34644. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34645. private _scene;
  34646. private _scaledPosition;
  34647. private _scaledVelocity;
  34648. private _finalPosition;
  34649. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34650. createCollider(): Collider;
  34651. init(scene: Scene): void;
  34652. private _collideWithWorld;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /**
  34657. * Class used to manage all inputs for the scene.
  34658. */
  34659. export class InputManager {
  34660. /** The distance in pixel that you have to move to prevent some events */
  34661. static DragMovementThreshold: number;
  34662. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34663. static LongPressDelay: number;
  34664. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34665. static DoubleClickDelay: number;
  34666. /** If you need to check double click without raising a single click at first click, enable this flag */
  34667. static ExclusiveDoubleClickMode: boolean;
  34668. private _wheelEventName;
  34669. private _onPointerMove;
  34670. private _onPointerDown;
  34671. private _onPointerUp;
  34672. private _initClickEvent;
  34673. private _initActionManager;
  34674. private _delayedSimpleClick;
  34675. private _delayedSimpleClickTimeout;
  34676. private _previousDelayedSimpleClickTimeout;
  34677. private _meshPickProceed;
  34678. private _previousButtonPressed;
  34679. private _currentPickResult;
  34680. private _previousPickResult;
  34681. private _totalPointersPressed;
  34682. private _doubleClickOccured;
  34683. private _pointerOverMesh;
  34684. private _pickedDownMesh;
  34685. private _pickedUpMesh;
  34686. private _pointerX;
  34687. private _pointerY;
  34688. private _unTranslatedPointerX;
  34689. private _unTranslatedPointerY;
  34690. private _startingPointerPosition;
  34691. private _previousStartingPointerPosition;
  34692. private _startingPointerTime;
  34693. private _previousStartingPointerTime;
  34694. private _pointerCaptures;
  34695. private _onKeyDown;
  34696. private _onKeyUp;
  34697. private _onCanvasFocusObserver;
  34698. private _onCanvasBlurObserver;
  34699. private _scene;
  34700. /**
  34701. * Creates a new InputManager
  34702. * @param scene defines the hosting scene
  34703. */
  34704. constructor(scene: Scene);
  34705. /**
  34706. * Gets the mesh that is currently under the pointer
  34707. */
  34708. get meshUnderPointer(): Nullable<AbstractMesh>;
  34709. /**
  34710. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34711. */
  34712. get unTranslatedPointer(): Vector2;
  34713. /**
  34714. * Gets or sets the current on-screen X position of the pointer
  34715. */
  34716. get pointerX(): number;
  34717. set pointerX(value: number);
  34718. /**
  34719. * Gets or sets the current on-screen Y position of the pointer
  34720. */
  34721. get pointerY(): number;
  34722. set pointerY(value: number);
  34723. private _updatePointerPosition;
  34724. private _processPointerMove;
  34725. private _setRayOnPointerInfo;
  34726. private _checkPrePointerObservable;
  34727. /**
  34728. * Use this method to simulate a pointer move on a mesh
  34729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34732. */
  34733. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34734. /**
  34735. * Use this method to simulate a pointer down on a mesh
  34736. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34737. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34738. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34739. */
  34740. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34741. private _processPointerDown;
  34742. /** @hidden */
  34743. _isPointerSwiping(): boolean;
  34744. /**
  34745. * Use this method to simulate a pointer up on a mesh
  34746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34749. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34750. */
  34751. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34752. private _processPointerUp;
  34753. /**
  34754. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34755. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34756. * @returns true if the pointer was captured
  34757. */
  34758. isPointerCaptured(pointerId?: number): boolean;
  34759. /**
  34760. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34761. * @param attachUp defines if you want to attach events to pointerup
  34762. * @param attachDown defines if you want to attach events to pointerdown
  34763. * @param attachMove defines if you want to attach events to pointermove
  34764. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34765. */
  34766. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34767. /**
  34768. * Detaches all event handlers
  34769. */
  34770. detachControl(): void;
  34771. /**
  34772. * Force the value of meshUnderPointer
  34773. * @param mesh defines the mesh to use
  34774. */
  34775. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34776. /**
  34777. * Gets the mesh under the pointer
  34778. * @returns a Mesh or null if no mesh is under the pointer
  34779. */
  34780. getPointerOverMesh(): Nullable<AbstractMesh>;
  34781. }
  34782. }
  34783. declare module BABYLON {
  34784. /**
  34785. * Helper class used to generate session unique ID
  34786. */
  34787. export class UniqueIdGenerator {
  34788. private static _UniqueIdCounter;
  34789. /**
  34790. * Gets an unique (relatively to the current scene) Id
  34791. */
  34792. static get UniqueId(): number;
  34793. }
  34794. }
  34795. declare module BABYLON {
  34796. /**
  34797. * This class defines the direct association between an animation and a target
  34798. */
  34799. export class TargetedAnimation {
  34800. /**
  34801. * Animation to perform
  34802. */
  34803. animation: Animation;
  34804. /**
  34805. * Target to animate
  34806. */
  34807. target: any;
  34808. /**
  34809. * Serialize the object
  34810. * @returns the JSON object representing the current entity
  34811. */
  34812. serialize(): any;
  34813. }
  34814. /**
  34815. * Use this class to create coordinated animations on multiple targets
  34816. */
  34817. export class AnimationGroup implements IDisposable {
  34818. /** The name of the animation group */
  34819. name: string;
  34820. private _scene;
  34821. private _targetedAnimations;
  34822. private _animatables;
  34823. private _from;
  34824. private _to;
  34825. private _isStarted;
  34826. private _isPaused;
  34827. private _speedRatio;
  34828. private _loopAnimation;
  34829. /**
  34830. * Gets or sets the unique id of the node
  34831. */
  34832. uniqueId: number;
  34833. /**
  34834. * This observable will notify when one animation have ended
  34835. */
  34836. onAnimationEndObservable: Observable<TargetedAnimation>;
  34837. /**
  34838. * Observer raised when one animation loops
  34839. */
  34840. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34841. /**
  34842. * Observer raised when all animations have looped
  34843. */
  34844. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34845. /**
  34846. * This observable will notify when all animations have ended.
  34847. */
  34848. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34849. /**
  34850. * This observable will notify when all animations have paused.
  34851. */
  34852. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34853. /**
  34854. * This observable will notify when all animations are playing.
  34855. */
  34856. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34857. /**
  34858. * Gets the first frame
  34859. */
  34860. get from(): number;
  34861. /**
  34862. * Gets the last frame
  34863. */
  34864. get to(): number;
  34865. /**
  34866. * Define if the animations are started
  34867. */
  34868. get isStarted(): boolean;
  34869. /**
  34870. * Gets a value indicating that the current group is playing
  34871. */
  34872. get isPlaying(): boolean;
  34873. /**
  34874. * Gets or sets the speed ratio to use for all animations
  34875. */
  34876. get speedRatio(): number;
  34877. /**
  34878. * Gets or sets the speed ratio to use for all animations
  34879. */
  34880. set speedRatio(value: number);
  34881. /**
  34882. * Gets or sets if all animations should loop or not
  34883. */
  34884. get loopAnimation(): boolean;
  34885. set loopAnimation(value: boolean);
  34886. /**
  34887. * Gets the targeted animations for this animation group
  34888. */
  34889. get targetedAnimations(): Array<TargetedAnimation>;
  34890. /**
  34891. * returning the list of animatables controlled by this animation group.
  34892. */
  34893. get animatables(): Array<Animatable>;
  34894. /**
  34895. * Instantiates a new Animation Group.
  34896. * This helps managing several animations at once.
  34897. * @see http://doc.babylonjs.com/how_to/group
  34898. * @param name Defines the name of the group
  34899. * @param scene Defines the scene the group belongs to
  34900. */
  34901. constructor(
  34902. /** The name of the animation group */
  34903. name: string, scene?: Nullable<Scene>);
  34904. /**
  34905. * Add an animation (with its target) in the group
  34906. * @param animation defines the animation we want to add
  34907. * @param target defines the target of the animation
  34908. * @returns the TargetedAnimation object
  34909. */
  34910. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34911. /**
  34912. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34913. * It can add constant keys at begin or end
  34914. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34915. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34916. * @returns the animation group
  34917. */
  34918. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34919. private _animationLoopCount;
  34920. private _animationLoopFlags;
  34921. private _processLoop;
  34922. /**
  34923. * Start all animations on given targets
  34924. * @param loop defines if animations must loop
  34925. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34926. * @param from defines the from key (optional)
  34927. * @param to defines the to key (optional)
  34928. * @returns the current animation group
  34929. */
  34930. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34931. /**
  34932. * Pause all animations
  34933. * @returns the animation group
  34934. */
  34935. pause(): AnimationGroup;
  34936. /**
  34937. * Play all animations to initial state
  34938. * This function will start() the animations if they were not started or will restart() them if they were paused
  34939. * @param loop defines if animations must loop
  34940. * @returns the animation group
  34941. */
  34942. play(loop?: boolean): AnimationGroup;
  34943. /**
  34944. * Reset all animations to initial state
  34945. * @returns the animation group
  34946. */
  34947. reset(): AnimationGroup;
  34948. /**
  34949. * Restart animations from key 0
  34950. * @returns the animation group
  34951. */
  34952. restart(): AnimationGroup;
  34953. /**
  34954. * Stop all animations
  34955. * @returns the animation group
  34956. */
  34957. stop(): AnimationGroup;
  34958. /**
  34959. * Set animation weight for all animatables
  34960. * @param weight defines the weight to use
  34961. * @return the animationGroup
  34962. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34963. */
  34964. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34965. /**
  34966. * Synchronize and normalize all animatables with a source animatable
  34967. * @param root defines the root animatable to synchronize with
  34968. * @return the animationGroup
  34969. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34970. */
  34971. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34972. /**
  34973. * Goes to a specific frame in this animation group
  34974. * @param frame the frame number to go to
  34975. * @return the animationGroup
  34976. */
  34977. goToFrame(frame: number): AnimationGroup;
  34978. /**
  34979. * Dispose all associated resources
  34980. */
  34981. dispose(): void;
  34982. private _checkAnimationGroupEnded;
  34983. /**
  34984. * Clone the current animation group and returns a copy
  34985. * @param newName defines the name of the new group
  34986. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34987. * @returns the new aniamtion group
  34988. */
  34989. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34990. /**
  34991. * Serializes the animationGroup to an object
  34992. * @returns Serialized object
  34993. */
  34994. serialize(): any;
  34995. /**
  34996. * Returns a new AnimationGroup object parsed from the source provided.
  34997. * @param parsedAnimationGroup defines the source
  34998. * @param scene defines the scene that will receive the animationGroup
  34999. * @returns a new AnimationGroup
  35000. */
  35001. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35002. /**
  35003. * Returns the string "AnimationGroup"
  35004. * @returns "AnimationGroup"
  35005. */
  35006. getClassName(): string;
  35007. /**
  35008. * Creates a detailled string about the object
  35009. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35010. * @returns a string representing the object
  35011. */
  35012. toString(fullDetails?: boolean): string;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /**
  35017. * Define an interface for all classes that will hold resources
  35018. */
  35019. export interface IDisposable {
  35020. /**
  35021. * Releases all held resources
  35022. */
  35023. dispose(): void;
  35024. }
  35025. /** Interface defining initialization parameters for Scene class */
  35026. export interface SceneOptions {
  35027. /**
  35028. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35029. * It will improve performance when the number of geometries becomes important.
  35030. */
  35031. useGeometryUniqueIdsMap?: boolean;
  35032. /**
  35033. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35034. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35035. */
  35036. useMaterialMeshMap?: boolean;
  35037. /**
  35038. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35039. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35040. */
  35041. useClonedMeshMap?: boolean;
  35042. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35043. virtual?: boolean;
  35044. }
  35045. /**
  35046. * Represents a scene to be rendered by the engine.
  35047. * @see http://doc.babylonjs.com/features/scene
  35048. */
  35049. export class Scene extends AbstractScene implements IAnimatable {
  35050. /** The fog is deactivated */
  35051. static readonly FOGMODE_NONE: number;
  35052. /** The fog density is following an exponential function */
  35053. static readonly FOGMODE_EXP: number;
  35054. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35055. static readonly FOGMODE_EXP2: number;
  35056. /** The fog density is following a linear function. */
  35057. static readonly FOGMODE_LINEAR: number;
  35058. /**
  35059. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35060. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35061. */
  35062. static MinDeltaTime: number;
  35063. /**
  35064. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35066. */
  35067. static MaxDeltaTime: number;
  35068. /**
  35069. * Factory used to create the default material.
  35070. * @param name The name of the material to create
  35071. * @param scene The scene to create the material for
  35072. * @returns The default material
  35073. */
  35074. static DefaultMaterialFactory(scene: Scene): Material;
  35075. /**
  35076. * Factory used to create the a collision coordinator.
  35077. * @returns The collision coordinator
  35078. */
  35079. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35080. /** @hidden */
  35081. _inputManager: InputManager;
  35082. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35083. cameraToUseForPointers: Nullable<Camera>;
  35084. /** @hidden */
  35085. readonly _isScene: boolean;
  35086. /** @hidden */
  35087. _blockEntityCollection: boolean;
  35088. /**
  35089. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35090. */
  35091. autoClear: boolean;
  35092. /**
  35093. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35094. */
  35095. autoClearDepthAndStencil: boolean;
  35096. /**
  35097. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35098. */
  35099. clearColor: Color4;
  35100. /**
  35101. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35102. */
  35103. ambientColor: Color3;
  35104. /**
  35105. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35106. * It should only be one of the following (if not the default embedded one):
  35107. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35108. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35109. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35110. * The material properties need to be setup according to the type of texture in use.
  35111. */
  35112. environmentBRDFTexture: BaseTexture;
  35113. /** @hidden */
  35114. protected _environmentTexture: Nullable<BaseTexture>;
  35115. /**
  35116. * Texture used in all pbr material as the reflection texture.
  35117. * As in the majority of the scene they are the same (exception for multi room and so on),
  35118. * this is easier to reference from here than from all the materials.
  35119. */
  35120. get environmentTexture(): Nullable<BaseTexture>;
  35121. /**
  35122. * Texture used in all pbr material as the reflection texture.
  35123. * As in the majority of the scene they are the same (exception for multi room and so on),
  35124. * this is easier to set here than in all the materials.
  35125. */
  35126. set environmentTexture(value: Nullable<BaseTexture>);
  35127. /** @hidden */
  35128. protected _environmentIntensity: number;
  35129. /**
  35130. * Intensity of the environment in all pbr material.
  35131. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35132. * As in the majority of the scene they are the same (exception for multi room and so on),
  35133. * this is easier to reference from here than from all the materials.
  35134. */
  35135. get environmentIntensity(): number;
  35136. /**
  35137. * Intensity of the environment in all pbr material.
  35138. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35139. * As in the majority of the scene they are the same (exception for multi room and so on),
  35140. * this is easier to set here than in all the materials.
  35141. */
  35142. set environmentIntensity(value: number);
  35143. /** @hidden */
  35144. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35145. /**
  35146. * Default image processing configuration used either in the rendering
  35147. * Forward main pass or through the imageProcessingPostProcess if present.
  35148. * As in the majority of the scene they are the same (exception for multi camera),
  35149. * this is easier to reference from here than from all the materials and post process.
  35150. *
  35151. * No setter as we it is a shared configuration, you can set the values instead.
  35152. */
  35153. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35154. private _forceWireframe;
  35155. /**
  35156. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35157. */
  35158. set forceWireframe(value: boolean);
  35159. get forceWireframe(): boolean;
  35160. private _skipFrustumClipping;
  35161. /**
  35162. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35163. */
  35164. set skipFrustumClipping(value: boolean);
  35165. get skipFrustumClipping(): boolean;
  35166. private _forcePointsCloud;
  35167. /**
  35168. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35169. */
  35170. set forcePointsCloud(value: boolean);
  35171. get forcePointsCloud(): boolean;
  35172. /**
  35173. * Gets or sets the active clipplane 1
  35174. */
  35175. clipPlane: Nullable<Plane>;
  35176. /**
  35177. * Gets or sets the active clipplane 2
  35178. */
  35179. clipPlane2: Nullable<Plane>;
  35180. /**
  35181. * Gets or sets the active clipplane 3
  35182. */
  35183. clipPlane3: Nullable<Plane>;
  35184. /**
  35185. * Gets or sets the active clipplane 4
  35186. */
  35187. clipPlane4: Nullable<Plane>;
  35188. /**
  35189. * Gets or sets the active clipplane 5
  35190. */
  35191. clipPlane5: Nullable<Plane>;
  35192. /**
  35193. * Gets or sets the active clipplane 6
  35194. */
  35195. clipPlane6: Nullable<Plane>;
  35196. /**
  35197. * Gets or sets a boolean indicating if animations are enabled
  35198. */
  35199. animationsEnabled: boolean;
  35200. private _animationPropertiesOverride;
  35201. /**
  35202. * Gets or sets the animation properties override
  35203. */
  35204. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35205. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35206. /**
  35207. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35208. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35209. */
  35210. useConstantAnimationDeltaTime: boolean;
  35211. /**
  35212. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35213. * Please note that it requires to run a ray cast through the scene on every frame
  35214. */
  35215. constantlyUpdateMeshUnderPointer: boolean;
  35216. /**
  35217. * Defines the HTML cursor to use when hovering over interactive elements
  35218. */
  35219. hoverCursor: string;
  35220. /**
  35221. * Defines the HTML default cursor to use (empty by default)
  35222. */
  35223. defaultCursor: string;
  35224. /**
  35225. * Defines whether cursors are handled by the scene.
  35226. */
  35227. doNotHandleCursors: boolean;
  35228. /**
  35229. * This is used to call preventDefault() on pointer down
  35230. * in order to block unwanted artifacts like system double clicks
  35231. */
  35232. preventDefaultOnPointerDown: boolean;
  35233. /**
  35234. * This is used to call preventDefault() on pointer up
  35235. * in order to block unwanted artifacts like system double clicks
  35236. */
  35237. preventDefaultOnPointerUp: boolean;
  35238. /**
  35239. * Gets or sets user defined metadata
  35240. */
  35241. metadata: any;
  35242. /**
  35243. * For internal use only. Please do not use.
  35244. */
  35245. reservedDataStore: any;
  35246. /**
  35247. * Gets the name of the plugin used to load this scene (null by default)
  35248. */
  35249. loadingPluginName: string;
  35250. /**
  35251. * Use this array to add regular expressions used to disable offline support for specific urls
  35252. */
  35253. disableOfflineSupportExceptionRules: RegExp[];
  35254. /**
  35255. * An event triggered when the scene is disposed.
  35256. */
  35257. onDisposeObservable: Observable<Scene>;
  35258. private _onDisposeObserver;
  35259. /** Sets a function to be executed when this scene is disposed. */
  35260. set onDispose(callback: () => void);
  35261. /**
  35262. * An event triggered before rendering the scene (right after animations and physics)
  35263. */
  35264. onBeforeRenderObservable: Observable<Scene>;
  35265. private _onBeforeRenderObserver;
  35266. /** Sets a function to be executed before rendering this scene */
  35267. set beforeRender(callback: Nullable<() => void>);
  35268. /**
  35269. * An event triggered after rendering the scene
  35270. */
  35271. onAfterRenderObservable: Observable<Scene>;
  35272. /**
  35273. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35274. */
  35275. onAfterRenderCameraObservable: Observable<Camera>;
  35276. private _onAfterRenderObserver;
  35277. /** Sets a function to be executed after rendering this scene */
  35278. set afterRender(callback: Nullable<() => void>);
  35279. /**
  35280. * An event triggered before animating the scene
  35281. */
  35282. onBeforeAnimationsObservable: Observable<Scene>;
  35283. /**
  35284. * An event triggered after animations processing
  35285. */
  35286. onAfterAnimationsObservable: Observable<Scene>;
  35287. /**
  35288. * An event triggered before draw calls are ready to be sent
  35289. */
  35290. onBeforeDrawPhaseObservable: Observable<Scene>;
  35291. /**
  35292. * An event triggered after draw calls have been sent
  35293. */
  35294. onAfterDrawPhaseObservable: Observable<Scene>;
  35295. /**
  35296. * An event triggered when the scene is ready
  35297. */
  35298. onReadyObservable: Observable<Scene>;
  35299. /**
  35300. * An event triggered before rendering a camera
  35301. */
  35302. onBeforeCameraRenderObservable: Observable<Camera>;
  35303. private _onBeforeCameraRenderObserver;
  35304. /** Sets a function to be executed before rendering a camera*/
  35305. set beforeCameraRender(callback: () => void);
  35306. /**
  35307. * An event triggered after rendering a camera
  35308. */
  35309. onAfterCameraRenderObservable: Observable<Camera>;
  35310. private _onAfterCameraRenderObserver;
  35311. /** Sets a function to be executed after rendering a camera*/
  35312. set afterCameraRender(callback: () => void);
  35313. /**
  35314. * An event triggered when active meshes evaluation is about to start
  35315. */
  35316. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35317. /**
  35318. * An event triggered when active meshes evaluation is done
  35319. */
  35320. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35321. /**
  35322. * An event triggered when particles rendering is about to start
  35323. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35324. */
  35325. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35326. /**
  35327. * An event triggered when particles rendering is done
  35328. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35329. */
  35330. onAfterParticlesRenderingObservable: Observable<Scene>;
  35331. /**
  35332. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35333. */
  35334. onDataLoadedObservable: Observable<Scene>;
  35335. /**
  35336. * An event triggered when a camera is created
  35337. */
  35338. onNewCameraAddedObservable: Observable<Camera>;
  35339. /**
  35340. * An event triggered when a camera is removed
  35341. */
  35342. onCameraRemovedObservable: Observable<Camera>;
  35343. /**
  35344. * An event triggered when a light is created
  35345. */
  35346. onNewLightAddedObservable: Observable<Light>;
  35347. /**
  35348. * An event triggered when a light is removed
  35349. */
  35350. onLightRemovedObservable: Observable<Light>;
  35351. /**
  35352. * An event triggered when a geometry is created
  35353. */
  35354. onNewGeometryAddedObservable: Observable<Geometry>;
  35355. /**
  35356. * An event triggered when a geometry is removed
  35357. */
  35358. onGeometryRemovedObservable: Observable<Geometry>;
  35359. /**
  35360. * An event triggered when a transform node is created
  35361. */
  35362. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35363. /**
  35364. * An event triggered when a transform node is removed
  35365. */
  35366. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35367. /**
  35368. * An event triggered when a mesh is created
  35369. */
  35370. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35371. /**
  35372. * An event triggered when a mesh is removed
  35373. */
  35374. onMeshRemovedObservable: Observable<AbstractMesh>;
  35375. /**
  35376. * An event triggered when a skeleton is created
  35377. */
  35378. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35379. /**
  35380. * An event triggered when a skeleton is removed
  35381. */
  35382. onSkeletonRemovedObservable: Observable<Skeleton>;
  35383. /**
  35384. * An event triggered when a material is created
  35385. */
  35386. onNewMaterialAddedObservable: Observable<Material>;
  35387. /**
  35388. * An event triggered when a material is removed
  35389. */
  35390. onMaterialRemovedObservable: Observable<Material>;
  35391. /**
  35392. * An event triggered when a texture is created
  35393. */
  35394. onNewTextureAddedObservable: Observable<BaseTexture>;
  35395. /**
  35396. * An event triggered when a texture is removed
  35397. */
  35398. onTextureRemovedObservable: Observable<BaseTexture>;
  35399. /**
  35400. * An event triggered when render targets are about to be rendered
  35401. * Can happen multiple times per frame.
  35402. */
  35403. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35404. /**
  35405. * An event triggered when render targets were rendered.
  35406. * Can happen multiple times per frame.
  35407. */
  35408. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35409. /**
  35410. * An event triggered before calculating deterministic simulation step
  35411. */
  35412. onBeforeStepObservable: Observable<Scene>;
  35413. /**
  35414. * An event triggered after calculating deterministic simulation step
  35415. */
  35416. onAfterStepObservable: Observable<Scene>;
  35417. /**
  35418. * An event triggered when the activeCamera property is updated
  35419. */
  35420. onActiveCameraChanged: Observable<Scene>;
  35421. /**
  35422. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35423. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35424. * 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)
  35425. */
  35426. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35427. /**
  35428. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35429. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35430. * 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)
  35431. */
  35432. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35433. /**
  35434. * This Observable will when a mesh has been imported into the scene.
  35435. */
  35436. onMeshImportedObservable: Observable<AbstractMesh>;
  35437. /**
  35438. * This Observable will when an animation file has been imported into the scene.
  35439. */
  35440. onAnimationFileImportedObservable: Observable<Scene>;
  35441. /**
  35442. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35443. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35444. */
  35445. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35446. /** @hidden */
  35447. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35448. /**
  35449. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35450. */
  35451. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35452. /**
  35453. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35454. */
  35455. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35456. /**
  35457. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35458. */
  35459. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35460. /** Callback called when a pointer move is detected */
  35461. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35462. /** Callback called when a pointer down is detected */
  35463. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35464. /** Callback called when a pointer up is detected */
  35465. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35466. /** Callback called when a pointer pick is detected */
  35467. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35468. /**
  35469. * 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).
  35470. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35471. */
  35472. onPrePointerObservable: Observable<PointerInfoPre>;
  35473. /**
  35474. * Observable event triggered each time an input event is received from the rendering canvas
  35475. */
  35476. onPointerObservable: Observable<PointerInfo>;
  35477. /**
  35478. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35479. */
  35480. get unTranslatedPointer(): Vector2;
  35481. /**
  35482. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35483. */
  35484. static get DragMovementThreshold(): number;
  35485. static set DragMovementThreshold(value: number);
  35486. /**
  35487. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35488. */
  35489. static get LongPressDelay(): number;
  35490. static set LongPressDelay(value: number);
  35491. /**
  35492. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35493. */
  35494. static get DoubleClickDelay(): number;
  35495. static set DoubleClickDelay(value: number);
  35496. /** If you need to check double click without raising a single click at first click, enable this flag */
  35497. static get ExclusiveDoubleClickMode(): boolean;
  35498. static set ExclusiveDoubleClickMode(value: boolean);
  35499. /** @hidden */
  35500. _mirroredCameraPosition: Nullable<Vector3>;
  35501. /**
  35502. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35503. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35504. */
  35505. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35506. /**
  35507. * Observable event triggered each time an keyboard event is received from the hosting window
  35508. */
  35509. onKeyboardObservable: Observable<KeyboardInfo>;
  35510. private _useRightHandedSystem;
  35511. /**
  35512. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35513. */
  35514. set useRightHandedSystem(value: boolean);
  35515. get useRightHandedSystem(): boolean;
  35516. private _timeAccumulator;
  35517. private _currentStepId;
  35518. private _currentInternalStep;
  35519. /**
  35520. * Sets the step Id used by deterministic lock step
  35521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35522. * @param newStepId defines the step Id
  35523. */
  35524. setStepId(newStepId: number): void;
  35525. /**
  35526. * Gets the step Id used by deterministic lock step
  35527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35528. * @returns the step Id
  35529. */
  35530. getStepId(): number;
  35531. /**
  35532. * Gets the internal step used by deterministic lock step
  35533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35534. * @returns the internal step
  35535. */
  35536. getInternalStep(): number;
  35537. private _fogEnabled;
  35538. /**
  35539. * Gets or sets a boolean indicating if fog is enabled on this scene
  35540. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35541. * (Default is true)
  35542. */
  35543. set fogEnabled(value: boolean);
  35544. get fogEnabled(): boolean;
  35545. private _fogMode;
  35546. /**
  35547. * Gets or sets the fog mode to use
  35548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35549. * | mode | value |
  35550. * | --- | --- |
  35551. * | FOGMODE_NONE | 0 |
  35552. * | FOGMODE_EXP | 1 |
  35553. * | FOGMODE_EXP2 | 2 |
  35554. * | FOGMODE_LINEAR | 3 |
  35555. */
  35556. set fogMode(value: number);
  35557. get fogMode(): number;
  35558. /**
  35559. * Gets or sets the fog color to use
  35560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35561. * (Default is Color3(0.2, 0.2, 0.3))
  35562. */
  35563. fogColor: Color3;
  35564. /**
  35565. * Gets or sets the fog density to use
  35566. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35567. * (Default is 0.1)
  35568. */
  35569. fogDensity: number;
  35570. /**
  35571. * Gets or sets the fog start distance to use
  35572. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35573. * (Default is 0)
  35574. */
  35575. fogStart: number;
  35576. /**
  35577. * Gets or sets the fog end distance to use
  35578. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35579. * (Default is 1000)
  35580. */
  35581. fogEnd: number;
  35582. private _shadowsEnabled;
  35583. /**
  35584. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35585. */
  35586. set shadowsEnabled(value: boolean);
  35587. get shadowsEnabled(): boolean;
  35588. private _lightsEnabled;
  35589. /**
  35590. * Gets or sets a boolean indicating if lights are enabled on this scene
  35591. */
  35592. set lightsEnabled(value: boolean);
  35593. get lightsEnabled(): boolean;
  35594. /** All of the active cameras added to this scene. */
  35595. activeCameras: Camera[];
  35596. /** @hidden */
  35597. _activeCamera: Nullable<Camera>;
  35598. /** Gets or sets the current active camera */
  35599. get activeCamera(): Nullable<Camera>;
  35600. set activeCamera(value: Nullable<Camera>);
  35601. private _defaultMaterial;
  35602. /** The default material used on meshes when no material is affected */
  35603. get defaultMaterial(): Material;
  35604. /** The default material used on meshes when no material is affected */
  35605. set defaultMaterial(value: Material);
  35606. private _texturesEnabled;
  35607. /**
  35608. * Gets or sets a boolean indicating if textures are enabled on this scene
  35609. */
  35610. set texturesEnabled(value: boolean);
  35611. get texturesEnabled(): boolean;
  35612. /**
  35613. * Gets or sets a boolean indicating if particles are enabled on this scene
  35614. */
  35615. particlesEnabled: boolean;
  35616. /**
  35617. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35618. */
  35619. spritesEnabled: boolean;
  35620. private _skeletonsEnabled;
  35621. /**
  35622. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35623. */
  35624. set skeletonsEnabled(value: boolean);
  35625. get skeletonsEnabled(): boolean;
  35626. /**
  35627. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35628. */
  35629. lensFlaresEnabled: boolean;
  35630. /**
  35631. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35633. */
  35634. collisionsEnabled: boolean;
  35635. private _collisionCoordinator;
  35636. /** @hidden */
  35637. get collisionCoordinator(): ICollisionCoordinator;
  35638. /**
  35639. * Defines the gravity applied to this scene (used only for collisions)
  35640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35641. */
  35642. gravity: Vector3;
  35643. /**
  35644. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35645. */
  35646. postProcessesEnabled: boolean;
  35647. /**
  35648. * The list of postprocesses added to the scene
  35649. */
  35650. postProcesses: PostProcess[];
  35651. /**
  35652. * Gets the current postprocess manager
  35653. */
  35654. postProcessManager: PostProcessManager;
  35655. /**
  35656. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35657. */
  35658. renderTargetsEnabled: boolean;
  35659. /**
  35660. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35661. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35662. */
  35663. dumpNextRenderTargets: boolean;
  35664. /**
  35665. * The list of user defined render targets added to the scene
  35666. */
  35667. customRenderTargets: RenderTargetTexture[];
  35668. /**
  35669. * Defines if texture loading must be delayed
  35670. * If true, textures will only be loaded when they need to be rendered
  35671. */
  35672. useDelayedTextureLoading: boolean;
  35673. /**
  35674. * Gets the list of meshes imported to the scene through SceneLoader
  35675. */
  35676. importedMeshesFiles: String[];
  35677. /**
  35678. * Gets or sets a boolean indicating if probes are enabled on this scene
  35679. */
  35680. probesEnabled: boolean;
  35681. /**
  35682. * Gets or sets the current offline provider to use to store scene data
  35683. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35684. */
  35685. offlineProvider: IOfflineProvider;
  35686. /**
  35687. * Gets or sets the action manager associated with the scene
  35688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35689. */
  35690. actionManager: AbstractActionManager;
  35691. private _meshesForIntersections;
  35692. /**
  35693. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35694. */
  35695. proceduralTexturesEnabled: boolean;
  35696. private _engine;
  35697. private _totalVertices;
  35698. /** @hidden */
  35699. _activeIndices: PerfCounter;
  35700. /** @hidden */
  35701. _activeParticles: PerfCounter;
  35702. /** @hidden */
  35703. _activeBones: PerfCounter;
  35704. private _animationRatio;
  35705. /** @hidden */
  35706. _animationTimeLast: number;
  35707. /** @hidden */
  35708. _animationTime: number;
  35709. /**
  35710. * Gets or sets a general scale for animation speed
  35711. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35712. */
  35713. animationTimeScale: number;
  35714. /** @hidden */
  35715. _cachedMaterial: Nullable<Material>;
  35716. /** @hidden */
  35717. _cachedEffect: Nullable<Effect>;
  35718. /** @hidden */
  35719. _cachedVisibility: Nullable<number>;
  35720. private _renderId;
  35721. private _frameId;
  35722. private _executeWhenReadyTimeoutId;
  35723. private _intermediateRendering;
  35724. private _viewUpdateFlag;
  35725. private _projectionUpdateFlag;
  35726. /** @hidden */
  35727. _toBeDisposed: Nullable<IDisposable>[];
  35728. private _activeRequests;
  35729. /** @hidden */
  35730. _pendingData: any[];
  35731. private _isDisposed;
  35732. /**
  35733. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35734. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35735. */
  35736. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35737. private _activeMeshes;
  35738. private _processedMaterials;
  35739. private _renderTargets;
  35740. /** @hidden */
  35741. _activeParticleSystems: SmartArray<IParticleSystem>;
  35742. private _activeSkeletons;
  35743. private _softwareSkinnedMeshes;
  35744. private _renderingManager;
  35745. /** @hidden */
  35746. _activeAnimatables: Animatable[];
  35747. private _transformMatrix;
  35748. private _sceneUbo;
  35749. /** @hidden */
  35750. _viewMatrix: Matrix;
  35751. private _projectionMatrix;
  35752. /** @hidden */
  35753. _forcedViewPosition: Nullable<Vector3>;
  35754. /** @hidden */
  35755. _frustumPlanes: Plane[];
  35756. /**
  35757. * Gets the list of frustum planes (built from the active camera)
  35758. */
  35759. get frustumPlanes(): Plane[];
  35760. /**
  35761. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35762. * This is useful if there are more lights that the maximum simulteanous authorized
  35763. */
  35764. requireLightSorting: boolean;
  35765. /** @hidden */
  35766. readonly useMaterialMeshMap: boolean;
  35767. /** @hidden */
  35768. readonly useClonedMeshMap: boolean;
  35769. private _externalData;
  35770. private _uid;
  35771. /**
  35772. * @hidden
  35773. * Backing store of defined scene components.
  35774. */
  35775. _components: ISceneComponent[];
  35776. /**
  35777. * @hidden
  35778. * Backing store of defined scene components.
  35779. */
  35780. _serializableComponents: ISceneSerializableComponent[];
  35781. /**
  35782. * List of components to register on the next registration step.
  35783. */
  35784. private _transientComponents;
  35785. /**
  35786. * Registers the transient components if needed.
  35787. */
  35788. private _registerTransientComponents;
  35789. /**
  35790. * @hidden
  35791. * Add a component to the scene.
  35792. * Note that the ccomponent could be registered on th next frame if this is called after
  35793. * the register component stage.
  35794. * @param component Defines the component to add to the scene
  35795. */
  35796. _addComponent(component: ISceneComponent): void;
  35797. /**
  35798. * @hidden
  35799. * Gets a component from the scene.
  35800. * @param name defines the name of the component to retrieve
  35801. * @returns the component or null if not present
  35802. */
  35803. _getComponent(name: string): Nullable<ISceneComponent>;
  35804. /**
  35805. * @hidden
  35806. * Defines the actions happening before camera updates.
  35807. */
  35808. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35809. /**
  35810. * @hidden
  35811. * Defines the actions happening before clear the canvas.
  35812. */
  35813. _beforeClearStage: Stage<SimpleStageAction>;
  35814. /**
  35815. * @hidden
  35816. * Defines the actions when collecting render targets for the frame.
  35817. */
  35818. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35819. /**
  35820. * @hidden
  35821. * Defines the actions happening for one camera in the frame.
  35822. */
  35823. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35824. /**
  35825. * @hidden
  35826. * Defines the actions happening during the per mesh ready checks.
  35827. */
  35828. _isReadyForMeshStage: Stage<MeshStageAction>;
  35829. /**
  35830. * @hidden
  35831. * Defines the actions happening before evaluate active mesh checks.
  35832. */
  35833. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35834. /**
  35835. * @hidden
  35836. * Defines the actions happening during the evaluate sub mesh checks.
  35837. */
  35838. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35839. /**
  35840. * @hidden
  35841. * Defines the actions happening during the active mesh stage.
  35842. */
  35843. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35844. /**
  35845. * @hidden
  35846. * Defines the actions happening during the per camera render target step.
  35847. */
  35848. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35849. /**
  35850. * @hidden
  35851. * Defines the actions happening just before the active camera is drawing.
  35852. */
  35853. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35854. /**
  35855. * @hidden
  35856. * Defines the actions happening just before a render target is drawing.
  35857. */
  35858. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35859. /**
  35860. * @hidden
  35861. * Defines the actions happening just before a rendering group is drawing.
  35862. */
  35863. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35864. /**
  35865. * @hidden
  35866. * Defines the actions happening just before a mesh is drawing.
  35867. */
  35868. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35869. /**
  35870. * @hidden
  35871. * Defines the actions happening just after a mesh has been drawn.
  35872. */
  35873. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35874. /**
  35875. * @hidden
  35876. * Defines the actions happening just after a rendering group has been drawn.
  35877. */
  35878. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35879. /**
  35880. * @hidden
  35881. * Defines the actions happening just after the active camera has been drawn.
  35882. */
  35883. _afterCameraDrawStage: Stage<CameraStageAction>;
  35884. /**
  35885. * @hidden
  35886. * Defines the actions happening just after a render target has been drawn.
  35887. */
  35888. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35889. /**
  35890. * @hidden
  35891. * Defines the actions happening just after rendering all cameras and computing intersections.
  35892. */
  35893. _afterRenderStage: Stage<SimpleStageAction>;
  35894. /**
  35895. * @hidden
  35896. * Defines the actions happening when a pointer move event happens.
  35897. */
  35898. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35899. /**
  35900. * @hidden
  35901. * Defines the actions happening when a pointer down event happens.
  35902. */
  35903. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35904. /**
  35905. * @hidden
  35906. * Defines the actions happening when a pointer up event happens.
  35907. */
  35908. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35909. /**
  35910. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35911. */
  35912. private geometriesByUniqueId;
  35913. /**
  35914. * Creates a new Scene
  35915. * @param engine defines the engine to use to render this scene
  35916. * @param options defines the scene options
  35917. */
  35918. constructor(engine: Engine, options?: SceneOptions);
  35919. /**
  35920. * Gets a string idenfifying the name of the class
  35921. * @returns "Scene" string
  35922. */
  35923. getClassName(): string;
  35924. private _defaultMeshCandidates;
  35925. /**
  35926. * @hidden
  35927. */
  35928. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35929. private _defaultSubMeshCandidates;
  35930. /**
  35931. * @hidden
  35932. */
  35933. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35934. /**
  35935. * Sets the default candidate providers for the scene.
  35936. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35937. * and getCollidingSubMeshCandidates to their default function
  35938. */
  35939. setDefaultCandidateProviders(): void;
  35940. /**
  35941. * Gets the mesh that is currently under the pointer
  35942. */
  35943. get meshUnderPointer(): Nullable<AbstractMesh>;
  35944. /**
  35945. * Gets or sets the current on-screen X position of the pointer
  35946. */
  35947. get pointerX(): number;
  35948. set pointerX(value: number);
  35949. /**
  35950. * Gets or sets the current on-screen Y position of the pointer
  35951. */
  35952. get pointerY(): number;
  35953. set pointerY(value: number);
  35954. /**
  35955. * Gets the cached material (ie. the latest rendered one)
  35956. * @returns the cached material
  35957. */
  35958. getCachedMaterial(): Nullable<Material>;
  35959. /**
  35960. * Gets the cached effect (ie. the latest rendered one)
  35961. * @returns the cached effect
  35962. */
  35963. getCachedEffect(): Nullable<Effect>;
  35964. /**
  35965. * Gets the cached visibility state (ie. the latest rendered one)
  35966. * @returns the cached visibility state
  35967. */
  35968. getCachedVisibility(): Nullable<number>;
  35969. /**
  35970. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35971. * @param material defines the current material
  35972. * @param effect defines the current effect
  35973. * @param visibility defines the current visibility state
  35974. * @returns true if one parameter is not cached
  35975. */
  35976. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35977. /**
  35978. * Gets the engine associated with the scene
  35979. * @returns an Engine
  35980. */
  35981. getEngine(): Engine;
  35982. /**
  35983. * Gets the total number of vertices rendered per frame
  35984. * @returns the total number of vertices rendered per frame
  35985. */
  35986. getTotalVertices(): number;
  35987. /**
  35988. * Gets the performance counter for total vertices
  35989. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35990. */
  35991. get totalVerticesPerfCounter(): PerfCounter;
  35992. /**
  35993. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35994. * @returns the total number of active indices rendered per frame
  35995. */
  35996. getActiveIndices(): number;
  35997. /**
  35998. * Gets the performance counter for active indices
  35999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36000. */
  36001. get totalActiveIndicesPerfCounter(): PerfCounter;
  36002. /**
  36003. * Gets the total number of active particles rendered per frame
  36004. * @returns the total number of active particles rendered per frame
  36005. */
  36006. getActiveParticles(): number;
  36007. /**
  36008. * Gets the performance counter for active particles
  36009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36010. */
  36011. get activeParticlesPerfCounter(): PerfCounter;
  36012. /**
  36013. * Gets the total number of active bones rendered per frame
  36014. * @returns the total number of active bones rendered per frame
  36015. */
  36016. getActiveBones(): number;
  36017. /**
  36018. * Gets the performance counter for active bones
  36019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36020. */
  36021. get activeBonesPerfCounter(): PerfCounter;
  36022. /**
  36023. * Gets the array of active meshes
  36024. * @returns an array of AbstractMesh
  36025. */
  36026. getActiveMeshes(): SmartArray<AbstractMesh>;
  36027. /**
  36028. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36029. * @returns a number
  36030. */
  36031. getAnimationRatio(): number;
  36032. /**
  36033. * Gets an unique Id for the current render phase
  36034. * @returns a number
  36035. */
  36036. getRenderId(): number;
  36037. /**
  36038. * Gets an unique Id for the current frame
  36039. * @returns a number
  36040. */
  36041. getFrameId(): number;
  36042. /** Call this function if you want to manually increment the render Id*/
  36043. incrementRenderId(): void;
  36044. private _createUbo;
  36045. /**
  36046. * Use this method to simulate a pointer move on a mesh
  36047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36050. * @returns the current scene
  36051. */
  36052. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36053. /**
  36054. * Use this method to simulate a pointer down on a mesh
  36055. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36056. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36057. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36058. * @returns the current scene
  36059. */
  36060. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36061. /**
  36062. * Use this method to simulate a pointer up on a mesh
  36063. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36064. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36065. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36066. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36067. * @returns the current scene
  36068. */
  36069. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36070. /**
  36071. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36072. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36073. * @returns true if the pointer was captured
  36074. */
  36075. isPointerCaptured(pointerId?: number): boolean;
  36076. /**
  36077. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36078. * @param attachUp defines if you want to attach events to pointerup
  36079. * @param attachDown defines if you want to attach events to pointerdown
  36080. * @param attachMove defines if you want to attach events to pointermove
  36081. */
  36082. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36083. /** Detaches all event handlers*/
  36084. detachControl(): void;
  36085. /**
  36086. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36087. * Delay loaded resources are not taking in account
  36088. * @return true if all required resources are ready
  36089. */
  36090. isReady(): boolean;
  36091. /** Resets all cached information relative to material (including effect and visibility) */
  36092. resetCachedMaterial(): void;
  36093. /**
  36094. * Registers a function to be called before every frame render
  36095. * @param func defines the function to register
  36096. */
  36097. registerBeforeRender(func: () => void): void;
  36098. /**
  36099. * Unregisters a function called before every frame render
  36100. * @param func defines the function to unregister
  36101. */
  36102. unregisterBeforeRender(func: () => void): void;
  36103. /**
  36104. * Registers a function to be called after every frame render
  36105. * @param func defines the function to register
  36106. */
  36107. registerAfterRender(func: () => void): void;
  36108. /**
  36109. * Unregisters a function called after every frame render
  36110. * @param func defines the function to unregister
  36111. */
  36112. unregisterAfterRender(func: () => void): void;
  36113. private _executeOnceBeforeRender;
  36114. /**
  36115. * The provided function will run before render once and will be disposed afterwards.
  36116. * A timeout delay can be provided so that the function will be executed in N ms.
  36117. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36118. * @param func The function to be executed.
  36119. * @param timeout optional delay in ms
  36120. */
  36121. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36122. /** @hidden */
  36123. _addPendingData(data: any): void;
  36124. /** @hidden */
  36125. _removePendingData(data: any): void;
  36126. /**
  36127. * Returns the number of items waiting to be loaded
  36128. * @returns the number of items waiting to be loaded
  36129. */
  36130. getWaitingItemsCount(): number;
  36131. /**
  36132. * Returns a boolean indicating if the scene is still loading data
  36133. */
  36134. get isLoading(): boolean;
  36135. /**
  36136. * Registers a function to be executed when the scene is ready
  36137. * @param {Function} func - the function to be executed
  36138. */
  36139. executeWhenReady(func: () => void): void;
  36140. /**
  36141. * Returns a promise that resolves when the scene is ready
  36142. * @returns A promise that resolves when the scene is ready
  36143. */
  36144. whenReadyAsync(): Promise<void>;
  36145. /** @hidden */
  36146. _checkIsReady(): void;
  36147. /**
  36148. * Gets all animatable attached to the scene
  36149. */
  36150. get animatables(): Animatable[];
  36151. /**
  36152. * Resets the last animation time frame.
  36153. * Useful to override when animations start running when loading a scene for the first time.
  36154. */
  36155. resetLastAnimationTimeFrame(): void;
  36156. /**
  36157. * Gets the current view matrix
  36158. * @returns a Matrix
  36159. */
  36160. getViewMatrix(): Matrix;
  36161. /**
  36162. * Gets the current projection matrix
  36163. * @returns a Matrix
  36164. */
  36165. getProjectionMatrix(): Matrix;
  36166. /**
  36167. * Gets the current transform matrix
  36168. * @returns a Matrix made of View * Projection
  36169. */
  36170. getTransformMatrix(): Matrix;
  36171. /**
  36172. * Sets the current transform matrix
  36173. * @param viewL defines the View matrix to use
  36174. * @param projectionL defines the Projection matrix to use
  36175. * @param viewR defines the right View matrix to use (if provided)
  36176. * @param projectionR defines the right Projection matrix to use (if provided)
  36177. */
  36178. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36179. /**
  36180. * Gets the uniform buffer used to store scene data
  36181. * @returns a UniformBuffer
  36182. */
  36183. getSceneUniformBuffer(): UniformBuffer;
  36184. /**
  36185. * Gets an unique (relatively to the current scene) Id
  36186. * @returns an unique number for the scene
  36187. */
  36188. getUniqueId(): number;
  36189. /**
  36190. * Add a mesh to the list of scene's meshes
  36191. * @param newMesh defines the mesh to add
  36192. * @param recursive if all child meshes should also be added to the scene
  36193. */
  36194. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36195. /**
  36196. * Remove a mesh for the list of scene's meshes
  36197. * @param toRemove defines the mesh to remove
  36198. * @param recursive if all child meshes should also be removed from the scene
  36199. * @returns the index where the mesh was in the mesh list
  36200. */
  36201. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36202. /**
  36203. * Add a transform node to the list of scene's transform nodes
  36204. * @param newTransformNode defines the transform node to add
  36205. */
  36206. addTransformNode(newTransformNode: TransformNode): void;
  36207. /**
  36208. * Remove a transform node for the list of scene's transform nodes
  36209. * @param toRemove defines the transform node to remove
  36210. * @returns the index where the transform node was in the transform node list
  36211. */
  36212. removeTransformNode(toRemove: TransformNode): number;
  36213. /**
  36214. * Remove a skeleton for the list of scene's skeletons
  36215. * @param toRemove defines the skeleton to remove
  36216. * @returns the index where the skeleton was in the skeleton list
  36217. */
  36218. removeSkeleton(toRemove: Skeleton): number;
  36219. /**
  36220. * Remove a morph target for the list of scene's morph targets
  36221. * @param toRemove defines the morph target to remove
  36222. * @returns the index where the morph target was in the morph target list
  36223. */
  36224. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36225. /**
  36226. * Remove a light for the list of scene's lights
  36227. * @param toRemove defines the light to remove
  36228. * @returns the index where the light was in the light list
  36229. */
  36230. removeLight(toRemove: Light): number;
  36231. /**
  36232. * Remove a camera for the list of scene's cameras
  36233. * @param toRemove defines the camera to remove
  36234. * @returns the index where the camera was in the camera list
  36235. */
  36236. removeCamera(toRemove: Camera): number;
  36237. /**
  36238. * Remove a particle system for the list of scene's particle systems
  36239. * @param toRemove defines the particle system to remove
  36240. * @returns the index where the particle system was in the particle system list
  36241. */
  36242. removeParticleSystem(toRemove: IParticleSystem): number;
  36243. /**
  36244. * Remove a animation for the list of scene's animations
  36245. * @param toRemove defines the animation to remove
  36246. * @returns the index where the animation was in the animation list
  36247. */
  36248. removeAnimation(toRemove: Animation): number;
  36249. /**
  36250. * Will stop the animation of the given target
  36251. * @param target - the target
  36252. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36253. * @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)
  36254. */
  36255. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36256. /**
  36257. * Removes the given animation group from this scene.
  36258. * @param toRemove The animation group to remove
  36259. * @returns The index of the removed animation group
  36260. */
  36261. removeAnimationGroup(toRemove: AnimationGroup): number;
  36262. /**
  36263. * Removes the given multi-material from this scene.
  36264. * @param toRemove The multi-material to remove
  36265. * @returns The index of the removed multi-material
  36266. */
  36267. removeMultiMaterial(toRemove: MultiMaterial): number;
  36268. /**
  36269. * Removes the given material from this scene.
  36270. * @param toRemove The material to remove
  36271. * @returns The index of the removed material
  36272. */
  36273. removeMaterial(toRemove: Material): number;
  36274. /**
  36275. * Removes the given action manager from this scene.
  36276. * @param toRemove The action manager to remove
  36277. * @returns The index of the removed action manager
  36278. */
  36279. removeActionManager(toRemove: AbstractActionManager): number;
  36280. /**
  36281. * Removes the given texture from this scene.
  36282. * @param toRemove The texture to remove
  36283. * @returns The index of the removed texture
  36284. */
  36285. removeTexture(toRemove: BaseTexture): number;
  36286. /**
  36287. * Adds the given light to this scene
  36288. * @param newLight The light to add
  36289. */
  36290. addLight(newLight: Light): void;
  36291. /**
  36292. * Sorts the list list based on light priorities
  36293. */
  36294. sortLightsByPriority(): void;
  36295. /**
  36296. * Adds the given camera to this scene
  36297. * @param newCamera The camera to add
  36298. */
  36299. addCamera(newCamera: Camera): void;
  36300. /**
  36301. * Adds the given skeleton to this scene
  36302. * @param newSkeleton The skeleton to add
  36303. */
  36304. addSkeleton(newSkeleton: Skeleton): void;
  36305. /**
  36306. * Adds the given particle system to this scene
  36307. * @param newParticleSystem The particle system to add
  36308. */
  36309. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36310. /**
  36311. * Adds the given animation to this scene
  36312. * @param newAnimation The animation to add
  36313. */
  36314. addAnimation(newAnimation: Animation): void;
  36315. /**
  36316. * Adds the given animation group to this scene.
  36317. * @param newAnimationGroup The animation group to add
  36318. */
  36319. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36320. /**
  36321. * Adds the given multi-material to this scene
  36322. * @param newMultiMaterial The multi-material to add
  36323. */
  36324. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36325. /**
  36326. * Adds the given material to this scene
  36327. * @param newMaterial The material to add
  36328. */
  36329. addMaterial(newMaterial: Material): void;
  36330. /**
  36331. * Adds the given morph target to this scene
  36332. * @param newMorphTargetManager The morph target to add
  36333. */
  36334. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36335. /**
  36336. * Adds the given geometry to this scene
  36337. * @param newGeometry The geometry to add
  36338. */
  36339. addGeometry(newGeometry: Geometry): void;
  36340. /**
  36341. * Adds the given action manager to this scene
  36342. * @param newActionManager The action manager to add
  36343. */
  36344. addActionManager(newActionManager: AbstractActionManager): void;
  36345. /**
  36346. * Adds the given texture to this scene.
  36347. * @param newTexture The texture to add
  36348. */
  36349. addTexture(newTexture: BaseTexture): void;
  36350. /**
  36351. * Switch active camera
  36352. * @param newCamera defines the new active camera
  36353. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36354. */
  36355. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36356. /**
  36357. * sets the active camera of the scene using its ID
  36358. * @param id defines the camera's ID
  36359. * @return the new active camera or null if none found.
  36360. */
  36361. setActiveCameraByID(id: string): Nullable<Camera>;
  36362. /**
  36363. * sets the active camera of the scene using its name
  36364. * @param name defines the camera's name
  36365. * @returns the new active camera or null if none found.
  36366. */
  36367. setActiveCameraByName(name: string): Nullable<Camera>;
  36368. /**
  36369. * get an animation group using its name
  36370. * @param name defines the material's name
  36371. * @return the animation group or null if none found.
  36372. */
  36373. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36374. /**
  36375. * Get a material using its unique id
  36376. * @param uniqueId defines the material's unique id
  36377. * @return the material or null if none found.
  36378. */
  36379. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36380. /**
  36381. * get a material using its id
  36382. * @param id defines the material's ID
  36383. * @return the material or null if none found.
  36384. */
  36385. getMaterialByID(id: string): Nullable<Material>;
  36386. /**
  36387. * Gets a the last added material using a given id
  36388. * @param id defines the material's ID
  36389. * @return the last material with the given id or null if none found.
  36390. */
  36391. getLastMaterialByID(id: string): Nullable<Material>;
  36392. /**
  36393. * Gets a material using its name
  36394. * @param name defines the material's name
  36395. * @return the material or null if none found.
  36396. */
  36397. getMaterialByName(name: string): Nullable<Material>;
  36398. /**
  36399. * Get a texture using its unique id
  36400. * @param uniqueId defines the texture's unique id
  36401. * @return the texture or null if none found.
  36402. */
  36403. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36404. /**
  36405. * Gets a camera using its id
  36406. * @param id defines the id to look for
  36407. * @returns the camera or null if not found
  36408. */
  36409. getCameraByID(id: string): Nullable<Camera>;
  36410. /**
  36411. * Gets a camera using its unique id
  36412. * @param uniqueId defines the unique id to look for
  36413. * @returns the camera or null if not found
  36414. */
  36415. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36416. /**
  36417. * Gets a camera using its name
  36418. * @param name defines the camera's name
  36419. * @return the camera or null if none found.
  36420. */
  36421. getCameraByName(name: string): Nullable<Camera>;
  36422. /**
  36423. * Gets a bone using its id
  36424. * @param id defines the bone's id
  36425. * @return the bone or null if not found
  36426. */
  36427. getBoneByID(id: string): Nullable<Bone>;
  36428. /**
  36429. * Gets a bone using its id
  36430. * @param name defines the bone's name
  36431. * @return the bone or null if not found
  36432. */
  36433. getBoneByName(name: string): Nullable<Bone>;
  36434. /**
  36435. * Gets a light node using its name
  36436. * @param name defines the the light's name
  36437. * @return the light or null if none found.
  36438. */
  36439. getLightByName(name: string): Nullable<Light>;
  36440. /**
  36441. * Gets a light node using its id
  36442. * @param id defines the light's id
  36443. * @return the light or null if none found.
  36444. */
  36445. getLightByID(id: string): Nullable<Light>;
  36446. /**
  36447. * Gets a light node using its scene-generated unique ID
  36448. * @param uniqueId defines the light's unique id
  36449. * @return the light or null if none found.
  36450. */
  36451. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36452. /**
  36453. * Gets a particle system by id
  36454. * @param id defines the particle system id
  36455. * @return the corresponding system or null if none found
  36456. */
  36457. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36458. /**
  36459. * Gets a geometry using its ID
  36460. * @param id defines the geometry's id
  36461. * @return the geometry or null if none found.
  36462. */
  36463. getGeometryByID(id: string): Nullable<Geometry>;
  36464. private _getGeometryByUniqueID;
  36465. /**
  36466. * Add a new geometry to this scene
  36467. * @param geometry defines the geometry to be added to the scene.
  36468. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36469. * @return a boolean defining if the geometry was added or not
  36470. */
  36471. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36472. /**
  36473. * Removes an existing geometry
  36474. * @param geometry defines the geometry to be removed from the scene
  36475. * @return a boolean defining if the geometry was removed or not
  36476. */
  36477. removeGeometry(geometry: Geometry): boolean;
  36478. /**
  36479. * Gets the list of geometries attached to the scene
  36480. * @returns an array of Geometry
  36481. */
  36482. getGeometries(): Geometry[];
  36483. /**
  36484. * Gets the first added mesh found of a given ID
  36485. * @param id defines the id to search for
  36486. * @return the mesh found or null if not found at all
  36487. */
  36488. getMeshByID(id: string): Nullable<AbstractMesh>;
  36489. /**
  36490. * Gets a list of meshes using their id
  36491. * @param id defines the id to search for
  36492. * @returns a list of meshes
  36493. */
  36494. getMeshesByID(id: string): Array<AbstractMesh>;
  36495. /**
  36496. * Gets the first added transform node found of a given ID
  36497. * @param id defines the id to search for
  36498. * @return the found transform node or null if not found at all.
  36499. */
  36500. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36501. /**
  36502. * Gets a transform node with its auto-generated unique id
  36503. * @param uniqueId efines the unique id to search for
  36504. * @return the found transform node or null if not found at all.
  36505. */
  36506. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36507. /**
  36508. * Gets a list of transform nodes using their id
  36509. * @param id defines the id to search for
  36510. * @returns a list of transform nodes
  36511. */
  36512. getTransformNodesByID(id: string): Array<TransformNode>;
  36513. /**
  36514. * Gets a mesh with its auto-generated unique id
  36515. * @param uniqueId defines the unique id to search for
  36516. * @return the found mesh or null if not found at all.
  36517. */
  36518. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36519. /**
  36520. * Gets a the last added mesh using a given id
  36521. * @param id defines the id to search for
  36522. * @return the found mesh or null if not found at all.
  36523. */
  36524. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36525. /**
  36526. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36527. * @param id defines the id to search for
  36528. * @return the found node or null if not found at all
  36529. */
  36530. getLastEntryByID(id: string): Nullable<Node>;
  36531. /**
  36532. * Gets a node (Mesh, Camera, Light) using a given id
  36533. * @param id defines the id to search for
  36534. * @return the found node or null if not found at all
  36535. */
  36536. getNodeByID(id: string): Nullable<Node>;
  36537. /**
  36538. * Gets a node (Mesh, Camera, Light) using a given name
  36539. * @param name defines the name to search for
  36540. * @return the found node or null if not found at all.
  36541. */
  36542. getNodeByName(name: string): Nullable<Node>;
  36543. /**
  36544. * Gets a mesh using a given name
  36545. * @param name defines the name to search for
  36546. * @return the found mesh or null if not found at all.
  36547. */
  36548. getMeshByName(name: string): Nullable<AbstractMesh>;
  36549. /**
  36550. * Gets a transform node using a given name
  36551. * @param name defines the name to search for
  36552. * @return the found transform node or null if not found at all.
  36553. */
  36554. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36555. /**
  36556. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36557. * @param id defines the id to search for
  36558. * @return the found skeleton or null if not found at all.
  36559. */
  36560. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36561. /**
  36562. * Gets a skeleton using a given auto generated unique id
  36563. * @param uniqueId defines the unique id to search for
  36564. * @return the found skeleton or null if not found at all.
  36565. */
  36566. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36567. /**
  36568. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36569. * @param id defines the id to search for
  36570. * @return the found skeleton or null if not found at all.
  36571. */
  36572. getSkeletonById(id: string): Nullable<Skeleton>;
  36573. /**
  36574. * Gets a skeleton using a given name
  36575. * @param name defines the name to search for
  36576. * @return the found skeleton or null if not found at all.
  36577. */
  36578. getSkeletonByName(name: string): Nullable<Skeleton>;
  36579. /**
  36580. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36581. * @param id defines the id to search for
  36582. * @return the found morph target manager or null if not found at all.
  36583. */
  36584. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36585. /**
  36586. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36587. * @param id defines the id to search for
  36588. * @return the found morph target or null if not found at all.
  36589. */
  36590. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36591. /**
  36592. * Gets a boolean indicating if the given mesh is active
  36593. * @param mesh defines the mesh to look for
  36594. * @returns true if the mesh is in the active list
  36595. */
  36596. isActiveMesh(mesh: AbstractMesh): boolean;
  36597. /**
  36598. * Return a unique id as a string which can serve as an identifier for the scene
  36599. */
  36600. get uid(): string;
  36601. /**
  36602. * Add an externaly attached data from its key.
  36603. * This method call will fail and return false, if such key already exists.
  36604. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36605. * @param key the unique key that identifies the data
  36606. * @param data the data object to associate to the key for this Engine instance
  36607. * @return true if no such key were already present and the data was added successfully, false otherwise
  36608. */
  36609. addExternalData<T>(key: string, data: T): boolean;
  36610. /**
  36611. * Get an externaly attached data from its key
  36612. * @param key the unique key that identifies the data
  36613. * @return the associated data, if present (can be null), or undefined if not present
  36614. */
  36615. getExternalData<T>(key: string): Nullable<T>;
  36616. /**
  36617. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36618. * @param key the unique key that identifies the data
  36619. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36620. * @return the associated data, can be null if the factory returned null.
  36621. */
  36622. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36623. /**
  36624. * Remove an externaly attached data from the Engine instance
  36625. * @param key the unique key that identifies the data
  36626. * @return true if the data was successfully removed, false if it doesn't exist
  36627. */
  36628. removeExternalData(key: string): boolean;
  36629. private _evaluateSubMesh;
  36630. /**
  36631. * Clear the processed materials smart array preventing retention point in material dispose.
  36632. */
  36633. freeProcessedMaterials(): void;
  36634. private _preventFreeActiveMeshesAndRenderingGroups;
  36635. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36636. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36637. * when disposing several meshes in a row or a hierarchy of meshes.
  36638. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36639. */
  36640. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36641. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36642. /**
  36643. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36644. */
  36645. freeActiveMeshes(): void;
  36646. /**
  36647. * Clear the info related to rendering groups preventing retention points during dispose.
  36648. */
  36649. freeRenderingGroups(): void;
  36650. /** @hidden */
  36651. _isInIntermediateRendering(): boolean;
  36652. /**
  36653. * Lambda returning the list of potentially active meshes.
  36654. */
  36655. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36656. /**
  36657. * Lambda returning the list of potentially active sub meshes.
  36658. */
  36659. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36660. /**
  36661. * Lambda returning the list of potentially intersecting sub meshes.
  36662. */
  36663. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36664. /**
  36665. * Lambda returning the list of potentially colliding sub meshes.
  36666. */
  36667. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36668. private _activeMeshesFrozen;
  36669. private _skipEvaluateActiveMeshesCompletely;
  36670. /**
  36671. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36672. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36673. * @returns the current scene
  36674. */
  36675. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36676. /**
  36677. * Use this function to restart evaluating active meshes on every frame
  36678. * @returns the current scene
  36679. */
  36680. unfreezeActiveMeshes(): Scene;
  36681. private _evaluateActiveMeshes;
  36682. private _activeMesh;
  36683. /**
  36684. * Update the transform matrix to update from the current active camera
  36685. * @param force defines a boolean used to force the update even if cache is up to date
  36686. */
  36687. updateTransformMatrix(force?: boolean): void;
  36688. private _bindFrameBuffer;
  36689. /** @hidden */
  36690. _allowPostProcessClearColor: boolean;
  36691. /** @hidden */
  36692. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36693. private _processSubCameras;
  36694. private _checkIntersections;
  36695. /** @hidden */
  36696. _advancePhysicsEngineStep(step: number): void;
  36697. /**
  36698. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36699. */
  36700. getDeterministicFrameTime: () => number;
  36701. /** @hidden */
  36702. _animate(): void;
  36703. /** Execute all animations (for a frame) */
  36704. animate(): void;
  36705. /**
  36706. * Render the scene
  36707. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36708. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36709. */
  36710. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36711. /**
  36712. * Freeze all materials
  36713. * A frozen material will not be updatable but should be faster to render
  36714. */
  36715. freezeMaterials(): void;
  36716. /**
  36717. * Unfreeze all materials
  36718. * A frozen material will not be updatable but should be faster to render
  36719. */
  36720. unfreezeMaterials(): void;
  36721. /**
  36722. * Releases all held ressources
  36723. */
  36724. dispose(): void;
  36725. /**
  36726. * Gets if the scene is already disposed
  36727. */
  36728. get isDisposed(): boolean;
  36729. /**
  36730. * Call this function to reduce memory footprint of the scene.
  36731. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36732. */
  36733. clearCachedVertexData(): void;
  36734. /**
  36735. * This function will remove the local cached buffer data from texture.
  36736. * It will save memory but will prevent the texture from being rebuilt
  36737. */
  36738. cleanCachedTextureBuffer(): void;
  36739. /**
  36740. * Get the world extend vectors with an optional filter
  36741. *
  36742. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36743. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36744. */
  36745. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36746. min: Vector3;
  36747. max: Vector3;
  36748. };
  36749. /**
  36750. * Creates a ray that can be used to pick in the scene
  36751. * @param x defines the x coordinate of the origin (on-screen)
  36752. * @param y defines the y coordinate of the origin (on-screen)
  36753. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36754. * @param camera defines the camera to use for the picking
  36755. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36756. * @returns a Ray
  36757. */
  36758. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36759. /**
  36760. * Creates a ray that can be used to pick in the scene
  36761. * @param x defines the x coordinate of the origin (on-screen)
  36762. * @param y defines the y coordinate of the origin (on-screen)
  36763. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36764. * @param result defines the ray where to store the picking ray
  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 the current scene
  36768. */
  36769. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  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 camera defines the camera to use for the picking
  36775. * @returns a Ray
  36776. */
  36777. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36778. /**
  36779. * Creates a ray that can be used to pick in the scene
  36780. * @param x defines the x coordinate of the origin (on-screen)
  36781. * @param y defines the y coordinate of the origin (on-screen)
  36782. * @param result defines the ray where to store the picking ray
  36783. * @param camera defines the camera to use for the picking
  36784. * @returns the current scene
  36785. */
  36786. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36787. /** Launch a ray to try to pick a mesh in the scene
  36788. * @param x position on screen
  36789. * @param y position on screen
  36790. * @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
  36791. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36792. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36793. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36794. * @returns a PickingInfo
  36795. */
  36796. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36797. /** Use the given ray to pick a mesh in the scene
  36798. * @param ray The ray to use to pick meshes
  36799. * @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
  36800. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36801. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36802. * @returns a PickingInfo
  36803. */
  36804. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36805. /**
  36806. * Launch a ray to try to pick a mesh in the scene
  36807. * @param x X position on screen
  36808. * @param y Y position on screen
  36809. * @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
  36810. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36811. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36812. * @returns an array of PickingInfo
  36813. */
  36814. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36815. /**
  36816. * Launch a ray to try to pick a mesh in the scene
  36817. * @param ray Ray to use
  36818. * @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
  36819. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36820. * @returns an array of PickingInfo
  36821. */
  36822. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36823. /**
  36824. * Force the value of meshUnderPointer
  36825. * @param mesh defines the mesh to use
  36826. */
  36827. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36828. /**
  36829. * Gets the mesh under the pointer
  36830. * @returns a Mesh or null if no mesh is under the pointer
  36831. */
  36832. getPointerOverMesh(): Nullable<AbstractMesh>;
  36833. /** @hidden */
  36834. _rebuildGeometries(): void;
  36835. /** @hidden */
  36836. _rebuildTextures(): void;
  36837. private _getByTags;
  36838. /**
  36839. * Get a list of meshes by tags
  36840. * @param tagsQuery defines the tags query to use
  36841. * @param forEach defines a predicate used to filter results
  36842. * @returns an array of Mesh
  36843. */
  36844. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36845. /**
  36846. * Get a list of cameras by tags
  36847. * @param tagsQuery defines the tags query to use
  36848. * @param forEach defines a predicate used to filter results
  36849. * @returns an array of Camera
  36850. */
  36851. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36852. /**
  36853. * Get a list of lights by tags
  36854. * @param tagsQuery defines the tags query to use
  36855. * @param forEach defines a predicate used to filter results
  36856. * @returns an array of Light
  36857. */
  36858. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36859. /**
  36860. * Get a list of materials by tags
  36861. * @param tagsQuery defines the tags query to use
  36862. * @param forEach defines a predicate used to filter results
  36863. * @returns an array of Material
  36864. */
  36865. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36866. /**
  36867. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36868. * This allowed control for front to back rendering or reversly depending of the special needs.
  36869. *
  36870. * @param renderingGroupId The rendering group id corresponding to its index
  36871. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36872. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36873. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36874. */
  36875. 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;
  36876. /**
  36877. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36878. *
  36879. * @param renderingGroupId The rendering group id corresponding to its index
  36880. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36881. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36882. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36883. */
  36884. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36885. /**
  36886. * Gets the current auto clear configuration for one rendering group of the rendering
  36887. * manager.
  36888. * @param index the rendering group index to get the information for
  36889. * @returns The auto clear setup for the requested rendering group
  36890. */
  36891. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36892. private _blockMaterialDirtyMechanism;
  36893. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36894. get blockMaterialDirtyMechanism(): boolean;
  36895. set blockMaterialDirtyMechanism(value: boolean);
  36896. /**
  36897. * Will flag all materials as dirty to trigger new shader compilation
  36898. * @param flag defines the flag used to specify which material part must be marked as dirty
  36899. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36900. */
  36901. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36902. /** @hidden */
  36903. _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;
  36904. /** @hidden */
  36905. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36906. /** @hidden */
  36907. _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;
  36908. /** @hidden */
  36909. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36910. /** @hidden */
  36911. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36912. /** @hidden */
  36913. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36914. }
  36915. }
  36916. declare module BABYLON {
  36917. /**
  36918. * Set of assets to keep when moving a scene into an asset container.
  36919. */
  36920. export class KeepAssets extends AbstractScene {
  36921. }
  36922. /**
  36923. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36924. */
  36925. export class InstantiatedEntries {
  36926. /**
  36927. * List of new root nodes (eg. nodes with no parent)
  36928. */
  36929. rootNodes: TransformNode[];
  36930. /**
  36931. * List of new skeletons
  36932. */
  36933. skeletons: Skeleton[];
  36934. /**
  36935. * List of new animation groups
  36936. */
  36937. animationGroups: AnimationGroup[];
  36938. }
  36939. /**
  36940. * Container with a set of assets that can be added or removed from a scene.
  36941. */
  36942. export class AssetContainer extends AbstractScene {
  36943. private _wasAddedToScene;
  36944. /**
  36945. * The scene the AssetContainer belongs to.
  36946. */
  36947. scene: Scene;
  36948. /**
  36949. * Instantiates an AssetContainer.
  36950. * @param scene The scene the AssetContainer belongs to.
  36951. */
  36952. constructor(scene: Scene);
  36953. /**
  36954. * Instantiate or clone all meshes and add the new ones to the scene.
  36955. * Skeletons and animation groups will all be cloned
  36956. * @param nameFunction defines an optional function used to get new names for clones
  36957. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36958. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36959. */
  36960. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36961. /**
  36962. * Adds all the assets from the container to the scene.
  36963. */
  36964. addAllToScene(): void;
  36965. /**
  36966. * Removes all the assets in the container from the scene
  36967. */
  36968. removeAllFromScene(): void;
  36969. /**
  36970. * Disposes all the assets in the container
  36971. */
  36972. dispose(): void;
  36973. private _moveAssets;
  36974. /**
  36975. * Removes all the assets contained in the scene and adds them to the container.
  36976. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36977. */
  36978. moveAllFromScene(keepAssets?: KeepAssets): void;
  36979. /**
  36980. * 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.
  36981. * @returns the root mesh
  36982. */
  36983. createRootMesh(): Mesh;
  36984. /**
  36985. * Merge animations from this asset container into a scene
  36986. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36987. * @param animatables set of animatables to retarget to a node from the scene
  36988. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36989. */
  36990. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36991. }
  36992. }
  36993. declare module BABYLON {
  36994. /**
  36995. * Defines how the parser contract is defined.
  36996. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36997. */
  36998. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36999. /**
  37000. * Defines how the individual parser contract is defined.
  37001. * These parser can parse an individual asset
  37002. */
  37003. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37004. /**
  37005. * Base class of the scene acting as a container for the different elements composing a scene.
  37006. * This class is dynamically extended by the different components of the scene increasing
  37007. * flexibility and reducing coupling
  37008. */
  37009. export abstract class AbstractScene {
  37010. /**
  37011. * Stores the list of available parsers in the application.
  37012. */
  37013. private static _BabylonFileParsers;
  37014. /**
  37015. * Stores the list of available individual parsers in the application.
  37016. */
  37017. private static _IndividualBabylonFileParsers;
  37018. /**
  37019. * Adds a parser in the list of available ones
  37020. * @param name Defines the name of the parser
  37021. * @param parser Defines the parser to add
  37022. */
  37023. static AddParser(name: string, parser: BabylonFileParser): void;
  37024. /**
  37025. * Gets a general parser from the list of avaialble ones
  37026. * @param name Defines the name of the parser
  37027. * @returns the requested parser or null
  37028. */
  37029. static GetParser(name: string): Nullable<BabylonFileParser>;
  37030. /**
  37031. * Adds n individual parser in the list of available ones
  37032. * @param name Defines the name of the parser
  37033. * @param parser Defines the parser to add
  37034. */
  37035. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37036. /**
  37037. * Gets an individual parser from the list of avaialble ones
  37038. * @param name Defines the name of the parser
  37039. * @returns the requested parser or null
  37040. */
  37041. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37042. /**
  37043. * Parser json data and populate both a scene and its associated container object
  37044. * @param jsonData Defines the data to parse
  37045. * @param scene Defines the scene to parse the data for
  37046. * @param container Defines the container attached to the parsing sequence
  37047. * @param rootUrl Defines the root url of the data
  37048. */
  37049. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37050. /**
  37051. * Gets the list of root nodes (ie. nodes with no parent)
  37052. */
  37053. rootNodes: Node[];
  37054. /** All of the cameras added to this scene
  37055. * @see http://doc.babylonjs.com/babylon101/cameras
  37056. */
  37057. cameras: Camera[];
  37058. /**
  37059. * All of the lights added to this scene
  37060. * @see http://doc.babylonjs.com/babylon101/lights
  37061. */
  37062. lights: Light[];
  37063. /**
  37064. * All of the (abstract) meshes added to this scene
  37065. */
  37066. meshes: AbstractMesh[];
  37067. /**
  37068. * The list of skeletons added to the scene
  37069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37070. */
  37071. skeletons: Skeleton[];
  37072. /**
  37073. * All of the particle systems added to this scene
  37074. * @see http://doc.babylonjs.com/babylon101/particles
  37075. */
  37076. particleSystems: IParticleSystem[];
  37077. /**
  37078. * Gets a list of Animations associated with the scene
  37079. */
  37080. animations: Animation[];
  37081. /**
  37082. * All of the animation groups added to this scene
  37083. * @see http://doc.babylonjs.com/how_to/group
  37084. */
  37085. animationGroups: AnimationGroup[];
  37086. /**
  37087. * All of the multi-materials added to this scene
  37088. * @see http://doc.babylonjs.com/how_to/multi_materials
  37089. */
  37090. multiMaterials: MultiMaterial[];
  37091. /**
  37092. * All of the materials added to this scene
  37093. * In the context of a Scene, it is not supposed to be modified manually.
  37094. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37095. * Note also that the order of the Material within the array is not significant and might change.
  37096. * @see http://doc.babylonjs.com/babylon101/materials
  37097. */
  37098. materials: Material[];
  37099. /**
  37100. * The list of morph target managers added to the scene
  37101. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37102. */
  37103. morphTargetManagers: MorphTargetManager[];
  37104. /**
  37105. * The list of geometries used in the scene.
  37106. */
  37107. geometries: Geometry[];
  37108. /**
  37109. * All of the tranform nodes added to this scene
  37110. * In the context of a Scene, it is not supposed to be modified manually.
  37111. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37112. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37113. * @see http://doc.babylonjs.com/how_to/transformnode
  37114. */
  37115. transformNodes: TransformNode[];
  37116. /**
  37117. * ActionManagers available on the scene.
  37118. */
  37119. actionManagers: AbstractActionManager[];
  37120. /**
  37121. * Textures to keep.
  37122. */
  37123. textures: BaseTexture[];
  37124. /**
  37125. * Environment texture for the scene
  37126. */
  37127. environmentTexture: Nullable<BaseTexture>;
  37128. /**
  37129. * @returns all meshes, lights, cameras, transformNodes and bones
  37130. */
  37131. getNodes(): Array<Node>;
  37132. }
  37133. }
  37134. declare module BABYLON {
  37135. /**
  37136. * Interface used to define options for Sound class
  37137. */
  37138. export interface ISoundOptions {
  37139. /**
  37140. * Does the sound autoplay once loaded.
  37141. */
  37142. autoplay?: boolean;
  37143. /**
  37144. * Does the sound loop after it finishes playing once.
  37145. */
  37146. loop?: boolean;
  37147. /**
  37148. * Sound's volume
  37149. */
  37150. volume?: number;
  37151. /**
  37152. * Is it a spatial sound?
  37153. */
  37154. spatialSound?: boolean;
  37155. /**
  37156. * Maximum distance to hear that sound
  37157. */
  37158. maxDistance?: number;
  37159. /**
  37160. * Uses user defined attenuation function
  37161. */
  37162. useCustomAttenuation?: boolean;
  37163. /**
  37164. * Define the roll off factor of spatial sounds.
  37165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37166. */
  37167. rolloffFactor?: number;
  37168. /**
  37169. * Define the reference distance the sound should be heard perfectly.
  37170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37171. */
  37172. refDistance?: number;
  37173. /**
  37174. * Define the distance attenuation model the sound will follow.
  37175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37176. */
  37177. distanceModel?: string;
  37178. /**
  37179. * Defines the playback speed (1 by default)
  37180. */
  37181. playbackRate?: number;
  37182. /**
  37183. * Defines if the sound is from a streaming source
  37184. */
  37185. streaming?: boolean;
  37186. /**
  37187. * Defines an optional length (in seconds) inside the sound file
  37188. */
  37189. length?: number;
  37190. /**
  37191. * Defines an optional offset (in seconds) inside the sound file
  37192. */
  37193. offset?: number;
  37194. /**
  37195. * If true, URLs will not be required to state the audio file codec to use.
  37196. */
  37197. skipCodecCheck?: boolean;
  37198. }
  37199. /**
  37200. * Defines a sound that can be played in the application.
  37201. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37203. */
  37204. export class Sound {
  37205. /**
  37206. * The name of the sound in the scene.
  37207. */
  37208. name: string;
  37209. /**
  37210. * Does the sound autoplay once loaded.
  37211. */
  37212. autoplay: boolean;
  37213. /**
  37214. * Does the sound loop after it finishes playing once.
  37215. */
  37216. loop: boolean;
  37217. /**
  37218. * Does the sound use a custom attenuation curve to simulate the falloff
  37219. * happening when the source gets further away from the camera.
  37220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37221. */
  37222. useCustomAttenuation: boolean;
  37223. /**
  37224. * The sound track id this sound belongs to.
  37225. */
  37226. soundTrackId: number;
  37227. /**
  37228. * Is this sound currently played.
  37229. */
  37230. isPlaying: boolean;
  37231. /**
  37232. * Is this sound currently paused.
  37233. */
  37234. isPaused: boolean;
  37235. /**
  37236. * Does this sound enables spatial sound.
  37237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37238. */
  37239. spatialSound: boolean;
  37240. /**
  37241. * Define the reference distance the sound should be heard perfectly.
  37242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37243. */
  37244. refDistance: number;
  37245. /**
  37246. * Define the roll off factor of spatial sounds.
  37247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37248. */
  37249. rolloffFactor: number;
  37250. /**
  37251. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37253. */
  37254. maxDistance: number;
  37255. /**
  37256. * Define the distance attenuation model the sound will follow.
  37257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37258. */
  37259. distanceModel: string;
  37260. /**
  37261. * @hidden
  37262. * Back Compat
  37263. **/
  37264. onended: () => any;
  37265. /**
  37266. * Observable event when the current playing sound finishes.
  37267. */
  37268. onEndedObservable: Observable<Sound>;
  37269. private _panningModel;
  37270. private _playbackRate;
  37271. private _streaming;
  37272. private _startTime;
  37273. private _startOffset;
  37274. private _position;
  37275. /** @hidden */
  37276. _positionInEmitterSpace: boolean;
  37277. private _localDirection;
  37278. private _volume;
  37279. private _isReadyToPlay;
  37280. private _isDirectional;
  37281. private _readyToPlayCallback;
  37282. private _audioBuffer;
  37283. private _soundSource;
  37284. private _streamingSource;
  37285. private _soundPanner;
  37286. private _soundGain;
  37287. private _inputAudioNode;
  37288. private _outputAudioNode;
  37289. private _coneInnerAngle;
  37290. private _coneOuterAngle;
  37291. private _coneOuterGain;
  37292. private _scene;
  37293. private _connectedTransformNode;
  37294. private _customAttenuationFunction;
  37295. private _registerFunc;
  37296. private _isOutputConnected;
  37297. private _htmlAudioElement;
  37298. private _urlType;
  37299. private _length?;
  37300. private _offset?;
  37301. /** @hidden */
  37302. static _SceneComponentInitialization: (scene: Scene) => void;
  37303. /**
  37304. * Create a sound and attach it to a scene
  37305. * @param name Name of your sound
  37306. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37307. * @param scene defines the scene the sound belongs to
  37308. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37309. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37310. */
  37311. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37312. /**
  37313. * Release the sound and its associated resources
  37314. */
  37315. dispose(): void;
  37316. /**
  37317. * Gets if the sounds is ready to be played or not.
  37318. * @returns true if ready, otherwise false
  37319. */
  37320. isReady(): boolean;
  37321. private _soundLoaded;
  37322. /**
  37323. * Sets the data of the sound from an audiobuffer
  37324. * @param audioBuffer The audioBuffer containing the data
  37325. */
  37326. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37327. /**
  37328. * Updates the current sounds options such as maxdistance, loop...
  37329. * @param options A JSON object containing values named as the object properties
  37330. */
  37331. updateOptions(options: ISoundOptions): void;
  37332. private _createSpatialParameters;
  37333. private _updateSpatialParameters;
  37334. /**
  37335. * Switch the panning model to HRTF:
  37336. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37338. */
  37339. switchPanningModelToHRTF(): void;
  37340. /**
  37341. * Switch the panning model to Equal Power:
  37342. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37344. */
  37345. switchPanningModelToEqualPower(): void;
  37346. private _switchPanningModel;
  37347. /**
  37348. * Connect this sound to a sound track audio node like gain...
  37349. * @param soundTrackAudioNode the sound track audio node to connect to
  37350. */
  37351. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37352. /**
  37353. * Transform this sound into a directional source
  37354. * @param coneInnerAngle Size of the inner cone in degree
  37355. * @param coneOuterAngle Size of the outer cone in degree
  37356. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37357. */
  37358. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37359. /**
  37360. * Gets or sets the inner angle for the directional cone.
  37361. */
  37362. get directionalConeInnerAngle(): number;
  37363. /**
  37364. * Gets or sets the inner angle for the directional cone.
  37365. */
  37366. set directionalConeInnerAngle(value: number);
  37367. /**
  37368. * Gets or sets the outer angle for the directional cone.
  37369. */
  37370. get directionalConeOuterAngle(): number;
  37371. /**
  37372. * Gets or sets the outer angle for the directional cone.
  37373. */
  37374. set directionalConeOuterAngle(value: number);
  37375. /**
  37376. * Sets the position of the emitter if spatial sound is enabled
  37377. * @param newPosition Defines the new posisiton
  37378. */
  37379. setPosition(newPosition: Vector3): void;
  37380. /**
  37381. * Sets the local direction of the emitter if spatial sound is enabled
  37382. * @param newLocalDirection Defines the new local direction
  37383. */
  37384. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37385. private _updateDirection;
  37386. /** @hidden */
  37387. updateDistanceFromListener(): void;
  37388. /**
  37389. * Sets a new custom attenuation function for the sound.
  37390. * @param callback Defines the function used for the attenuation
  37391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37392. */
  37393. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37394. /**
  37395. * Play the sound
  37396. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37397. * @param offset (optional) Start the sound at a specific time in seconds
  37398. * @param length (optional) Sound duration (in seconds)
  37399. */
  37400. play(time?: number, offset?: number, length?: number): void;
  37401. private _onended;
  37402. /**
  37403. * Stop the sound
  37404. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37405. */
  37406. stop(time?: number): void;
  37407. /**
  37408. * Put the sound in pause
  37409. */
  37410. pause(): void;
  37411. /**
  37412. * Sets a dedicated volume for this sounds
  37413. * @param newVolume Define the new volume of the sound
  37414. * @param time Define time for gradual change to new volume
  37415. */
  37416. setVolume(newVolume: number, time?: number): void;
  37417. /**
  37418. * Set the sound play back rate
  37419. * @param newPlaybackRate Define the playback rate the sound should be played at
  37420. */
  37421. setPlaybackRate(newPlaybackRate: number): void;
  37422. /**
  37423. * Gets the volume of the sound.
  37424. * @returns the volume of the sound
  37425. */
  37426. getVolume(): number;
  37427. /**
  37428. * Attach the sound to a dedicated mesh
  37429. * @param transformNode The transform node to connect the sound with
  37430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37431. */
  37432. attachToMesh(transformNode: TransformNode): void;
  37433. /**
  37434. * Detach the sound from the previously attached mesh
  37435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37436. */
  37437. detachFromMesh(): void;
  37438. private _onRegisterAfterWorldMatrixUpdate;
  37439. /**
  37440. * Clone the current sound in the scene.
  37441. * @returns the new sound clone
  37442. */
  37443. clone(): Nullable<Sound>;
  37444. /**
  37445. * Gets the current underlying audio buffer containing the data
  37446. * @returns the audio buffer
  37447. */
  37448. getAudioBuffer(): Nullable<AudioBuffer>;
  37449. /**
  37450. * Serializes the Sound in a JSON representation
  37451. * @returns the JSON representation of the sound
  37452. */
  37453. serialize(): any;
  37454. /**
  37455. * Parse a JSON representation of a sound to innstantiate in a given scene
  37456. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37457. * @param scene Define the scene the new parsed sound should be created in
  37458. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37459. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37460. * @returns the newly parsed sound
  37461. */
  37462. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37463. }
  37464. }
  37465. declare module BABYLON {
  37466. /**
  37467. * This defines an action helpful to play a defined sound on a triggered action.
  37468. */
  37469. export class PlaySoundAction extends Action {
  37470. private _sound;
  37471. /**
  37472. * Instantiate the action
  37473. * @param triggerOptions defines the trigger options
  37474. * @param sound defines the sound to play
  37475. * @param condition defines the trigger related conditions
  37476. */
  37477. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37478. /** @hidden */
  37479. _prepare(): void;
  37480. /**
  37481. * Execute the action and play the sound.
  37482. */
  37483. execute(): void;
  37484. /**
  37485. * Serializes the actions and its related information.
  37486. * @param parent defines the object to serialize in
  37487. * @returns the serialized object
  37488. */
  37489. serialize(parent: any): any;
  37490. }
  37491. /**
  37492. * This defines an action helpful to stop a defined sound on a triggered action.
  37493. */
  37494. export class StopSoundAction extends Action {
  37495. private _sound;
  37496. /**
  37497. * Instantiate the action
  37498. * @param triggerOptions defines the trigger options
  37499. * @param sound defines the sound to stop
  37500. * @param condition defines the trigger related conditions
  37501. */
  37502. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37503. /** @hidden */
  37504. _prepare(): void;
  37505. /**
  37506. * Execute the action and stop the sound.
  37507. */
  37508. execute(): void;
  37509. /**
  37510. * Serializes the actions and its related information.
  37511. * @param parent defines the object to serialize in
  37512. * @returns the serialized object
  37513. */
  37514. serialize(parent: any): any;
  37515. }
  37516. }
  37517. declare module BABYLON {
  37518. /**
  37519. * This defines an action responsible to change the value of a property
  37520. * by interpolating between its current value and the newly set one once triggered.
  37521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37522. */
  37523. export class InterpolateValueAction extends Action {
  37524. /**
  37525. * Defines the path of the property where the value should be interpolated
  37526. */
  37527. propertyPath: string;
  37528. /**
  37529. * Defines the target value at the end of the interpolation.
  37530. */
  37531. value: any;
  37532. /**
  37533. * Defines the time it will take for the property to interpolate to the value.
  37534. */
  37535. duration: number;
  37536. /**
  37537. * Defines if the other scene animations should be stopped when the action has been triggered
  37538. */
  37539. stopOtherAnimations?: boolean;
  37540. /**
  37541. * Defines a callback raised once the interpolation animation has been done.
  37542. */
  37543. onInterpolationDone?: () => void;
  37544. /**
  37545. * Observable triggered once the interpolation animation has been done.
  37546. */
  37547. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37548. private _target;
  37549. private _effectiveTarget;
  37550. private _property;
  37551. /**
  37552. * Instantiate the action
  37553. * @param triggerOptions defines the trigger options
  37554. * @param target defines the object containing the value to interpolate
  37555. * @param propertyPath defines the path to the property in the target object
  37556. * @param value defines the target value at the end of the interpolation
  37557. * @param duration deines the time it will take for the property to interpolate to the value.
  37558. * @param condition defines the trigger related conditions
  37559. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37560. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37561. */
  37562. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37563. /** @hidden */
  37564. _prepare(): void;
  37565. /**
  37566. * Execute the action starts the value interpolation.
  37567. */
  37568. execute(): void;
  37569. /**
  37570. * Serializes the actions and its related information.
  37571. * @param parent defines the object to serialize in
  37572. * @returns the serialized object
  37573. */
  37574. serialize(parent: any): any;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * Options allowed during the creation of a sound track.
  37580. */
  37581. export interface ISoundTrackOptions {
  37582. /**
  37583. * The volume the sound track should take during creation
  37584. */
  37585. volume?: number;
  37586. /**
  37587. * Define if the sound track is the main sound track of the scene
  37588. */
  37589. mainTrack?: boolean;
  37590. }
  37591. /**
  37592. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37593. * It will be also used in a future release to apply effects on a specific track.
  37594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37595. */
  37596. export class SoundTrack {
  37597. /**
  37598. * The unique identifier of the sound track in the scene.
  37599. */
  37600. id: number;
  37601. /**
  37602. * The list of sounds included in the sound track.
  37603. */
  37604. soundCollection: Array<Sound>;
  37605. private _outputAudioNode;
  37606. private _scene;
  37607. private _connectedAnalyser;
  37608. private _options;
  37609. private _isInitialized;
  37610. /**
  37611. * Creates a new sound track.
  37612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37613. * @param scene Define the scene the sound track belongs to
  37614. * @param options
  37615. */
  37616. constructor(scene: Scene, options?: ISoundTrackOptions);
  37617. private _initializeSoundTrackAudioGraph;
  37618. /**
  37619. * Release the sound track and its associated resources
  37620. */
  37621. dispose(): void;
  37622. /**
  37623. * Adds a sound to this sound track
  37624. * @param sound define the cound to add
  37625. * @ignoreNaming
  37626. */
  37627. AddSound(sound: Sound): void;
  37628. /**
  37629. * Removes a sound to this sound track
  37630. * @param sound define the cound to remove
  37631. * @ignoreNaming
  37632. */
  37633. RemoveSound(sound: Sound): void;
  37634. /**
  37635. * Set a global volume for the full sound track.
  37636. * @param newVolume Define the new volume of the sound track
  37637. */
  37638. setVolume(newVolume: number): void;
  37639. /**
  37640. * Switch the panning model to HRTF:
  37641. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37643. */
  37644. switchPanningModelToHRTF(): void;
  37645. /**
  37646. * Switch the panning model to Equal Power:
  37647. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37649. */
  37650. switchPanningModelToEqualPower(): void;
  37651. /**
  37652. * Connect the sound track to an audio analyser allowing some amazing
  37653. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37655. * @param analyser The analyser to connect to the engine
  37656. */
  37657. connectToAnalyser(analyser: Analyser): void;
  37658. }
  37659. }
  37660. declare module BABYLON {
  37661. interface AbstractScene {
  37662. /**
  37663. * The list of sounds used in the scene.
  37664. */
  37665. sounds: Nullable<Array<Sound>>;
  37666. }
  37667. interface Scene {
  37668. /**
  37669. * @hidden
  37670. * Backing field
  37671. */
  37672. _mainSoundTrack: SoundTrack;
  37673. /**
  37674. * The main sound track played by the scene.
  37675. * It cotains your primary collection of sounds.
  37676. */
  37677. mainSoundTrack: SoundTrack;
  37678. /**
  37679. * The list of sound tracks added to the scene
  37680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37681. */
  37682. soundTracks: Nullable<Array<SoundTrack>>;
  37683. /**
  37684. * Gets a sound using a given name
  37685. * @param name defines the name to search for
  37686. * @return the found sound or null if not found at all.
  37687. */
  37688. getSoundByName(name: string): Nullable<Sound>;
  37689. /**
  37690. * Gets or sets if audio support is enabled
  37691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37692. */
  37693. audioEnabled: boolean;
  37694. /**
  37695. * Gets or sets if audio will be output to headphones
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37697. */
  37698. headphone: boolean;
  37699. /**
  37700. * Gets or sets custom audio listener position provider
  37701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37702. */
  37703. audioListenerPositionProvider: Nullable<() => Vector3>;
  37704. /**
  37705. * Gets or sets a refresh rate when using 3D audio positioning
  37706. */
  37707. audioPositioningRefreshRate: number;
  37708. }
  37709. /**
  37710. * Defines the sound scene component responsible to manage any sounds
  37711. * in a given scene.
  37712. */
  37713. export class AudioSceneComponent implements ISceneSerializableComponent {
  37714. /**
  37715. * The component name helpfull to identify the component in the list of scene components.
  37716. */
  37717. readonly name: string;
  37718. /**
  37719. * The scene the component belongs to.
  37720. */
  37721. scene: Scene;
  37722. private _audioEnabled;
  37723. /**
  37724. * Gets whether audio is enabled or not.
  37725. * Please use related enable/disable method to switch state.
  37726. */
  37727. get audioEnabled(): boolean;
  37728. private _headphone;
  37729. /**
  37730. * Gets whether audio is outputing to headphone or not.
  37731. * Please use the according Switch methods to change output.
  37732. */
  37733. get headphone(): boolean;
  37734. /**
  37735. * Gets or sets a refresh rate when using 3D audio positioning
  37736. */
  37737. audioPositioningRefreshRate: number;
  37738. private _audioListenerPositionProvider;
  37739. /**
  37740. * Gets the current audio listener position provider
  37741. */
  37742. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37743. /**
  37744. * Sets a custom listener position for all sounds in the scene
  37745. * By default, this is the position of the first active camera
  37746. */
  37747. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37748. /**
  37749. * Creates a new instance of the component for the given scene
  37750. * @param scene Defines the scene to register the component in
  37751. */
  37752. constructor(scene: Scene);
  37753. /**
  37754. * Registers the component in a given scene
  37755. */
  37756. register(): void;
  37757. /**
  37758. * Rebuilds the elements related to this component in case of
  37759. * context lost for instance.
  37760. */
  37761. rebuild(): void;
  37762. /**
  37763. * Serializes the component data to the specified json object
  37764. * @param serializationObject The object to serialize to
  37765. */
  37766. serialize(serializationObject: any): void;
  37767. /**
  37768. * Adds all the elements from the container to the scene
  37769. * @param container the container holding the elements
  37770. */
  37771. addFromContainer(container: AbstractScene): void;
  37772. /**
  37773. * Removes all the elements in the container from the scene
  37774. * @param container contains the elements to remove
  37775. * @param dispose if the removed element should be disposed (default: false)
  37776. */
  37777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37778. /**
  37779. * Disposes the component and the associated ressources.
  37780. */
  37781. dispose(): void;
  37782. /**
  37783. * Disables audio in the associated scene.
  37784. */
  37785. disableAudio(): void;
  37786. /**
  37787. * Enables audio in the associated scene.
  37788. */
  37789. enableAudio(): void;
  37790. /**
  37791. * Switch audio to headphone output.
  37792. */
  37793. switchAudioModeForHeadphones(): void;
  37794. /**
  37795. * Switch audio to normal speakers.
  37796. */
  37797. switchAudioModeForNormalSpeakers(): void;
  37798. private _cachedCameraDirection;
  37799. private _cachedCameraPosition;
  37800. private _lastCheck;
  37801. private _afterRender;
  37802. }
  37803. }
  37804. declare module BABYLON {
  37805. /**
  37806. * Wraps one or more Sound objects and selects one with random weight for playback.
  37807. */
  37808. export class WeightedSound {
  37809. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37810. loop: boolean;
  37811. private _coneInnerAngle;
  37812. private _coneOuterAngle;
  37813. private _volume;
  37814. /** A Sound is currently playing. */
  37815. isPlaying: boolean;
  37816. /** A Sound is currently paused. */
  37817. isPaused: boolean;
  37818. private _sounds;
  37819. private _weights;
  37820. private _currentIndex?;
  37821. /**
  37822. * Creates a new WeightedSound from the list of sounds given.
  37823. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37824. * @param sounds Array of Sounds that will be selected from.
  37825. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37826. */
  37827. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37828. /**
  37829. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37830. */
  37831. get directionalConeInnerAngle(): number;
  37832. /**
  37833. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37834. */
  37835. set directionalConeInnerAngle(value: number);
  37836. /**
  37837. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37838. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37839. */
  37840. get directionalConeOuterAngle(): number;
  37841. /**
  37842. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37843. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37844. */
  37845. set directionalConeOuterAngle(value: number);
  37846. /**
  37847. * Playback volume.
  37848. */
  37849. get volume(): number;
  37850. /**
  37851. * Playback volume.
  37852. */
  37853. set volume(value: number);
  37854. private _onended;
  37855. /**
  37856. * Suspend playback
  37857. */
  37858. pause(): void;
  37859. /**
  37860. * Stop playback
  37861. */
  37862. stop(): void;
  37863. /**
  37864. * Start playback.
  37865. * @param startOffset Position the clip head at a specific time in seconds.
  37866. */
  37867. play(startOffset?: number): void;
  37868. }
  37869. }
  37870. declare module BABYLON {
  37871. /**
  37872. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37873. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37874. */
  37875. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37876. /**
  37877. * Gets the name of the behavior.
  37878. */
  37879. get name(): string;
  37880. /**
  37881. * The easing function used by animations
  37882. */
  37883. static EasingFunction: BackEase;
  37884. /**
  37885. * The easing mode used by animations
  37886. */
  37887. static EasingMode: number;
  37888. /**
  37889. * The duration of the animation, in milliseconds
  37890. */
  37891. transitionDuration: number;
  37892. /**
  37893. * Length of the distance animated by the transition when lower radius is reached
  37894. */
  37895. lowerRadiusTransitionRange: number;
  37896. /**
  37897. * Length of the distance animated by the transition when upper radius is reached
  37898. */
  37899. upperRadiusTransitionRange: number;
  37900. private _autoTransitionRange;
  37901. /**
  37902. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37903. */
  37904. get autoTransitionRange(): boolean;
  37905. /**
  37906. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37907. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37908. */
  37909. set autoTransitionRange(value: boolean);
  37910. private _attachedCamera;
  37911. private _onAfterCheckInputsObserver;
  37912. private _onMeshTargetChangedObserver;
  37913. /**
  37914. * Initializes the behavior.
  37915. */
  37916. init(): void;
  37917. /**
  37918. * Attaches the behavior to its arc rotate camera.
  37919. * @param camera Defines the camera to attach the behavior to
  37920. */
  37921. attach(camera: ArcRotateCamera): void;
  37922. /**
  37923. * Detaches the behavior from its current arc rotate camera.
  37924. */
  37925. detach(): void;
  37926. private _radiusIsAnimating;
  37927. private _radiusBounceTransition;
  37928. private _animatables;
  37929. private _cachedWheelPrecision;
  37930. /**
  37931. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37932. * @param radiusLimit The limit to check against.
  37933. * @return Bool to indicate if at limit.
  37934. */
  37935. private _isRadiusAtLimit;
  37936. /**
  37937. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37938. * @param radiusDelta The delta by which to animate to. Can be negative.
  37939. */
  37940. private _applyBoundRadiusAnimation;
  37941. /**
  37942. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37943. */
  37944. protected _clearAnimationLocks(): void;
  37945. /**
  37946. * Stops and removes all animations that have been applied to the camera
  37947. */
  37948. stopAllAnimations(): void;
  37949. }
  37950. }
  37951. declare module BABYLON {
  37952. /**
  37953. * 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.
  37954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37955. */
  37956. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37957. /**
  37958. * Gets the name of the behavior.
  37959. */
  37960. get name(): string;
  37961. private _mode;
  37962. private _radiusScale;
  37963. private _positionScale;
  37964. private _defaultElevation;
  37965. private _elevationReturnTime;
  37966. private _elevationReturnWaitTime;
  37967. private _zoomStopsAnimation;
  37968. private _framingTime;
  37969. /**
  37970. * The easing function used by animations
  37971. */
  37972. static EasingFunction: ExponentialEase;
  37973. /**
  37974. * The easing mode used by animations
  37975. */
  37976. static EasingMode: number;
  37977. /**
  37978. * Sets the current mode used by the behavior
  37979. */
  37980. set mode(mode: number);
  37981. /**
  37982. * Gets current mode used by the behavior.
  37983. */
  37984. get mode(): number;
  37985. /**
  37986. * Sets the scale applied to the radius (1 by default)
  37987. */
  37988. set radiusScale(radius: number);
  37989. /**
  37990. * Gets the scale applied to the radius
  37991. */
  37992. get radiusScale(): number;
  37993. /**
  37994. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37995. */
  37996. set positionScale(scale: number);
  37997. /**
  37998. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37999. */
  38000. get positionScale(): number;
  38001. /**
  38002. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38003. * behaviour is triggered, in radians.
  38004. */
  38005. set defaultElevation(elevation: number);
  38006. /**
  38007. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38008. * behaviour is triggered, in radians.
  38009. */
  38010. get defaultElevation(): number;
  38011. /**
  38012. * Sets the time (in milliseconds) taken to return to the default beta position.
  38013. * Negative value indicates camera should not return to default.
  38014. */
  38015. set elevationReturnTime(speed: number);
  38016. /**
  38017. * Gets the time (in milliseconds) taken to return to the default beta position.
  38018. * Negative value indicates camera should not return to default.
  38019. */
  38020. get elevationReturnTime(): number;
  38021. /**
  38022. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38023. */
  38024. set elevationReturnWaitTime(time: number);
  38025. /**
  38026. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38027. */
  38028. get elevationReturnWaitTime(): number;
  38029. /**
  38030. * Sets the flag that indicates if user zooming should stop animation.
  38031. */
  38032. set zoomStopsAnimation(flag: boolean);
  38033. /**
  38034. * Gets the flag that indicates if user zooming should stop animation.
  38035. */
  38036. get zoomStopsAnimation(): boolean;
  38037. /**
  38038. * Sets the transition time when framing the mesh, in milliseconds
  38039. */
  38040. set framingTime(time: number);
  38041. /**
  38042. * Gets the transition time when framing the mesh, in milliseconds
  38043. */
  38044. get framingTime(): number;
  38045. /**
  38046. * Define if the behavior should automatically change the configured
  38047. * camera limits and sensibilities.
  38048. */
  38049. autoCorrectCameraLimitsAndSensibility: boolean;
  38050. private _onPrePointerObservableObserver;
  38051. private _onAfterCheckInputsObserver;
  38052. private _onMeshTargetChangedObserver;
  38053. private _attachedCamera;
  38054. private _isPointerDown;
  38055. private _lastInteractionTime;
  38056. /**
  38057. * Initializes the behavior.
  38058. */
  38059. init(): void;
  38060. /**
  38061. * Attaches the behavior to its arc rotate camera.
  38062. * @param camera Defines the camera to attach the behavior to
  38063. */
  38064. attach(camera: ArcRotateCamera): void;
  38065. /**
  38066. * Detaches the behavior from its current arc rotate camera.
  38067. */
  38068. detach(): void;
  38069. private _animatables;
  38070. private _betaIsAnimating;
  38071. private _betaTransition;
  38072. private _radiusTransition;
  38073. private _vectorTransition;
  38074. /**
  38075. * Targets the given mesh and updates zoom level accordingly.
  38076. * @param mesh The mesh to target.
  38077. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38078. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38079. */
  38080. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38081. /**
  38082. * Targets the given mesh with its children and updates zoom level accordingly.
  38083. * @param mesh The mesh to target.
  38084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38086. */
  38087. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38088. /**
  38089. * Targets the given meshes with their children and updates zoom level accordingly.
  38090. * @param meshes The mesh to target.
  38091. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38092. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38093. */
  38094. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38095. /**
  38096. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38097. * @param minimumWorld Determines the smaller position of the bounding box extend
  38098. * @param maximumWorld Determines the bigger position of the bounding box extend
  38099. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38100. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38101. */
  38102. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38103. /**
  38104. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38105. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38106. * frustum width.
  38107. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38108. * to fully enclose the mesh in the viewing frustum.
  38109. */
  38110. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38111. /**
  38112. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38113. * is automatically returned to its default position (expected to be above ground plane).
  38114. */
  38115. private _maintainCameraAboveGround;
  38116. /**
  38117. * Returns the frustum slope based on the canvas ratio and camera FOV
  38118. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38119. */
  38120. private _getFrustumSlope;
  38121. /**
  38122. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38123. */
  38124. private _clearAnimationLocks;
  38125. /**
  38126. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38127. */
  38128. private _applyUserInteraction;
  38129. /**
  38130. * Stops and removes all animations that have been applied to the camera
  38131. */
  38132. stopAllAnimations(): void;
  38133. /**
  38134. * Gets a value indicating if the user is moving the camera
  38135. */
  38136. get isUserIsMoving(): boolean;
  38137. /**
  38138. * The camera can move all the way towards the mesh.
  38139. */
  38140. static IgnoreBoundsSizeMode: number;
  38141. /**
  38142. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38143. */
  38144. static FitFrustumSidesMode: number;
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. /**
  38149. * Base class for Camera Pointer Inputs.
  38150. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38151. * for example usage.
  38152. */
  38153. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38154. /**
  38155. * Defines the camera the input is attached to.
  38156. */
  38157. abstract camera: Camera;
  38158. /**
  38159. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38160. */
  38161. protected _altKey: boolean;
  38162. protected _ctrlKey: boolean;
  38163. protected _metaKey: boolean;
  38164. protected _shiftKey: boolean;
  38165. /**
  38166. * Which mouse buttons were pressed at time of last mouse event.
  38167. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38168. */
  38169. protected _buttonsPressed: number;
  38170. /**
  38171. * Defines the buttons associated with the input to handle camera move.
  38172. */
  38173. buttons: number[];
  38174. /**
  38175. * Attach the input controls to a specific dom element to get the input from.
  38176. * @param element Defines the element the controls should be listened from
  38177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38178. */
  38179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38180. /**
  38181. * Detach the current controls from the specified dom element.
  38182. * @param element Defines the element to stop listening the inputs from
  38183. */
  38184. detachControl(element: Nullable<HTMLElement>): void;
  38185. /**
  38186. * Gets the class name of the current input.
  38187. * @returns the class name
  38188. */
  38189. getClassName(): string;
  38190. /**
  38191. * Get the friendly name associated with the input class.
  38192. * @returns the input friendly name
  38193. */
  38194. getSimpleName(): string;
  38195. /**
  38196. * Called on pointer POINTERDOUBLETAP event.
  38197. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38198. */
  38199. protected onDoubleTap(type: string): void;
  38200. /**
  38201. * Called on pointer POINTERMOVE event if only a single touch is active.
  38202. * Override this method to provide functionality.
  38203. */
  38204. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38205. /**
  38206. * Called on pointer POINTERMOVE event if multiple touches are active.
  38207. * Override this method to provide functionality.
  38208. */
  38209. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38210. /**
  38211. * Called on JS contextmenu event.
  38212. * Override this method to provide functionality.
  38213. */
  38214. protected onContextMenu(evt: PointerEvent): void;
  38215. /**
  38216. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38217. * press.
  38218. * Override this method to provide functionality.
  38219. */
  38220. protected onButtonDown(evt: PointerEvent): void;
  38221. /**
  38222. * Called each time a new POINTERUP event occurs. Ie, for each button
  38223. * release.
  38224. * Override this method to provide functionality.
  38225. */
  38226. protected onButtonUp(evt: PointerEvent): void;
  38227. /**
  38228. * Called when window becomes inactive.
  38229. * Override this method to provide functionality.
  38230. */
  38231. protected onLostFocus(): void;
  38232. private _pointerInput;
  38233. private _observer;
  38234. private _onLostFocus;
  38235. private pointA;
  38236. private pointB;
  38237. }
  38238. }
  38239. declare module BABYLON {
  38240. /**
  38241. * Manage the pointers inputs to control an arc rotate camera.
  38242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38243. */
  38244. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38245. /**
  38246. * Defines the camera the input is attached to.
  38247. */
  38248. camera: ArcRotateCamera;
  38249. /**
  38250. * Gets the class name of the current input.
  38251. * @returns the class name
  38252. */
  38253. getClassName(): string;
  38254. /**
  38255. * Defines the buttons associated with the input to handle camera move.
  38256. */
  38257. buttons: number[];
  38258. /**
  38259. * Defines the pointer angular sensibility along the X axis or how fast is
  38260. * the camera rotating.
  38261. */
  38262. angularSensibilityX: number;
  38263. /**
  38264. * Defines the pointer angular sensibility along the Y axis or how fast is
  38265. * the camera rotating.
  38266. */
  38267. angularSensibilityY: number;
  38268. /**
  38269. * Defines the pointer pinch precision or how fast is the camera zooming.
  38270. */
  38271. pinchPrecision: number;
  38272. /**
  38273. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38274. * from 0.
  38275. * It defines the percentage of current camera.radius to use as delta when
  38276. * pinch zoom is used.
  38277. */
  38278. pinchDeltaPercentage: number;
  38279. /**
  38280. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38281. * that any object in the plane at the camera's target point will scale
  38282. * perfectly with finger motion.
  38283. * Overrides pinchDeltaPercentage and pinchPrecision.
  38284. */
  38285. useNaturalPinchZoom: boolean;
  38286. /**
  38287. * Defines the pointer panning sensibility or how fast is the camera moving.
  38288. */
  38289. panningSensibility: number;
  38290. /**
  38291. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38292. */
  38293. multiTouchPanning: boolean;
  38294. /**
  38295. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38296. * zoom (pinch) through multitouch.
  38297. */
  38298. multiTouchPanAndZoom: boolean;
  38299. /**
  38300. * Revers pinch action direction.
  38301. */
  38302. pinchInwards: boolean;
  38303. private _isPanClick;
  38304. private _twoFingerActivityCount;
  38305. private _isPinching;
  38306. /**
  38307. * Called on pointer POINTERMOVE event if only a single touch is active.
  38308. */
  38309. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38310. /**
  38311. * Called on pointer POINTERDOUBLETAP event.
  38312. */
  38313. protected onDoubleTap(type: string): void;
  38314. /**
  38315. * Called on pointer POINTERMOVE event if multiple touches are active.
  38316. */
  38317. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38318. /**
  38319. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38320. * press.
  38321. */
  38322. protected onButtonDown(evt: PointerEvent): void;
  38323. /**
  38324. * Called each time a new POINTERUP event occurs. Ie, for each button
  38325. * release.
  38326. */
  38327. protected onButtonUp(evt: PointerEvent): void;
  38328. /**
  38329. * Called when window becomes inactive.
  38330. */
  38331. protected onLostFocus(): void;
  38332. }
  38333. }
  38334. declare module BABYLON {
  38335. /**
  38336. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38338. */
  38339. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38340. /**
  38341. * Defines the camera the input is attached to.
  38342. */
  38343. camera: ArcRotateCamera;
  38344. /**
  38345. * Defines the list of key codes associated with the up action (increase alpha)
  38346. */
  38347. keysUp: number[];
  38348. /**
  38349. * Defines the list of key codes associated with the down action (decrease alpha)
  38350. */
  38351. keysDown: number[];
  38352. /**
  38353. * Defines the list of key codes associated with the left action (increase beta)
  38354. */
  38355. keysLeft: number[];
  38356. /**
  38357. * Defines the list of key codes associated with the right action (decrease beta)
  38358. */
  38359. keysRight: number[];
  38360. /**
  38361. * Defines the list of key codes associated with the reset action.
  38362. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38363. */
  38364. keysReset: number[];
  38365. /**
  38366. * Defines the panning sensibility of the inputs.
  38367. * (How fast is the camera panning)
  38368. */
  38369. panningSensibility: number;
  38370. /**
  38371. * Defines the zooming sensibility of the inputs.
  38372. * (How fast is the camera zooming)
  38373. */
  38374. zoomingSensibility: number;
  38375. /**
  38376. * Defines whether maintaining the alt key down switch the movement mode from
  38377. * orientation to zoom.
  38378. */
  38379. useAltToZoom: boolean;
  38380. /**
  38381. * Rotation speed of the camera
  38382. */
  38383. angularSpeed: number;
  38384. private _keys;
  38385. private _ctrlPressed;
  38386. private _altPressed;
  38387. private _onCanvasBlurObserver;
  38388. private _onKeyboardObserver;
  38389. private _engine;
  38390. private _scene;
  38391. /**
  38392. * Attach the input controls to a specific dom element to get the input from.
  38393. * @param element Defines the element the controls should be listened from
  38394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38395. */
  38396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38397. /**
  38398. * Detach the current controls from the specified dom element.
  38399. * @param element Defines the element to stop listening the inputs from
  38400. */
  38401. detachControl(element: Nullable<HTMLElement>): void;
  38402. /**
  38403. * Update the current camera state depending on the inputs that have been used this frame.
  38404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38405. */
  38406. checkInputs(): void;
  38407. /**
  38408. * Gets the class name of the current intput.
  38409. * @returns the class name
  38410. */
  38411. getClassName(): string;
  38412. /**
  38413. * Get the friendly name associated with the input class.
  38414. * @returns the input friendly name
  38415. */
  38416. getSimpleName(): string;
  38417. }
  38418. }
  38419. declare module BABYLON {
  38420. /**
  38421. * Manage the mouse wheel inputs to control an arc rotate camera.
  38422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38423. */
  38424. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38425. /**
  38426. * Defines the camera the input is attached to.
  38427. */
  38428. camera: ArcRotateCamera;
  38429. /**
  38430. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38431. */
  38432. wheelPrecision: number;
  38433. /**
  38434. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38435. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38436. */
  38437. wheelDeltaPercentage: number;
  38438. private _wheel;
  38439. private _observer;
  38440. private computeDeltaFromMouseWheelLegacyEvent;
  38441. /**
  38442. * Attach the input controls to a specific dom element to get the input from.
  38443. * @param element Defines the element the controls should be listened from
  38444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38445. */
  38446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38447. /**
  38448. * Detach the current controls from the specified dom element.
  38449. * @param element Defines the element to stop listening the inputs from
  38450. */
  38451. detachControl(element: Nullable<HTMLElement>): void;
  38452. /**
  38453. * Gets the class name of the current intput.
  38454. * @returns the class name
  38455. */
  38456. getClassName(): string;
  38457. /**
  38458. * Get the friendly name associated with the input class.
  38459. * @returns the input friendly name
  38460. */
  38461. getSimpleName(): string;
  38462. }
  38463. }
  38464. declare module BABYLON {
  38465. /**
  38466. * Default Inputs manager for the ArcRotateCamera.
  38467. * It groups all the default supported inputs for ease of use.
  38468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38469. */
  38470. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38471. /**
  38472. * Instantiates a new ArcRotateCameraInputsManager.
  38473. * @param camera Defines the camera the inputs belong to
  38474. */
  38475. constructor(camera: ArcRotateCamera);
  38476. /**
  38477. * Add mouse wheel input support to the input manager.
  38478. * @returns the current input manager
  38479. */
  38480. addMouseWheel(): ArcRotateCameraInputsManager;
  38481. /**
  38482. * Add pointers input support to the input manager.
  38483. * @returns the current input manager
  38484. */
  38485. addPointers(): ArcRotateCameraInputsManager;
  38486. /**
  38487. * Add keyboard input support to the input manager.
  38488. * @returns the current input manager
  38489. */
  38490. addKeyboard(): ArcRotateCameraInputsManager;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /**
  38495. * This represents an orbital type of camera.
  38496. *
  38497. * 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.
  38498. * 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.
  38499. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38500. */
  38501. export class ArcRotateCamera extends TargetCamera {
  38502. /**
  38503. * Defines the rotation angle of the camera along the longitudinal axis.
  38504. */
  38505. alpha: number;
  38506. /**
  38507. * Defines the rotation angle of the camera along the latitudinal axis.
  38508. */
  38509. beta: number;
  38510. /**
  38511. * Defines the radius of the camera from it s target point.
  38512. */
  38513. radius: number;
  38514. protected _target: Vector3;
  38515. protected _targetHost: Nullable<AbstractMesh>;
  38516. /**
  38517. * Defines the target point of the camera.
  38518. * The camera looks towards it form the radius distance.
  38519. */
  38520. get target(): Vector3;
  38521. set target(value: Vector3);
  38522. /**
  38523. * Define the current local position of the camera in the scene
  38524. */
  38525. get position(): Vector3;
  38526. set position(newPosition: Vector3);
  38527. protected _upVector: Vector3;
  38528. protected _upToYMatrix: Matrix;
  38529. protected _YToUpMatrix: Matrix;
  38530. /**
  38531. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38532. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38533. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38534. */
  38535. set upVector(vec: Vector3);
  38536. get upVector(): Vector3;
  38537. /**
  38538. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38539. */
  38540. setMatUp(): void;
  38541. /**
  38542. * Current inertia value on the longitudinal axis.
  38543. * The bigger this number the longer it will take for the camera to stop.
  38544. */
  38545. inertialAlphaOffset: number;
  38546. /**
  38547. * Current inertia value on the latitudinal axis.
  38548. * The bigger this number the longer it will take for the camera to stop.
  38549. */
  38550. inertialBetaOffset: number;
  38551. /**
  38552. * Current inertia value on the radius axis.
  38553. * The bigger this number the longer it will take for the camera to stop.
  38554. */
  38555. inertialRadiusOffset: number;
  38556. /**
  38557. * Minimum allowed angle on the longitudinal axis.
  38558. * This can help limiting how the Camera is able to move in the scene.
  38559. */
  38560. lowerAlphaLimit: Nullable<number>;
  38561. /**
  38562. * Maximum allowed angle on the longitudinal axis.
  38563. * This can help limiting how the Camera is able to move in the scene.
  38564. */
  38565. upperAlphaLimit: Nullable<number>;
  38566. /**
  38567. * Minimum allowed angle on the latitudinal axis.
  38568. * This can help limiting how the Camera is able to move in the scene.
  38569. */
  38570. lowerBetaLimit: number;
  38571. /**
  38572. * Maximum allowed angle on the latitudinal axis.
  38573. * This can help limiting how the Camera is able to move in the scene.
  38574. */
  38575. upperBetaLimit: number;
  38576. /**
  38577. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38578. * This can help limiting how the Camera is able to move in the scene.
  38579. */
  38580. lowerRadiusLimit: Nullable<number>;
  38581. /**
  38582. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38583. * This can help limiting how the Camera is able to move in the scene.
  38584. */
  38585. upperRadiusLimit: Nullable<number>;
  38586. /**
  38587. * Defines the current inertia value used during panning of the camera along the X axis.
  38588. */
  38589. inertialPanningX: number;
  38590. /**
  38591. * Defines the current inertia value used during panning of the camera along the Y axis.
  38592. */
  38593. inertialPanningY: number;
  38594. /**
  38595. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38596. * Basically if your fingers moves away from more than this distance you will be considered
  38597. * in pinch mode.
  38598. */
  38599. pinchToPanMaxDistance: number;
  38600. /**
  38601. * Defines the maximum distance the camera can pan.
  38602. * This could help keeping the cammera always in your scene.
  38603. */
  38604. panningDistanceLimit: Nullable<number>;
  38605. /**
  38606. * Defines the target of the camera before paning.
  38607. */
  38608. panningOriginTarget: Vector3;
  38609. /**
  38610. * Defines the value of the inertia used during panning.
  38611. * 0 would mean stop inertia and one would mean no decelleration at all.
  38612. */
  38613. panningInertia: number;
  38614. /**
  38615. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38616. */
  38617. get angularSensibilityX(): number;
  38618. set angularSensibilityX(value: number);
  38619. /**
  38620. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38621. */
  38622. get angularSensibilityY(): number;
  38623. set angularSensibilityY(value: number);
  38624. /**
  38625. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38626. */
  38627. get pinchPrecision(): number;
  38628. set pinchPrecision(value: number);
  38629. /**
  38630. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38631. * It will be used instead of pinchDeltaPrecision if different from 0.
  38632. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38633. */
  38634. get pinchDeltaPercentage(): number;
  38635. set pinchDeltaPercentage(value: number);
  38636. /**
  38637. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38638. * and pinch delta percentage.
  38639. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38640. * that any object in the plane at the camera's target point will scale
  38641. * perfectly with finger motion.
  38642. */
  38643. get useNaturalPinchZoom(): boolean;
  38644. set useNaturalPinchZoom(value: boolean);
  38645. /**
  38646. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38647. */
  38648. get panningSensibility(): number;
  38649. set panningSensibility(value: number);
  38650. /**
  38651. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38652. */
  38653. get keysUp(): number[];
  38654. set keysUp(value: number[]);
  38655. /**
  38656. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38657. */
  38658. get keysDown(): number[];
  38659. set keysDown(value: number[]);
  38660. /**
  38661. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38662. */
  38663. get keysLeft(): number[];
  38664. set keysLeft(value: number[]);
  38665. /**
  38666. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38667. */
  38668. get keysRight(): number[];
  38669. set keysRight(value: number[]);
  38670. /**
  38671. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38672. */
  38673. get wheelPrecision(): number;
  38674. set wheelPrecision(value: number);
  38675. /**
  38676. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38677. * It will be used instead of pinchDeltaPrecision if different from 0.
  38678. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38679. */
  38680. get wheelDeltaPercentage(): number;
  38681. set wheelDeltaPercentage(value: number);
  38682. /**
  38683. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38684. */
  38685. zoomOnFactor: number;
  38686. /**
  38687. * Defines a screen offset for the camera position.
  38688. */
  38689. targetScreenOffset: Vector2;
  38690. /**
  38691. * Allows the camera to be completely reversed.
  38692. * If false the camera can not arrive upside down.
  38693. */
  38694. allowUpsideDown: boolean;
  38695. /**
  38696. * Define if double tap/click is used to restore the previously saved state of the camera.
  38697. */
  38698. useInputToRestoreState: boolean;
  38699. /** @hidden */
  38700. _viewMatrix: Matrix;
  38701. /** @hidden */
  38702. _useCtrlForPanning: boolean;
  38703. /** @hidden */
  38704. _panningMouseButton: number;
  38705. /**
  38706. * Defines the input associated to the camera.
  38707. */
  38708. inputs: ArcRotateCameraInputsManager;
  38709. /** @hidden */
  38710. _reset: () => void;
  38711. /**
  38712. * Defines the allowed panning axis.
  38713. */
  38714. panningAxis: Vector3;
  38715. protected _localDirection: Vector3;
  38716. protected _transformedDirection: Vector3;
  38717. private _bouncingBehavior;
  38718. /**
  38719. * Gets the bouncing behavior of the camera if it has been enabled.
  38720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38721. */
  38722. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38723. /**
  38724. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38726. */
  38727. get useBouncingBehavior(): boolean;
  38728. set useBouncingBehavior(value: boolean);
  38729. private _framingBehavior;
  38730. /**
  38731. * Gets the framing behavior of the camera if it has been enabled.
  38732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38733. */
  38734. get framingBehavior(): Nullable<FramingBehavior>;
  38735. /**
  38736. * Defines if the framing behavior of the camera is enabled on the camera.
  38737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38738. */
  38739. get useFramingBehavior(): boolean;
  38740. set useFramingBehavior(value: boolean);
  38741. private _autoRotationBehavior;
  38742. /**
  38743. * Gets the auto rotation behavior of the camera if it has been enabled.
  38744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38745. */
  38746. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38747. /**
  38748. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38750. */
  38751. get useAutoRotationBehavior(): boolean;
  38752. set useAutoRotationBehavior(value: boolean);
  38753. /**
  38754. * Observable triggered when the mesh target has been changed on the camera.
  38755. */
  38756. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38757. /**
  38758. * Event raised when the camera is colliding with a mesh.
  38759. */
  38760. onCollide: (collidedMesh: AbstractMesh) => void;
  38761. /**
  38762. * Defines whether the camera should check collision with the objects oh the scene.
  38763. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38764. */
  38765. checkCollisions: boolean;
  38766. /**
  38767. * Defines the collision radius of the camera.
  38768. * This simulates a sphere around the camera.
  38769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38770. */
  38771. collisionRadius: Vector3;
  38772. protected _collider: Collider;
  38773. protected _previousPosition: Vector3;
  38774. protected _collisionVelocity: Vector3;
  38775. protected _newPosition: Vector3;
  38776. protected _previousAlpha: number;
  38777. protected _previousBeta: number;
  38778. protected _previousRadius: number;
  38779. protected _collisionTriggered: boolean;
  38780. protected _targetBoundingCenter: Nullable<Vector3>;
  38781. private _computationVector;
  38782. /**
  38783. * Instantiates a new ArcRotateCamera in a given scene
  38784. * @param name Defines the name of the camera
  38785. * @param alpha Defines the camera rotation along the logitudinal axis
  38786. * @param beta Defines the camera rotation along the latitudinal axis
  38787. * @param radius Defines the camera distance from its target
  38788. * @param target Defines the camera target
  38789. * @param scene Defines the scene the camera belongs to
  38790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38791. */
  38792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38793. /** @hidden */
  38794. _initCache(): void;
  38795. /** @hidden */
  38796. _updateCache(ignoreParentClass?: boolean): void;
  38797. protected _getTargetPosition(): Vector3;
  38798. private _storedAlpha;
  38799. private _storedBeta;
  38800. private _storedRadius;
  38801. private _storedTarget;
  38802. private _storedTargetScreenOffset;
  38803. /**
  38804. * Stores the current state of the camera (alpha, beta, radius and target)
  38805. * @returns the camera itself
  38806. */
  38807. storeState(): Camera;
  38808. /**
  38809. * @hidden
  38810. * Restored camera state. You must call storeState() first
  38811. */
  38812. _restoreStateValues(): boolean;
  38813. /** @hidden */
  38814. _isSynchronizedViewMatrix(): boolean;
  38815. /**
  38816. * Attached controls to the current camera.
  38817. * @param element Defines the element the controls should be listened from
  38818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38819. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38820. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38821. */
  38822. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38823. /**
  38824. * Detach the current controls from the camera.
  38825. * The camera will stop reacting to inputs.
  38826. * @param element Defines the element to stop listening the inputs from
  38827. */
  38828. detachControl(element: HTMLElement): void;
  38829. /** @hidden */
  38830. _checkInputs(): void;
  38831. protected _checkLimits(): void;
  38832. /**
  38833. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38834. */
  38835. rebuildAnglesAndRadius(): void;
  38836. /**
  38837. * Use a position to define the current camera related information like alpha, beta and radius
  38838. * @param position Defines the position to set the camera at
  38839. */
  38840. setPosition(position: Vector3): void;
  38841. /**
  38842. * Defines the target the camera should look at.
  38843. * This will automatically adapt alpha beta and radius to fit within the new target.
  38844. * @param target Defines the new target as a Vector or a mesh
  38845. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38846. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38847. */
  38848. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38849. /** @hidden */
  38850. _getViewMatrix(): Matrix;
  38851. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38852. /**
  38853. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38854. * @param meshes Defines the mesh to zoom on
  38855. * @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)
  38856. */
  38857. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38858. /**
  38859. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38860. * The target will be changed but the radius
  38861. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38862. * @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)
  38863. */
  38864. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38865. min: Vector3;
  38866. max: Vector3;
  38867. distance: number;
  38868. }, doNotUpdateMaxZ?: boolean): void;
  38869. /**
  38870. * @override
  38871. * Override Camera.createRigCamera
  38872. */
  38873. createRigCamera(name: string, cameraIndex: number): Camera;
  38874. /**
  38875. * @hidden
  38876. * @override
  38877. * Override Camera._updateRigCameras
  38878. */
  38879. _updateRigCameras(): void;
  38880. /**
  38881. * Destroy the camera and release the current resources hold by it.
  38882. */
  38883. dispose(): void;
  38884. /**
  38885. * Gets the current object class name.
  38886. * @return the class name
  38887. */
  38888. getClassName(): string;
  38889. }
  38890. }
  38891. declare module BABYLON {
  38892. /**
  38893. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38895. */
  38896. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38897. /**
  38898. * Gets the name of the behavior.
  38899. */
  38900. get name(): string;
  38901. private _zoomStopsAnimation;
  38902. private _idleRotationSpeed;
  38903. private _idleRotationWaitTime;
  38904. private _idleRotationSpinupTime;
  38905. /**
  38906. * Sets the flag that indicates if user zooming should stop animation.
  38907. */
  38908. set zoomStopsAnimation(flag: boolean);
  38909. /**
  38910. * Gets the flag that indicates if user zooming should stop animation.
  38911. */
  38912. get zoomStopsAnimation(): boolean;
  38913. /**
  38914. * Sets the default speed at which the camera rotates around the model.
  38915. */
  38916. set idleRotationSpeed(speed: number);
  38917. /**
  38918. * Gets the default speed at which the camera rotates around the model.
  38919. */
  38920. get idleRotationSpeed(): number;
  38921. /**
  38922. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38923. */
  38924. set idleRotationWaitTime(time: number);
  38925. /**
  38926. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38927. */
  38928. get idleRotationWaitTime(): number;
  38929. /**
  38930. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38931. */
  38932. set idleRotationSpinupTime(time: number);
  38933. /**
  38934. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38935. */
  38936. get idleRotationSpinupTime(): number;
  38937. /**
  38938. * Gets a value indicating if the camera is currently rotating because of this behavior
  38939. */
  38940. get rotationInProgress(): boolean;
  38941. private _onPrePointerObservableObserver;
  38942. private _onAfterCheckInputsObserver;
  38943. private _attachedCamera;
  38944. private _isPointerDown;
  38945. private _lastFrameTime;
  38946. private _lastInteractionTime;
  38947. private _cameraRotationSpeed;
  38948. /**
  38949. * Initializes the behavior.
  38950. */
  38951. init(): void;
  38952. /**
  38953. * Attaches the behavior to its arc rotate camera.
  38954. * @param camera Defines the camera to attach the behavior to
  38955. */
  38956. attach(camera: ArcRotateCamera): void;
  38957. /**
  38958. * Detaches the behavior from its current arc rotate camera.
  38959. */
  38960. detach(): void;
  38961. /**
  38962. * Returns true if user is scrolling.
  38963. * @return true if user is scrolling.
  38964. */
  38965. private _userIsZooming;
  38966. private _lastFrameRadius;
  38967. private _shouldAnimationStopForInteraction;
  38968. /**
  38969. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38970. */
  38971. private _applyUserInteraction;
  38972. private _userIsMoving;
  38973. }
  38974. }
  38975. declare module BABYLON {
  38976. /**
  38977. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38978. */
  38979. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38980. private ui;
  38981. /**
  38982. * The name of the behavior
  38983. */
  38984. name: string;
  38985. /**
  38986. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38987. */
  38988. distanceAwayFromFace: number;
  38989. /**
  38990. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38991. */
  38992. distanceAwayFromBottomOfFace: number;
  38993. private _faceVectors;
  38994. private _target;
  38995. private _scene;
  38996. private _onRenderObserver;
  38997. private _tmpMatrix;
  38998. private _tmpVector;
  38999. /**
  39000. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39001. * @param ui The transform node that should be attched to the mesh
  39002. */
  39003. constructor(ui: TransformNode);
  39004. /**
  39005. * Initializes the behavior
  39006. */
  39007. init(): void;
  39008. private _closestFace;
  39009. private _zeroVector;
  39010. private _lookAtTmpMatrix;
  39011. private _lookAtToRef;
  39012. /**
  39013. * Attaches the AttachToBoxBehavior to the passed in mesh
  39014. * @param target The mesh that the specified node will be attached to
  39015. */
  39016. attach(target: Mesh): void;
  39017. /**
  39018. * Detaches the behavior from the mesh
  39019. */
  39020. detach(): void;
  39021. }
  39022. }
  39023. declare module BABYLON {
  39024. /**
  39025. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39026. */
  39027. export class FadeInOutBehavior implements Behavior<Mesh> {
  39028. /**
  39029. * Time in milliseconds to delay before fading in (Default: 0)
  39030. */
  39031. delay: number;
  39032. /**
  39033. * Time in milliseconds for the mesh to fade in (Default: 300)
  39034. */
  39035. fadeInTime: number;
  39036. private _millisecondsPerFrame;
  39037. private _hovered;
  39038. private _hoverValue;
  39039. private _ownerNode;
  39040. /**
  39041. * Instatiates the FadeInOutBehavior
  39042. */
  39043. constructor();
  39044. /**
  39045. * The name of the behavior
  39046. */
  39047. get name(): string;
  39048. /**
  39049. * Initializes the behavior
  39050. */
  39051. init(): void;
  39052. /**
  39053. * Attaches the fade behavior on the passed in mesh
  39054. * @param ownerNode The mesh that will be faded in/out once attached
  39055. */
  39056. attach(ownerNode: Mesh): void;
  39057. /**
  39058. * Detaches the behavior from the mesh
  39059. */
  39060. detach(): void;
  39061. /**
  39062. * Triggers the mesh to begin fading in or out
  39063. * @param value if the object should fade in or out (true to fade in)
  39064. */
  39065. fadeIn(value: boolean): void;
  39066. private _update;
  39067. private _setAllVisibility;
  39068. }
  39069. }
  39070. declare module BABYLON {
  39071. /**
  39072. * Class containing a set of static utilities functions for managing Pivots
  39073. * @hidden
  39074. */
  39075. export class PivotTools {
  39076. private static _PivotCached;
  39077. private static _OldPivotPoint;
  39078. private static _PivotTranslation;
  39079. private static _PivotTmpVector;
  39080. /** @hidden */
  39081. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39082. /** @hidden */
  39083. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39084. }
  39085. }
  39086. declare module BABYLON {
  39087. /**
  39088. * Class containing static functions to help procedurally build meshes
  39089. */
  39090. export class PlaneBuilder {
  39091. /**
  39092. * Creates a plane mesh
  39093. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39094. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39095. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39097. * * 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
  39098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39099. * @param name defines the name of the mesh
  39100. * @param options defines the options used to create the mesh
  39101. * @param scene defines the hosting scene
  39102. * @returns the plane mesh
  39103. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39104. */
  39105. static CreatePlane(name: string, options: {
  39106. size?: number;
  39107. width?: number;
  39108. height?: number;
  39109. sideOrientation?: number;
  39110. frontUVs?: Vector4;
  39111. backUVs?: Vector4;
  39112. updatable?: boolean;
  39113. sourcePlane?: Plane;
  39114. }, scene?: Nullable<Scene>): Mesh;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39120. */
  39121. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39122. private static _AnyMouseID;
  39123. /**
  39124. * Abstract mesh the behavior is set on
  39125. */
  39126. attachedNode: AbstractMesh;
  39127. private _dragPlane;
  39128. private _scene;
  39129. private _pointerObserver;
  39130. private _beforeRenderObserver;
  39131. private static _planeScene;
  39132. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39133. /**
  39134. * 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)
  39135. */
  39136. maxDragAngle: number;
  39137. /**
  39138. * @hidden
  39139. */
  39140. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39141. /**
  39142. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39143. */
  39144. currentDraggingPointerID: number;
  39145. /**
  39146. * The last position where the pointer hit the drag plane in world space
  39147. */
  39148. lastDragPosition: Vector3;
  39149. /**
  39150. * If the behavior is currently in a dragging state
  39151. */
  39152. dragging: boolean;
  39153. /**
  39154. * 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)
  39155. */
  39156. dragDeltaRatio: number;
  39157. /**
  39158. * If the drag plane orientation should be updated during the dragging (Default: true)
  39159. */
  39160. updateDragPlane: boolean;
  39161. private _debugMode;
  39162. private _moving;
  39163. /**
  39164. * Fires each time the attached mesh is dragged with the pointer
  39165. * * delta between last drag position and current drag position in world space
  39166. * * dragDistance along the drag axis
  39167. * * dragPlaneNormal normal of the current drag plane used during the drag
  39168. * * dragPlanePoint in world space where the drag intersects the drag plane
  39169. */
  39170. onDragObservable: Observable<{
  39171. delta: Vector3;
  39172. dragPlanePoint: Vector3;
  39173. dragPlaneNormal: Vector3;
  39174. dragDistance: number;
  39175. pointerId: number;
  39176. }>;
  39177. /**
  39178. * Fires each time a drag begins (eg. mouse down on mesh)
  39179. */
  39180. onDragStartObservable: Observable<{
  39181. dragPlanePoint: Vector3;
  39182. pointerId: number;
  39183. }>;
  39184. /**
  39185. * Fires each time a drag ends (eg. mouse release after drag)
  39186. */
  39187. onDragEndObservable: Observable<{
  39188. dragPlanePoint: Vector3;
  39189. pointerId: number;
  39190. }>;
  39191. /**
  39192. * If the attached mesh should be moved when dragged
  39193. */
  39194. moveAttached: boolean;
  39195. /**
  39196. * If the drag behavior will react to drag events (Default: true)
  39197. */
  39198. enabled: boolean;
  39199. /**
  39200. * If pointer events should start and release the drag (Default: true)
  39201. */
  39202. startAndReleaseDragOnPointerEvents: boolean;
  39203. /**
  39204. * If camera controls should be detached during the drag
  39205. */
  39206. detachCameraControls: boolean;
  39207. /**
  39208. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39209. */
  39210. useObjectOrientationForDragging: boolean;
  39211. private _options;
  39212. /**
  39213. * Gets the options used by the behavior
  39214. */
  39215. get options(): {
  39216. dragAxis?: Vector3;
  39217. dragPlaneNormal?: Vector3;
  39218. };
  39219. /**
  39220. * Sets the options used by the behavior
  39221. */
  39222. set options(options: {
  39223. dragAxis?: Vector3;
  39224. dragPlaneNormal?: Vector3;
  39225. });
  39226. /**
  39227. * Creates a pointer drag behavior that can be attached to a mesh
  39228. * @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)
  39229. */
  39230. constructor(options?: {
  39231. dragAxis?: Vector3;
  39232. dragPlaneNormal?: Vector3;
  39233. });
  39234. /**
  39235. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39236. */
  39237. validateDrag: (targetPosition: Vector3) => boolean;
  39238. /**
  39239. * The name of the behavior
  39240. */
  39241. get name(): string;
  39242. /**
  39243. * Initializes the behavior
  39244. */
  39245. init(): void;
  39246. private _tmpVector;
  39247. private _alternatePickedPoint;
  39248. private _worldDragAxis;
  39249. private _targetPosition;
  39250. private _attachedElement;
  39251. /**
  39252. * Attaches the drag behavior the passed in mesh
  39253. * @param ownerNode The mesh that will be dragged around once attached
  39254. * @param predicate Predicate to use for pick filtering
  39255. */
  39256. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39257. /**
  39258. * Force relase the drag action by code.
  39259. */
  39260. releaseDrag(): void;
  39261. private _startDragRay;
  39262. private _lastPointerRay;
  39263. /**
  39264. * Simulates the start of a pointer drag event on the behavior
  39265. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39266. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39267. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39268. */
  39269. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39270. private _startDrag;
  39271. private _dragDelta;
  39272. private _moveDrag;
  39273. private _pickWithRayOnDragPlane;
  39274. private _pointA;
  39275. private _pointB;
  39276. private _pointC;
  39277. private _lineA;
  39278. private _lineB;
  39279. private _localAxis;
  39280. private _lookAt;
  39281. private _updateDragPlanePosition;
  39282. /**
  39283. * Detaches the behavior from the mesh
  39284. */
  39285. detach(): void;
  39286. }
  39287. }
  39288. declare module BABYLON {
  39289. /**
  39290. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39291. */
  39292. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39293. private _dragBehaviorA;
  39294. private _dragBehaviorB;
  39295. private _startDistance;
  39296. private _initialScale;
  39297. private _targetScale;
  39298. private _ownerNode;
  39299. private _sceneRenderObserver;
  39300. /**
  39301. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39302. */
  39303. constructor();
  39304. /**
  39305. * The name of the behavior
  39306. */
  39307. get name(): string;
  39308. /**
  39309. * Initializes the behavior
  39310. */
  39311. init(): void;
  39312. private _getCurrentDistance;
  39313. /**
  39314. * Attaches the scale behavior the passed in mesh
  39315. * @param ownerNode The mesh that will be scaled around once attached
  39316. */
  39317. attach(ownerNode: Mesh): void;
  39318. /**
  39319. * Detaches the behavior from the mesh
  39320. */
  39321. detach(): void;
  39322. }
  39323. }
  39324. declare module BABYLON {
  39325. /**
  39326. * 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
  39327. */
  39328. export class SixDofDragBehavior implements Behavior<Mesh> {
  39329. private static _virtualScene;
  39330. private _ownerNode;
  39331. private _sceneRenderObserver;
  39332. private _scene;
  39333. private _targetPosition;
  39334. private _virtualOriginMesh;
  39335. private _virtualDragMesh;
  39336. private _pointerObserver;
  39337. private _moving;
  39338. private _startingOrientation;
  39339. /**
  39340. * 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)
  39341. */
  39342. private zDragFactor;
  39343. /**
  39344. * If the object should rotate to face the drag origin
  39345. */
  39346. rotateDraggedObject: boolean;
  39347. /**
  39348. * If the behavior is currently in a dragging state
  39349. */
  39350. dragging: boolean;
  39351. /**
  39352. * 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)
  39353. */
  39354. dragDeltaRatio: number;
  39355. /**
  39356. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39357. */
  39358. currentDraggingPointerID: number;
  39359. /**
  39360. * If camera controls should be detached during the drag
  39361. */
  39362. detachCameraControls: boolean;
  39363. /**
  39364. * Fires each time a drag starts
  39365. */
  39366. onDragStartObservable: Observable<{}>;
  39367. /**
  39368. * Fires each time a drag ends (eg. mouse release after drag)
  39369. */
  39370. onDragEndObservable: Observable<{}>;
  39371. /**
  39372. * 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
  39373. */
  39374. constructor();
  39375. /**
  39376. * The name of the behavior
  39377. */
  39378. get name(): string;
  39379. /**
  39380. * Initializes the behavior
  39381. */
  39382. init(): void;
  39383. /**
  39384. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39385. */
  39386. private get _pointerCamera();
  39387. /**
  39388. * Attaches the scale behavior the passed in mesh
  39389. * @param ownerNode The mesh that will be scaled around once attached
  39390. */
  39391. attach(ownerNode: Mesh): void;
  39392. /**
  39393. * Detaches the behavior from the mesh
  39394. */
  39395. detach(): void;
  39396. }
  39397. }
  39398. declare module BABYLON {
  39399. /**
  39400. * Class used to apply inverse kinematics to bones
  39401. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39402. */
  39403. export class BoneIKController {
  39404. private static _tmpVecs;
  39405. private static _tmpQuat;
  39406. private static _tmpMats;
  39407. /**
  39408. * Gets or sets the target mesh
  39409. */
  39410. targetMesh: AbstractMesh;
  39411. /** Gets or sets the mesh used as pole */
  39412. poleTargetMesh: AbstractMesh;
  39413. /**
  39414. * Gets or sets the bone used as pole
  39415. */
  39416. poleTargetBone: Nullable<Bone>;
  39417. /**
  39418. * Gets or sets the target position
  39419. */
  39420. targetPosition: Vector3;
  39421. /**
  39422. * Gets or sets the pole target position
  39423. */
  39424. poleTargetPosition: Vector3;
  39425. /**
  39426. * Gets or sets the pole target local offset
  39427. */
  39428. poleTargetLocalOffset: Vector3;
  39429. /**
  39430. * Gets or sets the pole angle
  39431. */
  39432. poleAngle: number;
  39433. /**
  39434. * Gets or sets the mesh associated with the controller
  39435. */
  39436. mesh: AbstractMesh;
  39437. /**
  39438. * 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)
  39439. */
  39440. slerpAmount: number;
  39441. private _bone1Quat;
  39442. private _bone1Mat;
  39443. private _bone2Ang;
  39444. private _bone1;
  39445. private _bone2;
  39446. private _bone1Length;
  39447. private _bone2Length;
  39448. private _maxAngle;
  39449. private _maxReach;
  39450. private _rightHandedSystem;
  39451. private _bendAxis;
  39452. private _slerping;
  39453. private _adjustRoll;
  39454. /**
  39455. * Gets or sets maximum allowed angle
  39456. */
  39457. get maxAngle(): number;
  39458. set maxAngle(value: number);
  39459. /**
  39460. * Creates a new BoneIKController
  39461. * @param mesh defines the mesh to control
  39462. * @param bone defines the bone to control
  39463. * @param options defines options to set up the controller
  39464. */
  39465. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39466. targetMesh?: AbstractMesh;
  39467. poleTargetMesh?: AbstractMesh;
  39468. poleTargetBone?: Bone;
  39469. poleTargetLocalOffset?: Vector3;
  39470. poleAngle?: number;
  39471. bendAxis?: Vector3;
  39472. maxAngle?: number;
  39473. slerpAmount?: number;
  39474. });
  39475. private _setMaxAngle;
  39476. /**
  39477. * Force the controller to update the bones
  39478. */
  39479. update(): void;
  39480. }
  39481. }
  39482. declare module BABYLON {
  39483. /**
  39484. * Class used to make a bone look toward a point in space
  39485. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39486. */
  39487. export class BoneLookController {
  39488. private static _tmpVecs;
  39489. private static _tmpQuat;
  39490. private static _tmpMats;
  39491. /**
  39492. * The target Vector3 that the bone will look at
  39493. */
  39494. target: Vector3;
  39495. /**
  39496. * The mesh that the bone is attached to
  39497. */
  39498. mesh: AbstractMesh;
  39499. /**
  39500. * The bone that will be looking to the target
  39501. */
  39502. bone: Bone;
  39503. /**
  39504. * The up axis of the coordinate system that is used when the bone is rotated
  39505. */
  39506. upAxis: Vector3;
  39507. /**
  39508. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39509. */
  39510. upAxisSpace: Space;
  39511. /**
  39512. * Used to make an adjustment to the yaw of the bone
  39513. */
  39514. adjustYaw: number;
  39515. /**
  39516. * Used to make an adjustment to the pitch of the bone
  39517. */
  39518. adjustPitch: number;
  39519. /**
  39520. * Used to make an adjustment to the roll of the bone
  39521. */
  39522. adjustRoll: number;
  39523. /**
  39524. * 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)
  39525. */
  39526. slerpAmount: number;
  39527. private _minYaw;
  39528. private _maxYaw;
  39529. private _minPitch;
  39530. private _maxPitch;
  39531. private _minYawSin;
  39532. private _minYawCos;
  39533. private _maxYawSin;
  39534. private _maxYawCos;
  39535. private _midYawConstraint;
  39536. private _minPitchTan;
  39537. private _maxPitchTan;
  39538. private _boneQuat;
  39539. private _slerping;
  39540. private _transformYawPitch;
  39541. private _transformYawPitchInv;
  39542. private _firstFrameSkipped;
  39543. private _yawRange;
  39544. private _fowardAxis;
  39545. /**
  39546. * Gets or sets the minimum yaw angle that the bone can look to
  39547. */
  39548. get minYaw(): number;
  39549. set minYaw(value: number);
  39550. /**
  39551. * Gets or sets the maximum yaw angle that the bone can look to
  39552. */
  39553. get maxYaw(): number;
  39554. set maxYaw(value: number);
  39555. /**
  39556. * Gets or sets the minimum pitch angle that the bone can look to
  39557. */
  39558. get minPitch(): number;
  39559. set minPitch(value: number);
  39560. /**
  39561. * Gets or sets the maximum pitch angle that the bone can look to
  39562. */
  39563. get maxPitch(): number;
  39564. set maxPitch(value: number);
  39565. /**
  39566. * Create a BoneLookController
  39567. * @param mesh the mesh that the bone belongs to
  39568. * @param bone the bone that will be looking to the target
  39569. * @param target the target Vector3 to look at
  39570. * @param options optional settings:
  39571. * * maxYaw: the maximum angle the bone will yaw to
  39572. * * minYaw: the minimum angle the bone will yaw to
  39573. * * maxPitch: the maximum angle the bone will pitch to
  39574. * * minPitch: the minimum angle the bone will yaw to
  39575. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39576. * * upAxis: the up axis of the coordinate system
  39577. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39578. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39579. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39580. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39581. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39582. * * adjustRoll: used to make an adjustment to the roll of the bone
  39583. **/
  39584. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39585. maxYaw?: number;
  39586. minYaw?: number;
  39587. maxPitch?: number;
  39588. minPitch?: number;
  39589. slerpAmount?: number;
  39590. upAxis?: Vector3;
  39591. upAxisSpace?: Space;
  39592. yawAxis?: Vector3;
  39593. pitchAxis?: Vector3;
  39594. adjustYaw?: number;
  39595. adjustPitch?: number;
  39596. adjustRoll?: number;
  39597. });
  39598. /**
  39599. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39600. */
  39601. update(): void;
  39602. private _getAngleDiff;
  39603. private _getAngleBetween;
  39604. private _isAngleBetween;
  39605. }
  39606. }
  39607. declare module BABYLON {
  39608. /**
  39609. * Manage the gamepad inputs to control an arc rotate camera.
  39610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39611. */
  39612. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39613. /**
  39614. * Defines the camera the input is attached to.
  39615. */
  39616. camera: ArcRotateCamera;
  39617. /**
  39618. * Defines the gamepad the input is gathering event from.
  39619. */
  39620. gamepad: Nullable<Gamepad>;
  39621. /**
  39622. * Defines the gamepad rotation sensiblity.
  39623. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39624. */
  39625. gamepadRotationSensibility: number;
  39626. /**
  39627. * Defines the gamepad move sensiblity.
  39628. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39629. */
  39630. gamepadMoveSensibility: number;
  39631. private _yAxisScale;
  39632. /**
  39633. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39634. */
  39635. get invertYAxis(): boolean;
  39636. set invertYAxis(value: boolean);
  39637. private _onGamepadConnectedObserver;
  39638. private _onGamepadDisconnectedObserver;
  39639. /**
  39640. * Attach the input controls to a specific dom element to get the input from.
  39641. * @param element Defines the element the controls should be listened from
  39642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39643. */
  39644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39645. /**
  39646. * Detach the current controls from the specified dom element.
  39647. * @param element Defines the element to stop listening the inputs from
  39648. */
  39649. detachControl(element: Nullable<HTMLElement>): void;
  39650. /**
  39651. * Update the current camera state depending on the inputs that have been used this frame.
  39652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39653. */
  39654. checkInputs(): void;
  39655. /**
  39656. * Gets the class name of the current intput.
  39657. * @returns the class name
  39658. */
  39659. getClassName(): string;
  39660. /**
  39661. * Get the friendly name associated with the input class.
  39662. * @returns the input friendly name
  39663. */
  39664. getSimpleName(): string;
  39665. }
  39666. }
  39667. declare module BABYLON {
  39668. interface ArcRotateCameraInputsManager {
  39669. /**
  39670. * Add orientation input support to the input manager.
  39671. * @returns the current input manager
  39672. */
  39673. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39674. }
  39675. /**
  39676. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39678. */
  39679. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39680. /**
  39681. * Defines the camera the input is attached to.
  39682. */
  39683. camera: ArcRotateCamera;
  39684. /**
  39685. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39686. */
  39687. alphaCorrection: number;
  39688. /**
  39689. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39690. */
  39691. gammaCorrection: number;
  39692. private _alpha;
  39693. private _gamma;
  39694. private _dirty;
  39695. private _deviceOrientationHandler;
  39696. /**
  39697. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39698. */
  39699. constructor();
  39700. /**
  39701. * Attach the input controls to a specific dom element to get the input from.
  39702. * @param element Defines the element the controls should be listened from
  39703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39704. */
  39705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39706. /** @hidden */
  39707. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39708. /**
  39709. * Update the current camera state depending on the inputs that have been used this frame.
  39710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39711. */
  39712. checkInputs(): void;
  39713. /**
  39714. * Detach the current controls from the specified dom element.
  39715. * @param element Defines the element to stop listening the inputs from
  39716. */
  39717. detachControl(element: Nullable<HTMLElement>): void;
  39718. /**
  39719. * Gets the class name of the current intput.
  39720. * @returns the class name
  39721. */
  39722. getClassName(): string;
  39723. /**
  39724. * Get the friendly name associated with the input class.
  39725. * @returns the input friendly name
  39726. */
  39727. getSimpleName(): string;
  39728. }
  39729. }
  39730. declare module BABYLON {
  39731. /**
  39732. * Listen to mouse events to control the camera.
  39733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39734. */
  39735. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39736. /**
  39737. * Defines the camera the input is attached to.
  39738. */
  39739. camera: FlyCamera;
  39740. /**
  39741. * Defines if touch is enabled. (Default is true.)
  39742. */
  39743. touchEnabled: boolean;
  39744. /**
  39745. * Defines the buttons associated with the input to handle camera rotation.
  39746. */
  39747. buttons: number[];
  39748. /**
  39749. * Assign buttons for Yaw control.
  39750. */
  39751. buttonsYaw: number[];
  39752. /**
  39753. * Assign buttons for Pitch control.
  39754. */
  39755. buttonsPitch: number[];
  39756. /**
  39757. * Assign buttons for Roll control.
  39758. */
  39759. buttonsRoll: number[];
  39760. /**
  39761. * Detect if any button is being pressed while mouse is moved.
  39762. * -1 = Mouse locked.
  39763. * 0 = Left button.
  39764. * 1 = Middle Button.
  39765. * 2 = Right Button.
  39766. */
  39767. activeButton: number;
  39768. /**
  39769. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39770. * Higher values reduce its sensitivity.
  39771. */
  39772. angularSensibility: number;
  39773. private _mousemoveCallback;
  39774. private _observer;
  39775. private _rollObserver;
  39776. private previousPosition;
  39777. private noPreventDefault;
  39778. private element;
  39779. /**
  39780. * Listen to mouse events to control the camera.
  39781. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39783. */
  39784. constructor(touchEnabled?: boolean);
  39785. /**
  39786. * Attach the mouse control to the HTML DOM element.
  39787. * @param element Defines the element that listens to the input events.
  39788. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39789. */
  39790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39791. /**
  39792. * Detach the current controls from the specified dom element.
  39793. * @param element Defines the element to stop listening the inputs from
  39794. */
  39795. detachControl(element: Nullable<HTMLElement>): void;
  39796. /**
  39797. * Gets the class name of the current input.
  39798. * @returns the class name.
  39799. */
  39800. getClassName(): string;
  39801. /**
  39802. * Get the friendly name associated with the input class.
  39803. * @returns the input's friendly name.
  39804. */
  39805. getSimpleName(): string;
  39806. private _pointerInput;
  39807. private _onMouseMove;
  39808. /**
  39809. * Rotate camera by mouse offset.
  39810. */
  39811. private rotateCamera;
  39812. }
  39813. }
  39814. declare module BABYLON {
  39815. /**
  39816. * Default Inputs manager for the FlyCamera.
  39817. * It groups all the default supported inputs for ease of use.
  39818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39819. */
  39820. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39821. /**
  39822. * Instantiates a new FlyCameraInputsManager.
  39823. * @param camera Defines the camera the inputs belong to.
  39824. */
  39825. constructor(camera: FlyCamera);
  39826. /**
  39827. * Add keyboard input support to the input manager.
  39828. * @returns the new FlyCameraKeyboardMoveInput().
  39829. */
  39830. addKeyboard(): FlyCameraInputsManager;
  39831. /**
  39832. * Add mouse input support to the input manager.
  39833. * @param touchEnabled Enable touch screen support.
  39834. * @returns the new FlyCameraMouseInput().
  39835. */
  39836. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39837. }
  39838. }
  39839. declare module BABYLON {
  39840. /**
  39841. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39842. * such as in a 3D Space Shooter or a Flight Simulator.
  39843. */
  39844. export class FlyCamera extends TargetCamera {
  39845. /**
  39846. * Define the collision ellipsoid of the camera.
  39847. * This is helpful for simulating a camera body, like a player's body.
  39848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39849. */
  39850. ellipsoid: Vector3;
  39851. /**
  39852. * Define an offset for the position of the ellipsoid around the camera.
  39853. * This can be helpful if the camera is attached away from the player's body center,
  39854. * such as at its head.
  39855. */
  39856. ellipsoidOffset: Vector3;
  39857. /**
  39858. * Enable or disable collisions of the camera with the rest of the scene objects.
  39859. */
  39860. checkCollisions: boolean;
  39861. /**
  39862. * Enable or disable gravity on the camera.
  39863. */
  39864. applyGravity: boolean;
  39865. /**
  39866. * Define the current direction the camera is moving to.
  39867. */
  39868. cameraDirection: Vector3;
  39869. /**
  39870. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39871. * This overrides and empties cameraRotation.
  39872. */
  39873. rotationQuaternion: Quaternion;
  39874. /**
  39875. * Track Roll to maintain the wanted Rolling when looking around.
  39876. */
  39877. _trackRoll: number;
  39878. /**
  39879. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39880. */
  39881. rollCorrect: number;
  39882. /**
  39883. * Mimic a banked turn, Rolling the camera when Yawing.
  39884. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39885. */
  39886. bankedTurn: boolean;
  39887. /**
  39888. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39889. */
  39890. bankedTurnLimit: number;
  39891. /**
  39892. * Value of 0 disables the banked Roll.
  39893. * Value of 1 is equal to the Yaw angle in radians.
  39894. */
  39895. bankedTurnMultiplier: number;
  39896. /**
  39897. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39898. */
  39899. inputs: FlyCameraInputsManager;
  39900. /**
  39901. * Gets the input sensibility for mouse input.
  39902. * Higher values reduce sensitivity.
  39903. */
  39904. get angularSensibility(): number;
  39905. /**
  39906. * Sets the input sensibility for a mouse input.
  39907. * Higher values reduce sensitivity.
  39908. */
  39909. set angularSensibility(value: number);
  39910. /**
  39911. * Get the keys for camera movement forward.
  39912. */
  39913. get keysForward(): number[];
  39914. /**
  39915. * Set the keys for camera movement forward.
  39916. */
  39917. set keysForward(value: number[]);
  39918. /**
  39919. * Get the keys for camera movement backward.
  39920. */
  39921. get keysBackward(): number[];
  39922. set keysBackward(value: number[]);
  39923. /**
  39924. * Get the keys for camera movement up.
  39925. */
  39926. get keysUp(): number[];
  39927. /**
  39928. * Set the keys for camera movement up.
  39929. */
  39930. set keysUp(value: number[]);
  39931. /**
  39932. * Get the keys for camera movement down.
  39933. */
  39934. get keysDown(): number[];
  39935. /**
  39936. * Set the keys for camera movement down.
  39937. */
  39938. set keysDown(value: number[]);
  39939. /**
  39940. * Get the keys for camera movement left.
  39941. */
  39942. get keysLeft(): number[];
  39943. /**
  39944. * Set the keys for camera movement left.
  39945. */
  39946. set keysLeft(value: number[]);
  39947. /**
  39948. * Set the keys for camera movement right.
  39949. */
  39950. get keysRight(): number[];
  39951. /**
  39952. * Set the keys for camera movement right.
  39953. */
  39954. set keysRight(value: number[]);
  39955. /**
  39956. * Event raised when the camera collides with a mesh in the scene.
  39957. */
  39958. onCollide: (collidedMesh: AbstractMesh) => void;
  39959. private _collider;
  39960. private _needMoveForGravity;
  39961. private _oldPosition;
  39962. private _diffPosition;
  39963. private _newPosition;
  39964. /** @hidden */
  39965. _localDirection: Vector3;
  39966. /** @hidden */
  39967. _transformedDirection: Vector3;
  39968. /**
  39969. * Instantiates a FlyCamera.
  39970. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39971. * such as in a 3D Space Shooter or a Flight Simulator.
  39972. * @param name Define the name of the camera in the scene.
  39973. * @param position Define the starting position of the camera in the scene.
  39974. * @param scene Define the scene the camera belongs to.
  39975. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39976. */
  39977. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39978. /**
  39979. * Attach a control to the HTML DOM element.
  39980. * @param element Defines the element that listens to the input events.
  39981. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39982. */
  39983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39984. /**
  39985. * Detach a control from the HTML DOM element.
  39986. * The camera will stop reacting to that input.
  39987. * @param element Defines the element that listens to the input events.
  39988. */
  39989. detachControl(element: HTMLElement): void;
  39990. private _collisionMask;
  39991. /**
  39992. * Get the mask that the camera ignores in collision events.
  39993. */
  39994. get collisionMask(): number;
  39995. /**
  39996. * Set the mask that the camera ignores in collision events.
  39997. */
  39998. set collisionMask(mask: number);
  39999. /** @hidden */
  40000. _collideWithWorld(displacement: Vector3): void;
  40001. /** @hidden */
  40002. private _onCollisionPositionChange;
  40003. /** @hidden */
  40004. _checkInputs(): void;
  40005. /** @hidden */
  40006. _decideIfNeedsToMove(): boolean;
  40007. /** @hidden */
  40008. _updatePosition(): void;
  40009. /**
  40010. * Restore the Roll to its target value at the rate specified.
  40011. * @param rate - Higher means slower restoring.
  40012. * @hidden
  40013. */
  40014. restoreRoll(rate: number): void;
  40015. /**
  40016. * Destroy the camera and release the current resources held by it.
  40017. */
  40018. dispose(): void;
  40019. /**
  40020. * Get the current object class name.
  40021. * @returns the class name.
  40022. */
  40023. getClassName(): string;
  40024. }
  40025. }
  40026. declare module BABYLON {
  40027. /**
  40028. * Listen to keyboard events to control the camera.
  40029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40030. */
  40031. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40032. /**
  40033. * Defines the camera the input is attached to.
  40034. */
  40035. camera: FlyCamera;
  40036. /**
  40037. * The list of keyboard keys used to control the forward move of the camera.
  40038. */
  40039. keysForward: number[];
  40040. /**
  40041. * The list of keyboard keys used to control the backward move of the camera.
  40042. */
  40043. keysBackward: number[];
  40044. /**
  40045. * The list of keyboard keys used to control the forward move of the camera.
  40046. */
  40047. keysUp: number[];
  40048. /**
  40049. * The list of keyboard keys used to control the backward move of the camera.
  40050. */
  40051. keysDown: number[];
  40052. /**
  40053. * The list of keyboard keys used to control the right strafe move of the camera.
  40054. */
  40055. keysRight: number[];
  40056. /**
  40057. * The list of keyboard keys used to control the left strafe move of the camera.
  40058. */
  40059. keysLeft: number[];
  40060. private _keys;
  40061. private _onCanvasBlurObserver;
  40062. private _onKeyboardObserver;
  40063. private _engine;
  40064. private _scene;
  40065. /**
  40066. * Attach the input controls to a specific dom element to get the input from.
  40067. * @param element Defines the element the controls should be listened from
  40068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40069. */
  40070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40071. /**
  40072. * Detach the current controls from the specified dom element.
  40073. * @param element Defines the element to stop listening the inputs from
  40074. */
  40075. detachControl(element: Nullable<HTMLElement>): void;
  40076. /**
  40077. * Gets the class name of the current intput.
  40078. * @returns the class name
  40079. */
  40080. getClassName(): string;
  40081. /** @hidden */
  40082. _onLostFocus(e: FocusEvent): void;
  40083. /**
  40084. * Get the friendly name associated with the input class.
  40085. * @returns the input friendly name
  40086. */
  40087. getSimpleName(): string;
  40088. /**
  40089. * Update the current camera state depending on the inputs that have been used this frame.
  40090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40091. */
  40092. checkInputs(): void;
  40093. }
  40094. }
  40095. declare module BABYLON {
  40096. /**
  40097. * Manage the mouse wheel inputs to control a follow camera.
  40098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40099. */
  40100. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40101. /**
  40102. * Defines the camera the input is attached to.
  40103. */
  40104. camera: FollowCamera;
  40105. /**
  40106. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40107. */
  40108. axisControlRadius: boolean;
  40109. /**
  40110. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40111. */
  40112. axisControlHeight: boolean;
  40113. /**
  40114. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40115. */
  40116. axisControlRotation: boolean;
  40117. /**
  40118. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40119. * relation to mouseWheel events.
  40120. */
  40121. wheelPrecision: number;
  40122. /**
  40123. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40124. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40125. */
  40126. wheelDeltaPercentage: number;
  40127. private _wheel;
  40128. private _observer;
  40129. /**
  40130. * Attach the input controls to a specific dom element to get the input from.
  40131. * @param element Defines the element the controls should be listened from
  40132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40133. */
  40134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40135. /**
  40136. * Detach the current controls from the specified dom element.
  40137. * @param element Defines the element to stop listening the inputs from
  40138. */
  40139. detachControl(element: Nullable<HTMLElement>): void;
  40140. /**
  40141. * Gets the class name of the current intput.
  40142. * @returns the class name
  40143. */
  40144. getClassName(): string;
  40145. /**
  40146. * Get the friendly name associated with the input class.
  40147. * @returns the input friendly name
  40148. */
  40149. getSimpleName(): string;
  40150. }
  40151. }
  40152. declare module BABYLON {
  40153. /**
  40154. * Manage the pointers inputs to control an follow camera.
  40155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40156. */
  40157. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40158. /**
  40159. * Defines the camera the input is attached to.
  40160. */
  40161. camera: FollowCamera;
  40162. /**
  40163. * Gets the class name of the current input.
  40164. * @returns the class name
  40165. */
  40166. getClassName(): string;
  40167. /**
  40168. * Defines the pointer angular sensibility along the X axis or how fast is
  40169. * the camera rotating.
  40170. * A negative number will reverse the axis direction.
  40171. */
  40172. angularSensibilityX: number;
  40173. /**
  40174. * Defines the pointer angular sensibility along the Y axis or how fast is
  40175. * the camera rotating.
  40176. * A negative number will reverse the axis direction.
  40177. */
  40178. angularSensibilityY: number;
  40179. /**
  40180. * Defines the pointer pinch precision or how fast is the camera zooming.
  40181. * A negative number will reverse the axis direction.
  40182. */
  40183. pinchPrecision: number;
  40184. /**
  40185. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40186. * from 0.
  40187. * It defines the percentage of current camera.radius to use as delta when
  40188. * pinch zoom is used.
  40189. */
  40190. pinchDeltaPercentage: number;
  40191. /**
  40192. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40193. */
  40194. axisXControlRadius: boolean;
  40195. /**
  40196. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40197. */
  40198. axisXControlHeight: boolean;
  40199. /**
  40200. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40201. */
  40202. axisXControlRotation: boolean;
  40203. /**
  40204. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40205. */
  40206. axisYControlRadius: boolean;
  40207. /**
  40208. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40209. */
  40210. axisYControlHeight: boolean;
  40211. /**
  40212. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40213. */
  40214. axisYControlRotation: boolean;
  40215. /**
  40216. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40217. */
  40218. axisPinchControlRadius: boolean;
  40219. /**
  40220. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40221. */
  40222. axisPinchControlHeight: boolean;
  40223. /**
  40224. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40225. */
  40226. axisPinchControlRotation: boolean;
  40227. /**
  40228. * Log error messages if basic misconfiguration has occurred.
  40229. */
  40230. warningEnable: boolean;
  40231. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40232. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40233. private _warningCounter;
  40234. private _warning;
  40235. }
  40236. }
  40237. declare module BABYLON {
  40238. /**
  40239. * Default Inputs manager for the FollowCamera.
  40240. * It groups all the default supported inputs for ease of use.
  40241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40242. */
  40243. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40244. /**
  40245. * Instantiates a new FollowCameraInputsManager.
  40246. * @param camera Defines the camera the inputs belong to
  40247. */
  40248. constructor(camera: FollowCamera);
  40249. /**
  40250. * Add keyboard input support to the input manager.
  40251. * @returns the current input manager
  40252. */
  40253. addKeyboard(): FollowCameraInputsManager;
  40254. /**
  40255. * Add mouse wheel input support to the input manager.
  40256. * @returns the current input manager
  40257. */
  40258. addMouseWheel(): FollowCameraInputsManager;
  40259. /**
  40260. * Add pointers input support to the input manager.
  40261. * @returns the current input manager
  40262. */
  40263. addPointers(): FollowCameraInputsManager;
  40264. /**
  40265. * Add orientation input support to the input manager.
  40266. * @returns the current input manager
  40267. */
  40268. addVRDeviceOrientation(): FollowCameraInputsManager;
  40269. }
  40270. }
  40271. declare module BABYLON {
  40272. /**
  40273. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40274. * an arc rotate version arcFollowCamera are available.
  40275. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40276. */
  40277. export class FollowCamera extends TargetCamera {
  40278. /**
  40279. * Distance the follow camera should follow an object at
  40280. */
  40281. radius: number;
  40282. /**
  40283. * Minimum allowed distance of the camera to the axis of rotation
  40284. * (The camera can not get closer).
  40285. * This can help limiting how the Camera is able to move in the scene.
  40286. */
  40287. lowerRadiusLimit: Nullable<number>;
  40288. /**
  40289. * Maximum allowed distance of the camera to the axis of rotation
  40290. * (The camera can not get further).
  40291. * This can help limiting how the Camera is able to move in the scene.
  40292. */
  40293. upperRadiusLimit: Nullable<number>;
  40294. /**
  40295. * Define a rotation offset between the camera and the object it follows
  40296. */
  40297. rotationOffset: number;
  40298. /**
  40299. * Minimum allowed angle to camera position relative to target object.
  40300. * This can help limiting how the Camera is able to move in the scene.
  40301. */
  40302. lowerRotationOffsetLimit: Nullable<number>;
  40303. /**
  40304. * Maximum allowed angle to camera position relative to target object.
  40305. * This can help limiting how the Camera is able to move in the scene.
  40306. */
  40307. upperRotationOffsetLimit: Nullable<number>;
  40308. /**
  40309. * Define a height offset between the camera and the object it follows.
  40310. * It can help following an object from the top (like a car chaing a plane)
  40311. */
  40312. heightOffset: number;
  40313. /**
  40314. * Minimum allowed height of camera position relative to target object.
  40315. * This can help limiting how the Camera is able to move in the scene.
  40316. */
  40317. lowerHeightOffsetLimit: Nullable<number>;
  40318. /**
  40319. * Maximum allowed height of camera position relative to target object.
  40320. * This can help limiting how the Camera is able to move in the scene.
  40321. */
  40322. upperHeightOffsetLimit: Nullable<number>;
  40323. /**
  40324. * Define how fast the camera can accelerate to follow it s target.
  40325. */
  40326. cameraAcceleration: number;
  40327. /**
  40328. * Define the speed limit of the camera following an object.
  40329. */
  40330. maxCameraSpeed: number;
  40331. /**
  40332. * Define the target of the camera.
  40333. */
  40334. lockedTarget: Nullable<AbstractMesh>;
  40335. /**
  40336. * Defines the input associated with the camera.
  40337. */
  40338. inputs: FollowCameraInputsManager;
  40339. /**
  40340. * Instantiates the follow camera.
  40341. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40342. * @param name Define the name of the camera in the scene
  40343. * @param position Define the position of the camera
  40344. * @param scene Define the scene the camera belong to
  40345. * @param lockedTarget Define the target of the camera
  40346. */
  40347. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40348. private _follow;
  40349. /**
  40350. * Attached controls to the current camera.
  40351. * @param element Defines the element the controls should be listened from
  40352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40353. */
  40354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40355. /**
  40356. * Detach the current controls from the camera.
  40357. * The camera will stop reacting to inputs.
  40358. * @param element Defines the element to stop listening the inputs from
  40359. */
  40360. detachControl(element: HTMLElement): void;
  40361. /** @hidden */
  40362. _checkInputs(): void;
  40363. private _checkLimits;
  40364. /**
  40365. * Gets the camera class name.
  40366. * @returns the class name
  40367. */
  40368. getClassName(): string;
  40369. }
  40370. /**
  40371. * Arc Rotate version of the follow camera.
  40372. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40373. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40374. */
  40375. export class ArcFollowCamera extends TargetCamera {
  40376. /** The longitudinal angle of the camera */
  40377. alpha: number;
  40378. /** The latitudinal angle of the camera */
  40379. beta: number;
  40380. /** The radius of the camera from its target */
  40381. radius: number;
  40382. /** Define the camera target (the messh it should follow) */
  40383. target: Nullable<AbstractMesh>;
  40384. private _cartesianCoordinates;
  40385. /**
  40386. * Instantiates a new ArcFollowCamera
  40387. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40388. * @param name Define the name of the camera
  40389. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40390. * @param beta Define the rotation angle of the camera around the elevation axis
  40391. * @param radius Define the radius of the camera from its target point
  40392. * @param target Define the target of the camera
  40393. * @param scene Define the scene the camera belongs to
  40394. */
  40395. constructor(name: string,
  40396. /** The longitudinal angle of the camera */
  40397. alpha: number,
  40398. /** The latitudinal angle of the camera */
  40399. beta: number,
  40400. /** The radius of the camera from its target */
  40401. radius: number,
  40402. /** Define the camera target (the messh it should follow) */
  40403. target: Nullable<AbstractMesh>, scene: Scene);
  40404. private _follow;
  40405. /** @hidden */
  40406. _checkInputs(): void;
  40407. /**
  40408. * Returns the class name of the object.
  40409. * It is mostly used internally for serialization purposes.
  40410. */
  40411. getClassName(): string;
  40412. }
  40413. }
  40414. declare module BABYLON {
  40415. /**
  40416. * Manage the keyboard inputs to control the movement of a follow camera.
  40417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40418. */
  40419. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40420. /**
  40421. * Defines the camera the input is attached to.
  40422. */
  40423. camera: FollowCamera;
  40424. /**
  40425. * Defines the list of key codes associated with the up action (increase heightOffset)
  40426. */
  40427. keysHeightOffsetIncr: number[];
  40428. /**
  40429. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40430. */
  40431. keysHeightOffsetDecr: number[];
  40432. /**
  40433. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40434. */
  40435. keysHeightOffsetModifierAlt: boolean;
  40436. /**
  40437. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40438. */
  40439. keysHeightOffsetModifierCtrl: boolean;
  40440. /**
  40441. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40442. */
  40443. keysHeightOffsetModifierShift: boolean;
  40444. /**
  40445. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40446. */
  40447. keysRotationOffsetIncr: number[];
  40448. /**
  40449. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40450. */
  40451. keysRotationOffsetDecr: number[];
  40452. /**
  40453. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40454. */
  40455. keysRotationOffsetModifierAlt: boolean;
  40456. /**
  40457. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40458. */
  40459. keysRotationOffsetModifierCtrl: boolean;
  40460. /**
  40461. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40462. */
  40463. keysRotationOffsetModifierShift: boolean;
  40464. /**
  40465. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40466. */
  40467. keysRadiusIncr: number[];
  40468. /**
  40469. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40470. */
  40471. keysRadiusDecr: number[];
  40472. /**
  40473. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40474. */
  40475. keysRadiusModifierAlt: boolean;
  40476. /**
  40477. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40478. */
  40479. keysRadiusModifierCtrl: boolean;
  40480. /**
  40481. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40482. */
  40483. keysRadiusModifierShift: boolean;
  40484. /**
  40485. * Defines the rate of change of heightOffset.
  40486. */
  40487. heightSensibility: number;
  40488. /**
  40489. * Defines the rate of change of rotationOffset.
  40490. */
  40491. rotationSensibility: number;
  40492. /**
  40493. * Defines the rate of change of radius.
  40494. */
  40495. radiusSensibility: number;
  40496. private _keys;
  40497. private _ctrlPressed;
  40498. private _altPressed;
  40499. private _shiftPressed;
  40500. private _onCanvasBlurObserver;
  40501. private _onKeyboardObserver;
  40502. private _engine;
  40503. private _scene;
  40504. /**
  40505. * Attach the input controls to a specific dom element to get the input from.
  40506. * @param element Defines the element the controls should be listened from
  40507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40508. */
  40509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40510. /**
  40511. * Detach the current controls from the specified dom element.
  40512. * @param element Defines the element to stop listening the inputs from
  40513. */
  40514. detachControl(element: Nullable<HTMLElement>): void;
  40515. /**
  40516. * Update the current camera state depending on the inputs that have been used this frame.
  40517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40518. */
  40519. checkInputs(): void;
  40520. /**
  40521. * Gets the class name of the current input.
  40522. * @returns the class name
  40523. */
  40524. getClassName(): string;
  40525. /**
  40526. * Get the friendly name associated with the input class.
  40527. * @returns the input friendly name
  40528. */
  40529. getSimpleName(): string;
  40530. /**
  40531. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40532. * allow modification of the heightOffset value.
  40533. */
  40534. private _modifierHeightOffset;
  40535. /**
  40536. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40537. * allow modification of the rotationOffset value.
  40538. */
  40539. private _modifierRotationOffset;
  40540. /**
  40541. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40542. * allow modification of the radius value.
  40543. */
  40544. private _modifierRadius;
  40545. }
  40546. }
  40547. declare module BABYLON {
  40548. interface FreeCameraInputsManager {
  40549. /**
  40550. * @hidden
  40551. */
  40552. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40553. /**
  40554. * Add orientation input support to the input manager.
  40555. * @returns the current input manager
  40556. */
  40557. addDeviceOrientation(): FreeCameraInputsManager;
  40558. }
  40559. /**
  40560. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40561. * Screen rotation is taken into account.
  40562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40563. */
  40564. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40565. private _camera;
  40566. private _screenOrientationAngle;
  40567. private _constantTranform;
  40568. private _screenQuaternion;
  40569. private _alpha;
  40570. private _beta;
  40571. private _gamma;
  40572. /**
  40573. * Can be used to detect if a device orientation sensor is available on a device
  40574. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40575. * @returns a promise that will resolve on orientation change
  40576. */
  40577. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40578. /**
  40579. * @hidden
  40580. */
  40581. _onDeviceOrientationChangedObservable: Observable<void>;
  40582. /**
  40583. * Instantiates a new input
  40584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40585. */
  40586. constructor();
  40587. /**
  40588. * Define the camera controlled by the input.
  40589. */
  40590. get camera(): FreeCamera;
  40591. set camera(camera: FreeCamera);
  40592. /**
  40593. * Attach the input controls to a specific dom element to get the input from.
  40594. * @param element Defines the element the controls should be listened from
  40595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40596. */
  40597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40598. private _orientationChanged;
  40599. private _deviceOrientation;
  40600. /**
  40601. * Detach the current controls from the specified dom element.
  40602. * @param element Defines the element to stop listening the inputs from
  40603. */
  40604. detachControl(element: Nullable<HTMLElement>): void;
  40605. /**
  40606. * Update the current camera state depending on the inputs that have been used this frame.
  40607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40608. */
  40609. checkInputs(): void;
  40610. /**
  40611. * Gets the class name of the current intput.
  40612. * @returns the class name
  40613. */
  40614. getClassName(): string;
  40615. /**
  40616. * Get the friendly name associated with the input class.
  40617. * @returns the input friendly name
  40618. */
  40619. getSimpleName(): string;
  40620. }
  40621. }
  40622. declare module BABYLON {
  40623. /**
  40624. * Manage the gamepad inputs to control a free camera.
  40625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40626. */
  40627. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40628. /**
  40629. * Define the camera the input is attached to.
  40630. */
  40631. camera: FreeCamera;
  40632. /**
  40633. * Define the Gamepad controlling the input
  40634. */
  40635. gamepad: Nullable<Gamepad>;
  40636. /**
  40637. * Defines the gamepad rotation sensiblity.
  40638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40639. */
  40640. gamepadAngularSensibility: number;
  40641. /**
  40642. * Defines the gamepad move sensiblity.
  40643. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40644. */
  40645. gamepadMoveSensibility: number;
  40646. private _yAxisScale;
  40647. /**
  40648. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40649. */
  40650. get invertYAxis(): boolean;
  40651. set invertYAxis(value: boolean);
  40652. private _onGamepadConnectedObserver;
  40653. private _onGamepadDisconnectedObserver;
  40654. private _cameraTransform;
  40655. private _deltaTransform;
  40656. private _vector3;
  40657. private _vector2;
  40658. /**
  40659. * Attach the input controls to a specific dom element to get the input from.
  40660. * @param element Defines the element the controls should be listened from
  40661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40662. */
  40663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40664. /**
  40665. * Detach the current controls from the specified dom element.
  40666. * @param element Defines the element to stop listening the inputs from
  40667. */
  40668. detachControl(element: Nullable<HTMLElement>): void;
  40669. /**
  40670. * Update the current camera state depending on the inputs that have been used this frame.
  40671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40672. */
  40673. checkInputs(): void;
  40674. /**
  40675. * Gets the class name of the current intput.
  40676. * @returns the class name
  40677. */
  40678. getClassName(): string;
  40679. /**
  40680. * Get the friendly name associated with the input class.
  40681. * @returns the input friendly name
  40682. */
  40683. getSimpleName(): string;
  40684. }
  40685. }
  40686. declare module BABYLON {
  40687. /**
  40688. * Defines the potential axis of a Joystick
  40689. */
  40690. export enum JoystickAxis {
  40691. /** X axis */
  40692. X = 0,
  40693. /** Y axis */
  40694. Y = 1,
  40695. /** Z axis */
  40696. Z = 2
  40697. }
  40698. /**
  40699. * Class used to define virtual joystick (used in touch mode)
  40700. */
  40701. export class VirtualJoystick {
  40702. /**
  40703. * Gets or sets a boolean indicating that left and right values must be inverted
  40704. */
  40705. reverseLeftRight: boolean;
  40706. /**
  40707. * Gets or sets a boolean indicating that up and down values must be inverted
  40708. */
  40709. reverseUpDown: boolean;
  40710. /**
  40711. * Gets the offset value for the position (ie. the change of the position value)
  40712. */
  40713. deltaPosition: Vector3;
  40714. /**
  40715. * Gets a boolean indicating if the virtual joystick was pressed
  40716. */
  40717. pressed: boolean;
  40718. /**
  40719. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40720. */
  40721. static Canvas: Nullable<HTMLCanvasElement>;
  40722. private static _globalJoystickIndex;
  40723. private static vjCanvasContext;
  40724. private static vjCanvasWidth;
  40725. private static vjCanvasHeight;
  40726. private static halfWidth;
  40727. private _action;
  40728. private _axisTargetedByLeftAndRight;
  40729. private _axisTargetedByUpAndDown;
  40730. private _joystickSensibility;
  40731. private _inversedSensibility;
  40732. private _joystickPointerID;
  40733. private _joystickColor;
  40734. private _joystickPointerPos;
  40735. private _joystickPreviousPointerPos;
  40736. private _joystickPointerStartPos;
  40737. private _deltaJoystickVector;
  40738. private _leftJoystick;
  40739. private _touches;
  40740. private _onPointerDownHandlerRef;
  40741. private _onPointerMoveHandlerRef;
  40742. private _onPointerUpHandlerRef;
  40743. private _onResize;
  40744. /**
  40745. * Creates a new virtual joystick
  40746. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40747. */
  40748. constructor(leftJoystick?: boolean);
  40749. /**
  40750. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40751. * @param newJoystickSensibility defines the new sensibility
  40752. */
  40753. setJoystickSensibility(newJoystickSensibility: number): void;
  40754. private _onPointerDown;
  40755. private _onPointerMove;
  40756. private _onPointerUp;
  40757. /**
  40758. * Change the color of the virtual joystick
  40759. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40760. */
  40761. setJoystickColor(newColor: string): void;
  40762. /**
  40763. * Defines a callback to call when the joystick is touched
  40764. * @param action defines the callback
  40765. */
  40766. setActionOnTouch(action: () => any): void;
  40767. /**
  40768. * Defines which axis you'd like to control for left & right
  40769. * @param axis defines the axis to use
  40770. */
  40771. setAxisForLeftRight(axis: JoystickAxis): void;
  40772. /**
  40773. * Defines which axis you'd like to control for up & down
  40774. * @param axis defines the axis to use
  40775. */
  40776. setAxisForUpDown(axis: JoystickAxis): void;
  40777. private _drawVirtualJoystick;
  40778. /**
  40779. * Release internal HTML canvas
  40780. */
  40781. releaseCanvas(): void;
  40782. }
  40783. }
  40784. declare module BABYLON {
  40785. interface FreeCameraInputsManager {
  40786. /**
  40787. * Add virtual joystick input support to the input manager.
  40788. * @returns the current input manager
  40789. */
  40790. addVirtualJoystick(): FreeCameraInputsManager;
  40791. }
  40792. /**
  40793. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40795. */
  40796. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40797. /**
  40798. * Defines the camera the input is attached to.
  40799. */
  40800. camera: FreeCamera;
  40801. private _leftjoystick;
  40802. private _rightjoystick;
  40803. /**
  40804. * Gets the left stick of the virtual joystick.
  40805. * @returns The virtual Joystick
  40806. */
  40807. getLeftJoystick(): VirtualJoystick;
  40808. /**
  40809. * Gets the right stick of the virtual joystick.
  40810. * @returns The virtual Joystick
  40811. */
  40812. getRightJoystick(): VirtualJoystick;
  40813. /**
  40814. * Update the current camera state depending on the inputs that have been used this frame.
  40815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40816. */
  40817. checkInputs(): void;
  40818. /**
  40819. * Attach the input controls to a specific dom element to get the input from.
  40820. * @param element Defines the element the controls should be listened from
  40821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40822. */
  40823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40824. /**
  40825. * Detach the current controls from the specified dom element.
  40826. * @param element Defines the element to stop listening the inputs from
  40827. */
  40828. detachControl(element: Nullable<HTMLElement>): void;
  40829. /**
  40830. * Gets the class name of the current intput.
  40831. * @returns the class name
  40832. */
  40833. getClassName(): string;
  40834. /**
  40835. * Get the friendly name associated with the input class.
  40836. * @returns the input friendly name
  40837. */
  40838. getSimpleName(): string;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * This represents a FPS type of camera controlled by touch.
  40844. * This is like a universal camera minus the Gamepad controls.
  40845. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40846. */
  40847. export class TouchCamera extends FreeCamera {
  40848. /**
  40849. * Defines the touch sensibility for rotation.
  40850. * The higher the faster.
  40851. */
  40852. get touchAngularSensibility(): number;
  40853. set touchAngularSensibility(value: number);
  40854. /**
  40855. * Defines the touch sensibility for move.
  40856. * The higher the faster.
  40857. */
  40858. get touchMoveSensibility(): number;
  40859. set touchMoveSensibility(value: number);
  40860. /**
  40861. * Instantiates a new touch camera.
  40862. * This represents a FPS type of camera controlled by touch.
  40863. * This is like a universal camera minus the Gamepad controls.
  40864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40865. * @param name Define the name of the camera in the scene
  40866. * @param position Define the start position of the camera in the scene
  40867. * @param scene Define the scene the camera belongs to
  40868. */
  40869. constructor(name: string, position: Vector3, scene: Scene);
  40870. /**
  40871. * Gets the current object class name.
  40872. * @return the class name
  40873. */
  40874. getClassName(): string;
  40875. /** @hidden */
  40876. _setupInputs(): void;
  40877. }
  40878. }
  40879. declare module BABYLON {
  40880. /**
  40881. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40882. * being tilted forward or back and left or right.
  40883. */
  40884. export class DeviceOrientationCamera extends FreeCamera {
  40885. private _initialQuaternion;
  40886. private _quaternionCache;
  40887. private _tmpDragQuaternion;
  40888. private _disablePointerInputWhenUsingDeviceOrientation;
  40889. /**
  40890. * Creates a new device orientation camera
  40891. * @param name The name of the camera
  40892. * @param position The start position camera
  40893. * @param scene The scene the camera belongs to
  40894. */
  40895. constructor(name: string, position: Vector3, scene: Scene);
  40896. /**
  40897. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40898. */
  40899. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40900. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40901. private _dragFactor;
  40902. /**
  40903. * Enabled turning on the y axis when the orientation sensor is active
  40904. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40905. */
  40906. enableHorizontalDragging(dragFactor?: number): void;
  40907. /**
  40908. * Gets the current instance class name ("DeviceOrientationCamera").
  40909. * This helps avoiding instanceof at run time.
  40910. * @returns the class name
  40911. */
  40912. getClassName(): string;
  40913. /**
  40914. * @hidden
  40915. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40916. */
  40917. _checkInputs(): void;
  40918. /**
  40919. * Reset the camera to its default orientation on the specified axis only.
  40920. * @param axis The axis to reset
  40921. */
  40922. resetToCurrentRotation(axis?: Axis): void;
  40923. }
  40924. }
  40925. declare module BABYLON {
  40926. /**
  40927. * Defines supported buttons for XBox360 compatible gamepads
  40928. */
  40929. export enum Xbox360Button {
  40930. /** A */
  40931. A = 0,
  40932. /** B */
  40933. B = 1,
  40934. /** X */
  40935. X = 2,
  40936. /** Y */
  40937. Y = 3,
  40938. /** Start */
  40939. Start = 4,
  40940. /** Back */
  40941. Back = 5,
  40942. /** Left button */
  40943. LB = 6,
  40944. /** Right button */
  40945. RB = 7,
  40946. /** Left stick */
  40947. LeftStick = 8,
  40948. /** Right stick */
  40949. RightStick = 9
  40950. }
  40951. /** Defines values for XBox360 DPad */
  40952. export enum Xbox360Dpad {
  40953. /** Up */
  40954. Up = 0,
  40955. /** Down */
  40956. Down = 1,
  40957. /** Left */
  40958. Left = 2,
  40959. /** Right */
  40960. Right = 3
  40961. }
  40962. /**
  40963. * Defines a XBox360 gamepad
  40964. */
  40965. export class Xbox360Pad extends Gamepad {
  40966. private _leftTrigger;
  40967. private _rightTrigger;
  40968. private _onlefttriggerchanged;
  40969. private _onrighttriggerchanged;
  40970. private _onbuttondown;
  40971. private _onbuttonup;
  40972. private _ondpaddown;
  40973. private _ondpadup;
  40974. /** Observable raised when a button is pressed */
  40975. onButtonDownObservable: Observable<Xbox360Button>;
  40976. /** Observable raised when a button is released */
  40977. onButtonUpObservable: Observable<Xbox360Button>;
  40978. /** Observable raised when a pad is pressed */
  40979. onPadDownObservable: Observable<Xbox360Dpad>;
  40980. /** Observable raised when a pad is released */
  40981. onPadUpObservable: Observable<Xbox360Dpad>;
  40982. private _buttonA;
  40983. private _buttonB;
  40984. private _buttonX;
  40985. private _buttonY;
  40986. private _buttonBack;
  40987. private _buttonStart;
  40988. private _buttonLB;
  40989. private _buttonRB;
  40990. private _buttonLeftStick;
  40991. private _buttonRightStick;
  40992. private _dPadUp;
  40993. private _dPadDown;
  40994. private _dPadLeft;
  40995. private _dPadRight;
  40996. private _isXboxOnePad;
  40997. /**
  40998. * Creates a new XBox360 gamepad object
  40999. * @param id defines the id of this gamepad
  41000. * @param index defines its index
  41001. * @param gamepad defines the internal HTML gamepad object
  41002. * @param xboxOne defines if it is a XBox One gamepad
  41003. */
  41004. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41005. /**
  41006. * Defines the callback to call when left trigger is pressed
  41007. * @param callback defines the callback to use
  41008. */
  41009. onlefttriggerchanged(callback: (value: number) => void): void;
  41010. /**
  41011. * Defines the callback to call when right trigger is pressed
  41012. * @param callback defines the callback to use
  41013. */
  41014. onrighttriggerchanged(callback: (value: number) => void): void;
  41015. /**
  41016. * Gets the left trigger value
  41017. */
  41018. get leftTrigger(): number;
  41019. /**
  41020. * Sets the left trigger value
  41021. */
  41022. set leftTrigger(newValue: number);
  41023. /**
  41024. * Gets the right trigger value
  41025. */
  41026. get rightTrigger(): number;
  41027. /**
  41028. * Sets the right trigger value
  41029. */
  41030. set rightTrigger(newValue: number);
  41031. /**
  41032. * Defines the callback to call when a button is pressed
  41033. * @param callback defines the callback to use
  41034. */
  41035. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41036. /**
  41037. * Defines the callback to call when a button is released
  41038. * @param callback defines the callback to use
  41039. */
  41040. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41041. /**
  41042. * Defines the callback to call when a pad is pressed
  41043. * @param callback defines the callback to use
  41044. */
  41045. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41046. /**
  41047. * Defines the callback to call when a pad is released
  41048. * @param callback defines the callback to use
  41049. */
  41050. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41051. private _setButtonValue;
  41052. private _setDPadValue;
  41053. /**
  41054. * Gets the value of the `A` button
  41055. */
  41056. get buttonA(): number;
  41057. /**
  41058. * Sets the value of the `A` button
  41059. */
  41060. set buttonA(value: number);
  41061. /**
  41062. * Gets the value of the `B` button
  41063. */
  41064. get buttonB(): number;
  41065. /**
  41066. * Sets the value of the `B` button
  41067. */
  41068. set buttonB(value: number);
  41069. /**
  41070. * Gets the value of the `X` button
  41071. */
  41072. get buttonX(): number;
  41073. /**
  41074. * Sets the value of the `X` button
  41075. */
  41076. set buttonX(value: number);
  41077. /**
  41078. * Gets the value of the `Y` button
  41079. */
  41080. get buttonY(): number;
  41081. /**
  41082. * Sets the value of the `Y` button
  41083. */
  41084. set buttonY(value: number);
  41085. /**
  41086. * Gets the value of the `Start` button
  41087. */
  41088. get buttonStart(): number;
  41089. /**
  41090. * Sets the value of the `Start` button
  41091. */
  41092. set buttonStart(value: number);
  41093. /**
  41094. * Gets the value of the `Back` button
  41095. */
  41096. get buttonBack(): number;
  41097. /**
  41098. * Sets the value of the `Back` button
  41099. */
  41100. set buttonBack(value: number);
  41101. /**
  41102. * Gets the value of the `Left` button
  41103. */
  41104. get buttonLB(): number;
  41105. /**
  41106. * Sets the value of the `Left` button
  41107. */
  41108. set buttonLB(value: number);
  41109. /**
  41110. * Gets the value of the `Right` button
  41111. */
  41112. get buttonRB(): number;
  41113. /**
  41114. * Sets the value of the `Right` button
  41115. */
  41116. set buttonRB(value: number);
  41117. /**
  41118. * Gets the value of the Left joystick
  41119. */
  41120. get buttonLeftStick(): number;
  41121. /**
  41122. * Sets the value of the Left joystick
  41123. */
  41124. set buttonLeftStick(value: number);
  41125. /**
  41126. * Gets the value of the Right joystick
  41127. */
  41128. get buttonRightStick(): number;
  41129. /**
  41130. * Sets the value of the Right joystick
  41131. */
  41132. set buttonRightStick(value: number);
  41133. /**
  41134. * Gets the value of D-pad up
  41135. */
  41136. get dPadUp(): number;
  41137. /**
  41138. * Sets the value of D-pad up
  41139. */
  41140. set dPadUp(value: number);
  41141. /**
  41142. * Gets the value of D-pad down
  41143. */
  41144. get dPadDown(): number;
  41145. /**
  41146. * Sets the value of D-pad down
  41147. */
  41148. set dPadDown(value: number);
  41149. /**
  41150. * Gets the value of D-pad left
  41151. */
  41152. get dPadLeft(): number;
  41153. /**
  41154. * Sets the value of D-pad left
  41155. */
  41156. set dPadLeft(value: number);
  41157. /**
  41158. * Gets the value of D-pad right
  41159. */
  41160. get dPadRight(): number;
  41161. /**
  41162. * Sets the value of D-pad right
  41163. */
  41164. set dPadRight(value: number);
  41165. /**
  41166. * Force the gamepad to synchronize with device values
  41167. */
  41168. update(): void;
  41169. /**
  41170. * Disposes the gamepad
  41171. */
  41172. dispose(): void;
  41173. }
  41174. }
  41175. declare module BABYLON {
  41176. /**
  41177. * Defines supported buttons for DualShock compatible gamepads
  41178. */
  41179. export enum DualShockButton {
  41180. /** Cross */
  41181. Cross = 0,
  41182. /** Circle */
  41183. Circle = 1,
  41184. /** Square */
  41185. Square = 2,
  41186. /** Triangle */
  41187. Triangle = 3,
  41188. /** Options */
  41189. Options = 4,
  41190. /** Share */
  41191. Share = 5,
  41192. /** L1 */
  41193. L1 = 6,
  41194. /** R1 */
  41195. R1 = 7,
  41196. /** Left stick */
  41197. LeftStick = 8,
  41198. /** Right stick */
  41199. RightStick = 9
  41200. }
  41201. /** Defines values for DualShock DPad */
  41202. export enum DualShockDpad {
  41203. /** Up */
  41204. Up = 0,
  41205. /** Down */
  41206. Down = 1,
  41207. /** Left */
  41208. Left = 2,
  41209. /** Right */
  41210. Right = 3
  41211. }
  41212. /**
  41213. * Defines a DualShock gamepad
  41214. */
  41215. export class DualShockPad extends Gamepad {
  41216. private _leftTrigger;
  41217. private _rightTrigger;
  41218. private _onlefttriggerchanged;
  41219. private _onrighttriggerchanged;
  41220. private _onbuttondown;
  41221. private _onbuttonup;
  41222. private _ondpaddown;
  41223. private _ondpadup;
  41224. /** Observable raised when a button is pressed */
  41225. onButtonDownObservable: Observable<DualShockButton>;
  41226. /** Observable raised when a button is released */
  41227. onButtonUpObservable: Observable<DualShockButton>;
  41228. /** Observable raised when a pad is pressed */
  41229. onPadDownObservable: Observable<DualShockDpad>;
  41230. /** Observable raised when a pad is released */
  41231. onPadUpObservable: Observable<DualShockDpad>;
  41232. private _buttonCross;
  41233. private _buttonCircle;
  41234. private _buttonSquare;
  41235. private _buttonTriangle;
  41236. private _buttonShare;
  41237. private _buttonOptions;
  41238. private _buttonL1;
  41239. private _buttonR1;
  41240. private _buttonLeftStick;
  41241. private _buttonRightStick;
  41242. private _dPadUp;
  41243. private _dPadDown;
  41244. private _dPadLeft;
  41245. private _dPadRight;
  41246. /**
  41247. * Creates a new DualShock gamepad object
  41248. * @param id defines the id of this gamepad
  41249. * @param index defines its index
  41250. * @param gamepad defines the internal HTML gamepad object
  41251. */
  41252. constructor(id: string, index: number, gamepad: any);
  41253. /**
  41254. * Defines the callback to call when left trigger is pressed
  41255. * @param callback defines the callback to use
  41256. */
  41257. onlefttriggerchanged(callback: (value: number) => void): void;
  41258. /**
  41259. * Defines the callback to call when right trigger is pressed
  41260. * @param callback defines the callback to use
  41261. */
  41262. onrighttriggerchanged(callback: (value: number) => void): void;
  41263. /**
  41264. * Gets the left trigger value
  41265. */
  41266. get leftTrigger(): number;
  41267. /**
  41268. * Sets the left trigger value
  41269. */
  41270. set leftTrigger(newValue: number);
  41271. /**
  41272. * Gets the right trigger value
  41273. */
  41274. get rightTrigger(): number;
  41275. /**
  41276. * Sets the right trigger value
  41277. */
  41278. set rightTrigger(newValue: number);
  41279. /**
  41280. * Defines the callback to call when a button is pressed
  41281. * @param callback defines the callback to use
  41282. */
  41283. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41284. /**
  41285. * Defines the callback to call when a button is released
  41286. * @param callback defines the callback to use
  41287. */
  41288. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41289. /**
  41290. * Defines the callback to call when a pad is pressed
  41291. * @param callback defines the callback to use
  41292. */
  41293. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41294. /**
  41295. * Defines the callback to call when a pad is released
  41296. * @param callback defines the callback to use
  41297. */
  41298. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41299. private _setButtonValue;
  41300. private _setDPadValue;
  41301. /**
  41302. * Gets the value of the `Cross` button
  41303. */
  41304. get buttonCross(): number;
  41305. /**
  41306. * Sets the value of the `Cross` button
  41307. */
  41308. set buttonCross(value: number);
  41309. /**
  41310. * Gets the value of the `Circle` button
  41311. */
  41312. get buttonCircle(): number;
  41313. /**
  41314. * Sets the value of the `Circle` button
  41315. */
  41316. set buttonCircle(value: number);
  41317. /**
  41318. * Gets the value of the `Square` button
  41319. */
  41320. get buttonSquare(): number;
  41321. /**
  41322. * Sets the value of the `Square` button
  41323. */
  41324. set buttonSquare(value: number);
  41325. /**
  41326. * Gets the value of the `Triangle` button
  41327. */
  41328. get buttonTriangle(): number;
  41329. /**
  41330. * Sets the value of the `Triangle` button
  41331. */
  41332. set buttonTriangle(value: number);
  41333. /**
  41334. * Gets the value of the `Options` button
  41335. */
  41336. get buttonOptions(): number;
  41337. /**
  41338. * Sets the value of the `Options` button
  41339. */
  41340. set buttonOptions(value: number);
  41341. /**
  41342. * Gets the value of the `Share` button
  41343. */
  41344. get buttonShare(): number;
  41345. /**
  41346. * Sets the value of the `Share` button
  41347. */
  41348. set buttonShare(value: number);
  41349. /**
  41350. * Gets the value of the `L1` button
  41351. */
  41352. get buttonL1(): number;
  41353. /**
  41354. * Sets the value of the `L1` button
  41355. */
  41356. set buttonL1(value: number);
  41357. /**
  41358. * Gets the value of the `R1` button
  41359. */
  41360. get buttonR1(): number;
  41361. /**
  41362. * Sets the value of the `R1` button
  41363. */
  41364. set buttonR1(value: number);
  41365. /**
  41366. * Gets the value of the Left joystick
  41367. */
  41368. get buttonLeftStick(): number;
  41369. /**
  41370. * Sets the value of the Left joystick
  41371. */
  41372. set buttonLeftStick(value: number);
  41373. /**
  41374. * Gets the value of the Right joystick
  41375. */
  41376. get buttonRightStick(): number;
  41377. /**
  41378. * Sets the value of the Right joystick
  41379. */
  41380. set buttonRightStick(value: number);
  41381. /**
  41382. * Gets the value of D-pad up
  41383. */
  41384. get dPadUp(): number;
  41385. /**
  41386. * Sets the value of D-pad up
  41387. */
  41388. set dPadUp(value: number);
  41389. /**
  41390. * Gets the value of D-pad down
  41391. */
  41392. get dPadDown(): number;
  41393. /**
  41394. * Sets the value of D-pad down
  41395. */
  41396. set dPadDown(value: number);
  41397. /**
  41398. * Gets the value of D-pad left
  41399. */
  41400. get dPadLeft(): number;
  41401. /**
  41402. * Sets the value of D-pad left
  41403. */
  41404. set dPadLeft(value: number);
  41405. /**
  41406. * Gets the value of D-pad right
  41407. */
  41408. get dPadRight(): number;
  41409. /**
  41410. * Sets the value of D-pad right
  41411. */
  41412. set dPadRight(value: number);
  41413. /**
  41414. * Force the gamepad to synchronize with device values
  41415. */
  41416. update(): void;
  41417. /**
  41418. * Disposes the gamepad
  41419. */
  41420. dispose(): void;
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /**
  41425. * Manager for handling gamepads
  41426. */
  41427. export class GamepadManager {
  41428. private _scene?;
  41429. private _babylonGamepads;
  41430. private _oneGamepadConnected;
  41431. /** @hidden */
  41432. _isMonitoring: boolean;
  41433. private _gamepadEventSupported;
  41434. private _gamepadSupport?;
  41435. /**
  41436. * observable to be triggered when the gamepad controller has been connected
  41437. */
  41438. onGamepadConnectedObservable: Observable<Gamepad>;
  41439. /**
  41440. * observable to be triggered when the gamepad controller has been disconnected
  41441. */
  41442. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41443. private _onGamepadConnectedEvent;
  41444. private _onGamepadDisconnectedEvent;
  41445. /**
  41446. * Initializes the gamepad manager
  41447. * @param _scene BabylonJS scene
  41448. */
  41449. constructor(_scene?: Scene | undefined);
  41450. /**
  41451. * The gamepads in the game pad manager
  41452. */
  41453. get gamepads(): Gamepad[];
  41454. /**
  41455. * Get the gamepad controllers based on type
  41456. * @param type The type of gamepad controller
  41457. * @returns Nullable gamepad
  41458. */
  41459. getGamepadByType(type?: number): Nullable<Gamepad>;
  41460. /**
  41461. * Disposes the gamepad manager
  41462. */
  41463. dispose(): void;
  41464. private _addNewGamepad;
  41465. private _startMonitoringGamepads;
  41466. private _stopMonitoringGamepads;
  41467. /** @hidden */
  41468. _checkGamepadsStatus(): void;
  41469. private _updateGamepadObjects;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. interface Scene {
  41474. /** @hidden */
  41475. _gamepadManager: Nullable<GamepadManager>;
  41476. /**
  41477. * Gets the gamepad manager associated with the scene
  41478. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41479. */
  41480. gamepadManager: GamepadManager;
  41481. }
  41482. /**
  41483. * Interface representing a free camera inputs manager
  41484. */
  41485. interface FreeCameraInputsManager {
  41486. /**
  41487. * Adds gamepad input support to the FreeCameraInputsManager.
  41488. * @returns the FreeCameraInputsManager
  41489. */
  41490. addGamepad(): FreeCameraInputsManager;
  41491. }
  41492. /**
  41493. * Interface representing an arc rotate camera inputs manager
  41494. */
  41495. interface ArcRotateCameraInputsManager {
  41496. /**
  41497. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41498. * @returns the camera inputs manager
  41499. */
  41500. addGamepad(): ArcRotateCameraInputsManager;
  41501. }
  41502. /**
  41503. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41504. */
  41505. export class GamepadSystemSceneComponent implements ISceneComponent {
  41506. /**
  41507. * The component name helpfull to identify the component in the list of scene components.
  41508. */
  41509. readonly name: string;
  41510. /**
  41511. * The scene the component belongs to.
  41512. */
  41513. scene: Scene;
  41514. /**
  41515. * Creates a new instance of the component for the given scene
  41516. * @param scene Defines the scene to register the component in
  41517. */
  41518. constructor(scene: Scene);
  41519. /**
  41520. * Registers the component in a given scene
  41521. */
  41522. register(): void;
  41523. /**
  41524. * Rebuilds the elements related to this component in case of
  41525. * context lost for instance.
  41526. */
  41527. rebuild(): void;
  41528. /**
  41529. * Disposes the component and the associated ressources
  41530. */
  41531. dispose(): void;
  41532. private _beforeCameraUpdate;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * 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,
  41538. * which still works and will still be found in many Playgrounds.
  41539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41540. */
  41541. export class UniversalCamera extends TouchCamera {
  41542. /**
  41543. * Defines the gamepad rotation sensiblity.
  41544. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41545. */
  41546. get gamepadAngularSensibility(): number;
  41547. set gamepadAngularSensibility(value: number);
  41548. /**
  41549. * Defines the gamepad move sensiblity.
  41550. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41551. */
  41552. get gamepadMoveSensibility(): number;
  41553. set gamepadMoveSensibility(value: number);
  41554. /**
  41555. * 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,
  41556. * which still works and will still be found in many Playgrounds.
  41557. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41558. * @param name Define the name of the camera in the scene
  41559. * @param position Define the start position of the camera in the scene
  41560. * @param scene Define the scene the camera belongs to
  41561. */
  41562. constructor(name: string, position: Vector3, scene: Scene);
  41563. /**
  41564. * Gets the current object class name.
  41565. * @return the class name
  41566. */
  41567. getClassName(): string;
  41568. }
  41569. }
  41570. declare module BABYLON {
  41571. /**
  41572. * This represents a FPS type of camera. This is only here for back compat purpose.
  41573. * Please use the UniversalCamera instead as both are identical.
  41574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41575. */
  41576. export class GamepadCamera extends UniversalCamera {
  41577. /**
  41578. * Instantiates a new Gamepad Camera
  41579. * This represents a FPS type of camera. This is only here for back compat purpose.
  41580. * Please use the UniversalCamera instead as both are identical.
  41581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41582. * @param name Define the name of the camera in the scene
  41583. * @param position Define the start position of the camera in the scene
  41584. * @param scene Define the scene the camera belongs to
  41585. */
  41586. constructor(name: string, position: Vector3, scene: Scene);
  41587. /**
  41588. * Gets the current object class name.
  41589. * @return the class name
  41590. */
  41591. getClassName(): string;
  41592. }
  41593. }
  41594. declare module BABYLON {
  41595. /** @hidden */
  41596. export var passPixelShader: {
  41597. name: string;
  41598. shader: string;
  41599. };
  41600. }
  41601. declare module BABYLON {
  41602. /** @hidden */
  41603. export var passCubePixelShader: {
  41604. name: string;
  41605. shader: string;
  41606. };
  41607. }
  41608. declare module BABYLON {
  41609. /**
  41610. * PassPostProcess which produces an output the same as it's input
  41611. */
  41612. export class PassPostProcess extends PostProcess {
  41613. /**
  41614. * Creates the PassPostProcess
  41615. * @param name The name of the effect.
  41616. * @param options The required width/height ratio to downsize to before computing the render pass.
  41617. * @param camera The camera to apply the render pass to.
  41618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41619. * @param engine The engine which the post process will be applied. (default: current engine)
  41620. * @param reusable If the post process can be reused on the same frame. (default: false)
  41621. * @param textureType The type of texture to be used when performing the post processing.
  41622. * @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)
  41623. */
  41624. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41625. }
  41626. /**
  41627. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41628. */
  41629. export class PassCubePostProcess extends PostProcess {
  41630. private _face;
  41631. /**
  41632. * Gets or sets the cube face to display.
  41633. * * 0 is +X
  41634. * * 1 is -X
  41635. * * 2 is +Y
  41636. * * 3 is -Y
  41637. * * 4 is +Z
  41638. * * 5 is -Z
  41639. */
  41640. get face(): number;
  41641. set face(value: number);
  41642. /**
  41643. * Creates the PassCubePostProcess
  41644. * @param name The name of the effect.
  41645. * @param options The required width/height ratio to downsize to before computing the render pass.
  41646. * @param camera The camera to apply the render pass to.
  41647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41648. * @param engine The engine which the post process will be applied. (default: current engine)
  41649. * @param reusable If the post process can be reused on the same frame. (default: false)
  41650. * @param textureType The type of texture to be used when performing the post processing.
  41651. * @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)
  41652. */
  41653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41654. }
  41655. }
  41656. declare module BABYLON {
  41657. /** @hidden */
  41658. export var anaglyphPixelShader: {
  41659. name: string;
  41660. shader: string;
  41661. };
  41662. }
  41663. declare module BABYLON {
  41664. /**
  41665. * Postprocess used to generate anaglyphic rendering
  41666. */
  41667. export class AnaglyphPostProcess extends PostProcess {
  41668. private _passedProcess;
  41669. /**
  41670. * Creates a new AnaglyphPostProcess
  41671. * @param name defines postprocess name
  41672. * @param options defines creation options or target ratio scale
  41673. * @param rigCameras defines cameras using this postprocess
  41674. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41675. * @param engine defines hosting engine
  41676. * @param reusable defines if the postprocess will be reused multiple times per frame
  41677. */
  41678. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41679. }
  41680. }
  41681. declare module BABYLON {
  41682. /**
  41683. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41684. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41685. */
  41686. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41687. /**
  41688. * Creates a new AnaglyphArcRotateCamera
  41689. * @param name defines camera name
  41690. * @param alpha defines alpha angle (in radians)
  41691. * @param beta defines beta angle (in radians)
  41692. * @param radius defines radius
  41693. * @param target defines camera target
  41694. * @param interaxialDistance defines distance between each color axis
  41695. * @param scene defines the hosting scene
  41696. */
  41697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41698. /**
  41699. * Gets camera class name
  41700. * @returns AnaglyphArcRotateCamera
  41701. */
  41702. getClassName(): string;
  41703. }
  41704. }
  41705. declare module BABYLON {
  41706. /**
  41707. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41708. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41709. */
  41710. export class AnaglyphFreeCamera extends FreeCamera {
  41711. /**
  41712. * Creates a new AnaglyphFreeCamera
  41713. * @param name defines camera name
  41714. * @param position defines initial position
  41715. * @param interaxialDistance defines distance between each color axis
  41716. * @param scene defines the hosting scene
  41717. */
  41718. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41719. /**
  41720. * Gets camera class name
  41721. * @returns AnaglyphFreeCamera
  41722. */
  41723. getClassName(): string;
  41724. }
  41725. }
  41726. declare module BABYLON {
  41727. /**
  41728. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41729. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41730. */
  41731. export class AnaglyphGamepadCamera extends GamepadCamera {
  41732. /**
  41733. * Creates a new AnaglyphGamepadCamera
  41734. * @param name defines camera name
  41735. * @param position defines initial position
  41736. * @param interaxialDistance defines distance between each color axis
  41737. * @param scene defines the hosting scene
  41738. */
  41739. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41740. /**
  41741. * Gets camera class name
  41742. * @returns AnaglyphGamepadCamera
  41743. */
  41744. getClassName(): string;
  41745. }
  41746. }
  41747. declare module BABYLON {
  41748. /**
  41749. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41750. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41751. */
  41752. export class AnaglyphUniversalCamera extends UniversalCamera {
  41753. /**
  41754. * Creates a new AnaglyphUniversalCamera
  41755. * @param name defines camera name
  41756. * @param position defines initial position
  41757. * @param interaxialDistance defines distance between each color axis
  41758. * @param scene defines the hosting scene
  41759. */
  41760. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41761. /**
  41762. * Gets camera class name
  41763. * @returns AnaglyphUniversalCamera
  41764. */
  41765. getClassName(): string;
  41766. }
  41767. }
  41768. declare module BABYLON {
  41769. /** @hidden */
  41770. export var stereoscopicInterlacePixelShader: {
  41771. name: string;
  41772. shader: string;
  41773. };
  41774. }
  41775. declare module BABYLON {
  41776. /**
  41777. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41778. */
  41779. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41780. private _stepSize;
  41781. private _passedProcess;
  41782. /**
  41783. * Initializes a StereoscopicInterlacePostProcessI
  41784. * @param name The name of the effect.
  41785. * @param rigCameras The rig cameras to be appled to the post process
  41786. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41787. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41789. * @param engine The engine which the post process will be applied. (default: current engine)
  41790. * @param reusable If the post process can be reused on the same frame. (default: false)
  41791. */
  41792. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41793. }
  41794. /**
  41795. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41796. */
  41797. export class StereoscopicInterlacePostProcess extends PostProcess {
  41798. private _stepSize;
  41799. private _passedProcess;
  41800. /**
  41801. * Initializes a StereoscopicInterlacePostProcess
  41802. * @param name The name of the effect.
  41803. * @param rigCameras The rig cameras to be appled to the post process
  41804. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41806. * @param engine The engine which the post process will be applied. (default: current engine)
  41807. * @param reusable If the post process can be reused on the same frame. (default: false)
  41808. */
  41809. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41810. }
  41811. }
  41812. declare module BABYLON {
  41813. /**
  41814. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41815. * @see http://doc.babylonjs.com/features/cameras
  41816. */
  41817. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41818. /**
  41819. * Creates a new StereoscopicArcRotateCamera
  41820. * @param name defines camera name
  41821. * @param alpha defines alpha angle (in radians)
  41822. * @param beta defines beta angle (in radians)
  41823. * @param radius defines radius
  41824. * @param target defines camera target
  41825. * @param interaxialDistance defines distance between each color axis
  41826. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41827. * @param scene defines the hosting scene
  41828. */
  41829. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41830. /**
  41831. * Gets camera class name
  41832. * @returns StereoscopicArcRotateCamera
  41833. */
  41834. getClassName(): string;
  41835. }
  41836. }
  41837. declare module BABYLON {
  41838. /**
  41839. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41840. * @see http://doc.babylonjs.com/features/cameras
  41841. */
  41842. export class StereoscopicFreeCamera extends FreeCamera {
  41843. /**
  41844. * Creates a new StereoscopicFreeCamera
  41845. * @param name defines camera name
  41846. * @param position defines initial position
  41847. * @param interaxialDistance defines distance between each color axis
  41848. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41849. * @param scene defines the hosting scene
  41850. */
  41851. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41852. /**
  41853. * Gets camera class name
  41854. * @returns StereoscopicFreeCamera
  41855. */
  41856. getClassName(): string;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41862. * @see http://doc.babylonjs.com/features/cameras
  41863. */
  41864. export class StereoscopicGamepadCamera extends GamepadCamera {
  41865. /**
  41866. * Creates a new StereoscopicGamepadCamera
  41867. * @param name defines camera name
  41868. * @param position defines initial position
  41869. * @param interaxialDistance defines distance between each color axis
  41870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41871. * @param scene defines the hosting scene
  41872. */
  41873. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41874. /**
  41875. * Gets camera class name
  41876. * @returns StereoscopicGamepadCamera
  41877. */
  41878. getClassName(): string;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41884. * @see http://doc.babylonjs.com/features/cameras
  41885. */
  41886. export class StereoscopicUniversalCamera extends UniversalCamera {
  41887. /**
  41888. * Creates a new StereoscopicUniversalCamera
  41889. * @param name defines camera name
  41890. * @param position defines initial position
  41891. * @param interaxialDistance defines distance between each color axis
  41892. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41893. * @param scene defines the hosting scene
  41894. */
  41895. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41896. /**
  41897. * Gets camera class name
  41898. * @returns StereoscopicUniversalCamera
  41899. */
  41900. getClassName(): string;
  41901. }
  41902. }
  41903. declare module BABYLON {
  41904. /**
  41905. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41906. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41907. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41908. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41909. */
  41910. export class VirtualJoysticksCamera extends FreeCamera {
  41911. /**
  41912. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41913. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41914. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41915. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41916. * @param name Define the name of the camera in the scene
  41917. * @param position Define the start position of the camera in the scene
  41918. * @param scene Define the scene the camera belongs to
  41919. */
  41920. constructor(name: string, position: Vector3, scene: Scene);
  41921. /**
  41922. * Gets the current object class name.
  41923. * @return the class name
  41924. */
  41925. getClassName(): string;
  41926. }
  41927. }
  41928. declare module BABYLON {
  41929. /**
  41930. * This represents all the required metrics to create a VR camera.
  41931. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41932. */
  41933. export class VRCameraMetrics {
  41934. /**
  41935. * Define the horizontal resolution off the screen.
  41936. */
  41937. hResolution: number;
  41938. /**
  41939. * Define the vertical resolution off the screen.
  41940. */
  41941. vResolution: number;
  41942. /**
  41943. * Define the horizontal screen size.
  41944. */
  41945. hScreenSize: number;
  41946. /**
  41947. * Define the vertical screen size.
  41948. */
  41949. vScreenSize: number;
  41950. /**
  41951. * Define the vertical screen center position.
  41952. */
  41953. vScreenCenter: number;
  41954. /**
  41955. * Define the distance of the eyes to the screen.
  41956. */
  41957. eyeToScreenDistance: number;
  41958. /**
  41959. * Define the distance between both lenses
  41960. */
  41961. lensSeparationDistance: number;
  41962. /**
  41963. * Define the distance between both viewer's eyes.
  41964. */
  41965. interpupillaryDistance: number;
  41966. /**
  41967. * Define the distortion factor of the VR postprocess.
  41968. * Please, touch with care.
  41969. */
  41970. distortionK: number[];
  41971. /**
  41972. * Define the chromatic aberration correction factors for the VR post process.
  41973. */
  41974. chromaAbCorrection: number[];
  41975. /**
  41976. * Define the scale factor of the post process.
  41977. * The smaller the better but the slower.
  41978. */
  41979. postProcessScaleFactor: number;
  41980. /**
  41981. * Define an offset for the lens center.
  41982. */
  41983. lensCenterOffset: number;
  41984. /**
  41985. * Define if the current vr camera should compensate the distortion of the lense or not.
  41986. */
  41987. compensateDistortion: boolean;
  41988. /**
  41989. * Defines if multiview should be enabled when rendering (Default: false)
  41990. */
  41991. multiviewEnabled: boolean;
  41992. /**
  41993. * Gets the rendering aspect ratio based on the provided resolutions.
  41994. */
  41995. get aspectRatio(): number;
  41996. /**
  41997. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41998. */
  41999. get aspectRatioFov(): number;
  42000. /**
  42001. * @hidden
  42002. */
  42003. get leftHMatrix(): Matrix;
  42004. /**
  42005. * @hidden
  42006. */
  42007. get rightHMatrix(): Matrix;
  42008. /**
  42009. * @hidden
  42010. */
  42011. get leftPreViewMatrix(): Matrix;
  42012. /**
  42013. * @hidden
  42014. */
  42015. get rightPreViewMatrix(): Matrix;
  42016. /**
  42017. * Get the default VRMetrics based on the most generic setup.
  42018. * @returns the default vr metrics
  42019. */
  42020. static GetDefault(): VRCameraMetrics;
  42021. }
  42022. }
  42023. declare module BABYLON {
  42024. /** @hidden */
  42025. export var vrDistortionCorrectionPixelShader: {
  42026. name: string;
  42027. shader: string;
  42028. };
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * VRDistortionCorrectionPostProcess used for mobile VR
  42033. */
  42034. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42035. private _isRightEye;
  42036. private _distortionFactors;
  42037. private _postProcessScaleFactor;
  42038. private _lensCenterOffset;
  42039. private _scaleIn;
  42040. private _scaleFactor;
  42041. private _lensCenter;
  42042. /**
  42043. * Initializes the VRDistortionCorrectionPostProcess
  42044. * @param name The name of the effect.
  42045. * @param camera The camera to apply the render pass to.
  42046. * @param isRightEye If this is for the right eye distortion
  42047. * @param vrMetrics All the required metrics for the VR camera
  42048. */
  42049. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42050. }
  42051. }
  42052. declare module BABYLON {
  42053. /**
  42054. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42055. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42056. */
  42057. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42058. /**
  42059. * Creates a new VRDeviceOrientationArcRotateCamera
  42060. * @param name defines camera name
  42061. * @param alpha defines the camera rotation along the logitudinal axis
  42062. * @param beta defines the camera rotation along the latitudinal axis
  42063. * @param radius defines the camera distance from its target
  42064. * @param target defines the camera target
  42065. * @param scene defines the scene the camera belongs to
  42066. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42067. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42068. */
  42069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42070. /**
  42071. * Gets camera class name
  42072. * @returns VRDeviceOrientationArcRotateCamera
  42073. */
  42074. getClassName(): string;
  42075. }
  42076. }
  42077. declare module BABYLON {
  42078. /**
  42079. * Camera used to simulate VR rendering (based on FreeCamera)
  42080. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42081. */
  42082. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42083. /**
  42084. * Creates a new VRDeviceOrientationFreeCamera
  42085. * @param name defines camera name
  42086. * @param position defines the start position of the camera
  42087. * @param scene defines the scene the camera belongs to
  42088. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42089. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42090. */
  42091. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42092. /**
  42093. * Gets camera class name
  42094. * @returns VRDeviceOrientationFreeCamera
  42095. */
  42096. getClassName(): string;
  42097. }
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42102. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42103. */
  42104. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42105. /**
  42106. * Creates a new VRDeviceOrientationGamepadCamera
  42107. * @param name defines camera name
  42108. * @param position defines the start position of the camera
  42109. * @param scene defines the scene the camera belongs to
  42110. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42111. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42112. */
  42113. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42114. /**
  42115. * Gets camera class name
  42116. * @returns VRDeviceOrientationGamepadCamera
  42117. */
  42118. getClassName(): string;
  42119. }
  42120. }
  42121. declare module BABYLON {
  42122. /** @hidden */
  42123. export var imageProcessingPixelShader: {
  42124. name: string;
  42125. shader: string;
  42126. };
  42127. }
  42128. declare module BABYLON {
  42129. /**
  42130. * ImageProcessingPostProcess
  42131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42132. */
  42133. export class ImageProcessingPostProcess extends PostProcess {
  42134. /**
  42135. * Default configuration related to image processing available in the PBR Material.
  42136. */
  42137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42138. /**
  42139. * Gets the image processing configuration used either in this material.
  42140. */
  42141. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42142. /**
  42143. * Sets the Default image processing configuration used either in the this material.
  42144. *
  42145. * If sets to null, the scene one is in use.
  42146. */
  42147. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42148. /**
  42149. * Keep track of the image processing observer to allow dispose and replace.
  42150. */
  42151. private _imageProcessingObserver;
  42152. /**
  42153. * Attaches a new image processing configuration to the PBR Material.
  42154. * @param configuration
  42155. */
  42156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42157. /**
  42158. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42159. */
  42160. get colorCurves(): Nullable<ColorCurves>;
  42161. /**
  42162. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42163. */
  42164. set colorCurves(value: Nullable<ColorCurves>);
  42165. /**
  42166. * Gets wether the color curves effect is enabled.
  42167. */
  42168. get colorCurvesEnabled(): boolean;
  42169. /**
  42170. * Sets wether the color curves effect is enabled.
  42171. */
  42172. set colorCurvesEnabled(value: boolean);
  42173. /**
  42174. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42175. */
  42176. get colorGradingTexture(): Nullable<BaseTexture>;
  42177. /**
  42178. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42179. */
  42180. set colorGradingTexture(value: Nullable<BaseTexture>);
  42181. /**
  42182. * Gets wether the color grading effect is enabled.
  42183. */
  42184. get colorGradingEnabled(): boolean;
  42185. /**
  42186. * Gets wether the color grading effect is enabled.
  42187. */
  42188. set colorGradingEnabled(value: boolean);
  42189. /**
  42190. * Gets exposure used in the effect.
  42191. */
  42192. get exposure(): number;
  42193. /**
  42194. * Sets exposure used in the effect.
  42195. */
  42196. set exposure(value: number);
  42197. /**
  42198. * Gets wether tonemapping is enabled or not.
  42199. */
  42200. get toneMappingEnabled(): boolean;
  42201. /**
  42202. * Sets wether tonemapping is enabled or not
  42203. */
  42204. set toneMappingEnabled(value: boolean);
  42205. /**
  42206. * Gets the type of tone mapping effect.
  42207. */
  42208. get toneMappingType(): number;
  42209. /**
  42210. * Sets the type of tone mapping effect.
  42211. */
  42212. set toneMappingType(value: number);
  42213. /**
  42214. * Gets contrast used in the effect.
  42215. */
  42216. get contrast(): number;
  42217. /**
  42218. * Sets contrast used in the effect.
  42219. */
  42220. set contrast(value: number);
  42221. /**
  42222. * Gets Vignette stretch size.
  42223. */
  42224. get vignetteStretch(): number;
  42225. /**
  42226. * Sets Vignette stretch size.
  42227. */
  42228. set vignetteStretch(value: number);
  42229. /**
  42230. * Gets Vignette centre X Offset.
  42231. */
  42232. get vignetteCentreX(): number;
  42233. /**
  42234. * Sets Vignette centre X Offset.
  42235. */
  42236. set vignetteCentreX(value: number);
  42237. /**
  42238. * Gets Vignette centre Y Offset.
  42239. */
  42240. get vignetteCentreY(): number;
  42241. /**
  42242. * Sets Vignette centre Y Offset.
  42243. */
  42244. set vignetteCentreY(value: number);
  42245. /**
  42246. * Gets Vignette weight or intensity of the vignette effect.
  42247. */
  42248. get vignetteWeight(): number;
  42249. /**
  42250. * Sets Vignette weight or intensity of the vignette effect.
  42251. */
  42252. set vignetteWeight(value: number);
  42253. /**
  42254. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42255. * if vignetteEnabled is set to true.
  42256. */
  42257. get vignetteColor(): Color4;
  42258. /**
  42259. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42260. * if vignetteEnabled is set to true.
  42261. */
  42262. set vignetteColor(value: Color4);
  42263. /**
  42264. * Gets Camera field of view used by the Vignette effect.
  42265. */
  42266. get vignetteCameraFov(): number;
  42267. /**
  42268. * Sets Camera field of view used by the Vignette effect.
  42269. */
  42270. set vignetteCameraFov(value: number);
  42271. /**
  42272. * Gets the vignette blend mode allowing different kind of effect.
  42273. */
  42274. get vignetteBlendMode(): number;
  42275. /**
  42276. * Sets the vignette blend mode allowing different kind of effect.
  42277. */
  42278. set vignetteBlendMode(value: number);
  42279. /**
  42280. * Gets wether the vignette effect is enabled.
  42281. */
  42282. get vignetteEnabled(): boolean;
  42283. /**
  42284. * Sets wether the vignette effect is enabled.
  42285. */
  42286. set vignetteEnabled(value: boolean);
  42287. private _fromLinearSpace;
  42288. /**
  42289. * Gets wether the input of the processing is in Gamma or Linear Space.
  42290. */
  42291. get fromLinearSpace(): boolean;
  42292. /**
  42293. * Sets wether the input of the processing is in Gamma or Linear Space.
  42294. */
  42295. set fromLinearSpace(value: boolean);
  42296. /**
  42297. * Defines cache preventing GC.
  42298. */
  42299. private _defines;
  42300. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42301. /**
  42302. * "ImageProcessingPostProcess"
  42303. * @returns "ImageProcessingPostProcess"
  42304. */
  42305. getClassName(): string;
  42306. protected _updateParameters(): void;
  42307. dispose(camera?: Camera): void;
  42308. }
  42309. }
  42310. declare module BABYLON {
  42311. /**
  42312. * Class containing static functions to help procedurally build meshes
  42313. */
  42314. export class GroundBuilder {
  42315. /**
  42316. * Creates a ground mesh
  42317. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42318. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42320. * @param name defines the name of the mesh
  42321. * @param options defines the options used to create the mesh
  42322. * @param scene defines the hosting scene
  42323. * @returns the ground mesh
  42324. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42325. */
  42326. static CreateGround(name: string, options: {
  42327. width?: number;
  42328. height?: number;
  42329. subdivisions?: number;
  42330. subdivisionsX?: number;
  42331. subdivisionsY?: number;
  42332. updatable?: boolean;
  42333. }, scene: any): Mesh;
  42334. /**
  42335. * Creates a tiled ground mesh
  42336. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42337. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42338. * * 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
  42339. * * 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
  42340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42341. * @param name defines the name of the mesh
  42342. * @param options defines the options used to create the mesh
  42343. * @param scene defines the hosting scene
  42344. * @returns the tiled ground mesh
  42345. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42346. */
  42347. static CreateTiledGround(name: string, options: {
  42348. xmin: number;
  42349. zmin: number;
  42350. xmax: number;
  42351. zmax: number;
  42352. subdivisions?: {
  42353. w: number;
  42354. h: number;
  42355. };
  42356. precision?: {
  42357. w: number;
  42358. h: number;
  42359. };
  42360. updatable?: boolean;
  42361. }, scene?: Nullable<Scene>): Mesh;
  42362. /**
  42363. * Creates a ground mesh from a height map
  42364. * * The parameter `url` sets the URL of the height map image resource.
  42365. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42366. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42367. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42368. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42369. * * 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.
  42370. * * 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).
  42371. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42373. * @param name defines the name of the mesh
  42374. * @param url defines the url to the height map
  42375. * @param options defines the options used to create the mesh
  42376. * @param scene defines the hosting scene
  42377. * @returns the ground mesh
  42378. * @see https://doc.babylonjs.com/babylon101/height_map
  42379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42380. */
  42381. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42382. width?: number;
  42383. height?: number;
  42384. subdivisions?: number;
  42385. minHeight?: number;
  42386. maxHeight?: number;
  42387. colorFilter?: Color3;
  42388. alphaFilter?: number;
  42389. updatable?: boolean;
  42390. onReady?: (mesh: GroundMesh) => void;
  42391. }, scene?: Nullable<Scene>): GroundMesh;
  42392. }
  42393. }
  42394. declare module BABYLON {
  42395. /**
  42396. * Class containing static functions to help procedurally build meshes
  42397. */
  42398. export class TorusBuilder {
  42399. /**
  42400. * Creates a torus mesh
  42401. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42402. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42403. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42405. * * 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
  42406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42407. * @param name defines the name of the mesh
  42408. * @param options defines the options used to create the mesh
  42409. * @param scene defines the hosting scene
  42410. * @returns the torus mesh
  42411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42412. */
  42413. static CreateTorus(name: string, options: {
  42414. diameter?: number;
  42415. thickness?: number;
  42416. tessellation?: number;
  42417. updatable?: boolean;
  42418. sideOrientation?: number;
  42419. frontUVs?: Vector4;
  42420. backUVs?: Vector4;
  42421. }, scene: any): Mesh;
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * Class containing static functions to help procedurally build meshes
  42427. */
  42428. export class CylinderBuilder {
  42429. /**
  42430. * Creates a cylinder or a cone mesh
  42431. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42432. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42433. * * 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.
  42434. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42435. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42436. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42437. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42438. * * 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).
  42439. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42440. * * 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).
  42441. * * 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
  42442. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42443. * * 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
  42444. * * 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.
  42445. * * If `enclose` is false, a ring surface is one element.
  42446. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42447. * * 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
  42448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42449. * * 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
  42450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42451. * @param name defines the name of the mesh
  42452. * @param options defines the options used to create the mesh
  42453. * @param scene defines the hosting scene
  42454. * @returns the cylinder mesh
  42455. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42456. */
  42457. static CreateCylinder(name: string, options: {
  42458. height?: number;
  42459. diameterTop?: number;
  42460. diameterBottom?: number;
  42461. diameter?: number;
  42462. tessellation?: number;
  42463. subdivisions?: number;
  42464. arc?: number;
  42465. faceColors?: Color4[];
  42466. faceUV?: Vector4[];
  42467. updatable?: boolean;
  42468. hasRings?: boolean;
  42469. enclose?: boolean;
  42470. cap?: number;
  42471. sideOrientation?: number;
  42472. frontUVs?: Vector4;
  42473. backUVs?: Vector4;
  42474. }, scene: any): Mesh;
  42475. }
  42476. }
  42477. declare module BABYLON {
  42478. /**
  42479. * States of the webXR experience
  42480. */
  42481. export enum WebXRState {
  42482. /**
  42483. * Transitioning to being in XR mode
  42484. */
  42485. ENTERING_XR = 0,
  42486. /**
  42487. * Transitioning to non XR mode
  42488. */
  42489. EXITING_XR = 1,
  42490. /**
  42491. * In XR mode and presenting
  42492. */
  42493. IN_XR = 2,
  42494. /**
  42495. * Not entered XR mode
  42496. */
  42497. NOT_IN_XR = 3
  42498. }
  42499. /**
  42500. * Abstraction of the XR render target
  42501. */
  42502. export interface WebXRRenderTarget extends IDisposable {
  42503. /**
  42504. * xrpresent context of the canvas which can be used to display/mirror xr content
  42505. */
  42506. canvasContext: WebGLRenderingContext;
  42507. /**
  42508. * xr layer for the canvas
  42509. */
  42510. xrLayer: Nullable<XRWebGLLayer>;
  42511. /**
  42512. * Initializes the xr layer for the session
  42513. * @param xrSession xr session
  42514. * @returns a promise that will resolve once the XR Layer has been created
  42515. */
  42516. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /**
  42521. * COnfiguration object for WebXR output canvas
  42522. */
  42523. export class WebXRManagedOutputCanvasOptions {
  42524. /**
  42525. * An optional canvas in case you wish to create it yourself and provide it here.
  42526. * If not provided, a new canvas will be created
  42527. */
  42528. canvasElement?: HTMLCanvasElement;
  42529. /**
  42530. * Options for this XR Layer output
  42531. */
  42532. canvasOptions?: XRWebGLLayerOptions;
  42533. /**
  42534. * CSS styling for a newly created canvas (if not provided)
  42535. */
  42536. newCanvasCssStyle?: string;
  42537. /**
  42538. * Get the default values of the configuration object
  42539. * @returns default values of this configuration object
  42540. */
  42541. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42542. }
  42543. /**
  42544. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42545. */
  42546. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42547. private _options;
  42548. private _canvas;
  42549. private _engine;
  42550. /**
  42551. * Rendering context of the canvas which can be used to display/mirror xr content
  42552. */
  42553. canvasContext: WebGLRenderingContext;
  42554. /**
  42555. * xr layer for the canvas
  42556. */
  42557. xrLayer: Nullable<XRWebGLLayer>;
  42558. /**
  42559. * Initializes the canvas to be added/removed upon entering/exiting xr
  42560. * @param _xrSessionManager The XR Session manager
  42561. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42562. */
  42563. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42564. /**
  42565. * Disposes of the object
  42566. */
  42567. dispose(): void;
  42568. /**
  42569. * Initializes the xr layer for the session
  42570. * @param xrSession xr session
  42571. * @returns a promise that will resolve once the XR Layer has been created
  42572. */
  42573. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42574. private _addCanvas;
  42575. private _removeCanvas;
  42576. private _setManagedOutputCanvas;
  42577. }
  42578. }
  42579. declare module BABYLON {
  42580. /**
  42581. * Manages an XRSession to work with Babylon's engine
  42582. * @see https://doc.babylonjs.com/how_to/webxr
  42583. */
  42584. export class WebXRSessionManager implements IDisposable {
  42585. /** The scene which the session should be created for */
  42586. scene: Scene;
  42587. private _referenceSpace;
  42588. private _rttProvider;
  42589. private _sessionEnded;
  42590. private _xrNavigator;
  42591. private baseLayer;
  42592. /**
  42593. * The base reference space from which the session started. good if you want to reset your
  42594. * reference space
  42595. */
  42596. baseReferenceSpace: XRReferenceSpace;
  42597. /**
  42598. * Current XR frame
  42599. */
  42600. currentFrame: Nullable<XRFrame>;
  42601. /** WebXR timestamp updated every frame */
  42602. currentTimestamp: number;
  42603. /**
  42604. * Used just in case of a failure to initialize an immersive session.
  42605. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42606. */
  42607. defaultHeightCompensation: number;
  42608. /**
  42609. * Fires every time a new xrFrame arrives which can be used to update the camera
  42610. */
  42611. onXRFrameObservable: Observable<XRFrame>;
  42612. /**
  42613. * Fires when the reference space changed
  42614. */
  42615. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42616. /**
  42617. * Fires when the xr session is ended either by the device or manually done
  42618. */
  42619. onXRSessionEnded: Observable<any>;
  42620. /**
  42621. * Fires when the xr session is ended either by the device or manually done
  42622. */
  42623. onXRSessionInit: Observable<XRSession>;
  42624. /**
  42625. * Underlying xr session
  42626. */
  42627. session: XRSession;
  42628. /**
  42629. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42630. * or get the offset the player is currently at.
  42631. */
  42632. viewerReferenceSpace: XRReferenceSpace;
  42633. /**
  42634. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42635. * @param scene The scene which the session should be created for
  42636. */
  42637. constructor(
  42638. /** The scene which the session should be created for */
  42639. scene: Scene);
  42640. /**
  42641. * The current reference space used in this session. This reference space can constantly change!
  42642. * It is mainly used to offset the camera's position.
  42643. */
  42644. get referenceSpace(): XRReferenceSpace;
  42645. /**
  42646. * Set a new reference space and triggers the observable
  42647. */
  42648. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42649. /**
  42650. * Disposes of the session manager
  42651. */
  42652. dispose(): void;
  42653. /**
  42654. * Stops the xrSession and restores the render loop
  42655. * @returns Promise which resolves after it exits XR
  42656. */
  42657. exitXRAsync(): Promise<void>;
  42658. /**
  42659. * Gets the correct render target texture to be rendered this frame for this eye
  42660. * @param eye the eye for which to get the render target
  42661. * @returns the render target for the specified eye
  42662. */
  42663. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42664. /**
  42665. * Creates a WebXRRenderTarget object for the XR session
  42666. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42667. * @param options optional options to provide when creating a new render target
  42668. * @returns a WebXR render target to which the session can render
  42669. */
  42670. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42671. /**
  42672. * Initializes the manager
  42673. * After initialization enterXR can be called to start an XR session
  42674. * @returns Promise which resolves after it is initialized
  42675. */
  42676. initializeAsync(): Promise<void>;
  42677. /**
  42678. * Initializes an xr session
  42679. * @param xrSessionMode mode to initialize
  42680. * @param xrSessionInit defines optional and required values to pass to the session builder
  42681. * @returns a promise which will resolve once the session has been initialized
  42682. */
  42683. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42684. /**
  42685. * Checks if a session would be supported for the creation options specified
  42686. * @param sessionMode session mode to check if supported eg. immersive-vr
  42687. * @returns A Promise that resolves to true if supported and false if not
  42688. */
  42689. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42690. /**
  42691. * Resets the reference space to the one started the session
  42692. */
  42693. resetReferenceSpace(): void;
  42694. /**
  42695. * Starts rendering to the xr layer
  42696. */
  42697. runXRRenderLoop(): void;
  42698. /**
  42699. * Sets the reference space on the xr session
  42700. * @param referenceSpaceType space to set
  42701. * @returns a promise that will resolve once the reference space has been set
  42702. */
  42703. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42704. /**
  42705. * Updates the render state of the session
  42706. * @param state state to set
  42707. * @returns a promise that resolves once the render state has been updated
  42708. */
  42709. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42710. /**
  42711. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42712. * @param sessionMode defines the session to test
  42713. * @returns a promise with boolean as final value
  42714. */
  42715. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42716. private _createRenderTargetTexture;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * WebXR Camera which holds the views for the xrSession
  42722. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42723. */
  42724. export class WebXRCamera extends FreeCamera {
  42725. private _xrSessionManager;
  42726. private _firstFrame;
  42727. private _referenceQuaternion;
  42728. private _referencedPosition;
  42729. private _xrInvPositionCache;
  42730. private _xrInvQuaternionCache;
  42731. /**
  42732. * Should position compensation execute on first frame.
  42733. * This is used when copying the position from a native (non XR) camera
  42734. */
  42735. compensateOnFirstFrame: boolean;
  42736. /**
  42737. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42738. * @param name the name of the camera
  42739. * @param scene the scene to add the camera to
  42740. * @param _xrSessionManager a constructed xr session manager
  42741. */
  42742. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42743. /**
  42744. * Return the user's height, unrelated to the current ground.
  42745. * This will be the y position of this camera, when ground level is 0.
  42746. */
  42747. get realWorldHeight(): number;
  42748. /** @hidden */
  42749. _updateForDualEyeDebugging(): void;
  42750. /**
  42751. * Sets this camera's transformation based on a non-vr camera
  42752. * @param otherCamera the non-vr camera to copy the transformation from
  42753. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42754. */
  42755. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42756. private _updateFromXRSession;
  42757. private _updateNumberOfRigCameras;
  42758. private _updateReferenceSpace;
  42759. private _updateReferenceSpaceOffset;
  42760. }
  42761. }
  42762. declare module BABYLON {
  42763. /**
  42764. * Defining the interface required for a (webxr) feature
  42765. */
  42766. export interface IWebXRFeature extends IDisposable {
  42767. /**
  42768. * Is this feature attached
  42769. */
  42770. attached: boolean;
  42771. /**
  42772. * Should auto-attach be disabled?
  42773. */
  42774. disableAutoAttach: boolean;
  42775. /**
  42776. * Attach the feature to the session
  42777. * Will usually be called by the features manager
  42778. *
  42779. * @param force should attachment be forced (even when already attached)
  42780. * @returns true if successful.
  42781. */
  42782. attach(force?: boolean): boolean;
  42783. /**
  42784. * Detach the feature from the session
  42785. * Will usually be called by the features manager
  42786. *
  42787. * @returns true if successful.
  42788. */
  42789. detach(): boolean;
  42790. }
  42791. /**
  42792. * A list of the currently available features without referencing them
  42793. */
  42794. export class WebXRFeatureName {
  42795. /**
  42796. * The name of the anchor system feature
  42797. */
  42798. static ANCHOR_SYSTEM: string;
  42799. /**
  42800. * The name of the background remover feature
  42801. */
  42802. static BACKGROUND_REMOVER: string;
  42803. /**
  42804. * The name of the hit test feature
  42805. */
  42806. static HIT_TEST: string;
  42807. /**
  42808. * physics impostors for xr controllers feature
  42809. */
  42810. static PHYSICS_CONTROLLERS: string;
  42811. /**
  42812. * The name of the plane detection feature
  42813. */
  42814. static PLANE_DETECTION: string;
  42815. /**
  42816. * The name of the pointer selection feature
  42817. */
  42818. static POINTER_SELECTION: string;
  42819. /**
  42820. * The name of the teleportation feature
  42821. */
  42822. static TELEPORTATION: string;
  42823. }
  42824. /**
  42825. * Defining the constructor of a feature. Used to register the modules.
  42826. */
  42827. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42828. /**
  42829. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42830. * It is mainly used in AR sessions.
  42831. *
  42832. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42833. */
  42834. export class WebXRFeaturesManager implements IDisposable {
  42835. private _xrSessionManager;
  42836. private static readonly _AvailableFeatures;
  42837. private _features;
  42838. /**
  42839. * constructs a new features manages.
  42840. *
  42841. * @param _xrSessionManager an instance of WebXRSessionManager
  42842. */
  42843. constructor(_xrSessionManager: WebXRSessionManager);
  42844. /**
  42845. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42846. * Mainly used internally.
  42847. *
  42848. * @param featureName the name of the feature to register
  42849. * @param constructorFunction the function used to construct the module
  42850. * @param version the (babylon) version of the module
  42851. * @param stable is that a stable version of this module
  42852. */
  42853. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42854. /**
  42855. * Returns a constructor of a specific feature.
  42856. *
  42857. * @param featureName the name of the feature to construct
  42858. * @param version the version of the feature to load
  42859. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42860. * @param options optional options provided to the module.
  42861. * @returns a function that, when called, will return a new instance of this feature
  42862. */
  42863. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42864. /**
  42865. * Can be used to return the list of features currently registered
  42866. *
  42867. * @returns an Array of available features
  42868. */
  42869. static GetAvailableFeatures(): string[];
  42870. /**
  42871. * Gets the versions available for a specific feature
  42872. * @param featureName the name of the feature
  42873. * @returns an array with the available versions
  42874. */
  42875. static GetAvailableVersions(featureName: string): string[];
  42876. /**
  42877. * Return the latest unstable version of this feature
  42878. * @param featureName the name of the feature to search
  42879. * @returns the version number. if not found will return -1
  42880. */
  42881. static GetLatestVersionOfFeature(featureName: string): number;
  42882. /**
  42883. * Return the latest stable version of this feature
  42884. * @param featureName the name of the feature to search
  42885. * @returns the version number. if not found will return -1
  42886. */
  42887. static GetStableVersionOfFeature(featureName: string): number;
  42888. /**
  42889. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42890. * Can be used during a session to start a feature
  42891. * @param featureName the name of feature to attach
  42892. */
  42893. attachFeature(featureName: string): void;
  42894. /**
  42895. * Can be used inside a session or when the session ends to detach a specific feature
  42896. * @param featureName the name of the feature to detach
  42897. */
  42898. detachFeature(featureName: string): void;
  42899. /**
  42900. * Used to disable an already-enabled feature
  42901. * The feature will be disposed and will be recreated once enabled.
  42902. * @param featureName the feature to disable
  42903. * @returns true if disable was successful
  42904. */
  42905. disableFeature(featureName: string | {
  42906. Name: string;
  42907. }): boolean;
  42908. /**
  42909. * dispose this features manager
  42910. */
  42911. dispose(): void;
  42912. /**
  42913. * 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.
  42914. * 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.
  42915. *
  42916. * @param featureName the name of the feature to load or the class of the feature
  42917. * @param version optional version to load. if not provided the latest version will be enabled
  42918. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42919. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42920. * @returns a new constructed feature or throws an error if feature not found.
  42921. */
  42922. enableFeature(featureName: string | {
  42923. Name: string;
  42924. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42925. /**
  42926. * get the implementation of an enabled feature.
  42927. * @param featureName the name of the feature to load
  42928. * @returns the feature class, if found
  42929. */
  42930. getEnabledFeature(featureName: string): IWebXRFeature;
  42931. /**
  42932. * Get the list of enabled features
  42933. * @returns an array of enabled features
  42934. */
  42935. getEnabledFeatures(): string[];
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  42941. * @see https://doc.babylonjs.com/how_to/webxr
  42942. */
  42943. export class WebXRExperienceHelper implements IDisposable {
  42944. private scene;
  42945. private _nonVRCamera;
  42946. private _originalSceneAutoClear;
  42947. private _supported;
  42948. /**
  42949. * Camera used to render xr content
  42950. */
  42951. camera: WebXRCamera;
  42952. /** A features manager for this xr session */
  42953. featuresManager: WebXRFeaturesManager;
  42954. /**
  42955. * Observers registered here will be triggered after the camera's initial transformation is set
  42956. * This can be used to set a different ground level or an extra rotation.
  42957. *
  42958. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42959. * to the position set after this observable is done executing.
  42960. */
  42961. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42962. /**
  42963. * Fires when the state of the experience helper has changed
  42964. */
  42965. onStateChangedObservable: Observable<WebXRState>;
  42966. /** Session manager used to keep track of xr session */
  42967. sessionManager: WebXRSessionManager;
  42968. /**
  42969. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42970. */
  42971. state: WebXRState;
  42972. /**
  42973. * Creates a WebXRExperienceHelper
  42974. * @param scene The scene the helper should be created in
  42975. */
  42976. private constructor();
  42977. /**
  42978. * Creates the experience helper
  42979. * @param scene the scene to attach the experience helper to
  42980. * @returns a promise for the experience helper
  42981. */
  42982. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42983. /**
  42984. * Disposes of the experience helper
  42985. */
  42986. dispose(): void;
  42987. /**
  42988. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42989. * @param sessionMode options for the XR session
  42990. * @param referenceSpaceType frame of reference of the XR session
  42991. * @param renderTarget the output canvas that will be used to enter XR mode
  42992. * @returns promise that resolves after xr mode has entered
  42993. */
  42994. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42995. /**
  42996. * Exits XR mode and returns the scene to its original state
  42997. * @returns promise that resolves after xr mode has exited
  42998. */
  42999. exitXRAsync(): Promise<void>;
  43000. private _nonXRToXRCamera;
  43001. private _setState;
  43002. }
  43003. }
  43004. declare module BABYLON {
  43005. /**
  43006. * X-Y values for axes in WebXR
  43007. */
  43008. export interface IWebXRMotionControllerAxesValue {
  43009. /**
  43010. * The value of the x axis
  43011. */
  43012. x: number;
  43013. /**
  43014. * The value of the y-axis
  43015. */
  43016. y: number;
  43017. }
  43018. /**
  43019. * changed / previous values for the values of this component
  43020. */
  43021. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43022. /**
  43023. * current (this frame) value
  43024. */
  43025. current: T;
  43026. /**
  43027. * previous (last change) value
  43028. */
  43029. previous: T;
  43030. }
  43031. /**
  43032. * Represents changes in the component between current frame and last values recorded
  43033. */
  43034. export interface IWebXRMotionControllerComponentChanges {
  43035. /**
  43036. * will be populated with previous and current values if axes changed
  43037. */
  43038. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43039. /**
  43040. * will be populated with previous and current values if pressed changed
  43041. */
  43042. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43043. /**
  43044. * will be populated with previous and current values if touched changed
  43045. */
  43046. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43047. /**
  43048. * will be populated with previous and current values if value changed
  43049. */
  43050. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43051. }
  43052. /**
  43053. * This class represents a single component (for example button or thumbstick) of a motion controller
  43054. */
  43055. export class WebXRControllerComponent implements IDisposable {
  43056. /**
  43057. * the id of this component
  43058. */
  43059. id: string;
  43060. /**
  43061. * the type of the component
  43062. */
  43063. type: MotionControllerComponentType;
  43064. private _buttonIndex;
  43065. private _axesIndices;
  43066. private _axes;
  43067. private _changes;
  43068. private _currentValue;
  43069. private _hasChanges;
  43070. private _pressed;
  43071. private _touched;
  43072. /**
  43073. * button component type
  43074. */
  43075. static BUTTON_TYPE: MotionControllerComponentType;
  43076. /**
  43077. * squeeze component type
  43078. */
  43079. static SQUEEZE_TYPE: MotionControllerComponentType;
  43080. /**
  43081. * Thumbstick component type
  43082. */
  43083. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43084. /**
  43085. * Touchpad component type
  43086. */
  43087. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43088. /**
  43089. * trigger component type
  43090. */
  43091. static TRIGGER_TYPE: MotionControllerComponentType;
  43092. /**
  43093. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43094. * the axes data changes
  43095. */
  43096. onAxisValueChangedObservable: Observable<{
  43097. x: number;
  43098. y: number;
  43099. }>;
  43100. /**
  43101. * Observers registered here will be triggered when the state of a button changes
  43102. * State change is either pressed / touched / value
  43103. */
  43104. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43105. /**
  43106. * Creates a new component for a motion controller.
  43107. * It is created by the motion controller itself
  43108. *
  43109. * @param id the id of this component
  43110. * @param type the type of the component
  43111. * @param _buttonIndex index in the buttons array of the gamepad
  43112. * @param _axesIndices indices of the values in the axes array of the gamepad
  43113. */
  43114. constructor(
  43115. /**
  43116. * the id of this component
  43117. */
  43118. id: string,
  43119. /**
  43120. * the type of the component
  43121. */
  43122. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43123. /**
  43124. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43125. */
  43126. get axes(): IWebXRMotionControllerAxesValue;
  43127. /**
  43128. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43129. */
  43130. get changes(): IWebXRMotionControllerComponentChanges;
  43131. /**
  43132. * Return whether or not the component changed the last frame
  43133. */
  43134. get hasChanges(): boolean;
  43135. /**
  43136. * is the button currently pressed
  43137. */
  43138. get pressed(): boolean;
  43139. /**
  43140. * is the button currently touched
  43141. */
  43142. get touched(): boolean;
  43143. /**
  43144. * Get the current value of this component
  43145. */
  43146. get value(): number;
  43147. /**
  43148. * Dispose this component
  43149. */
  43150. dispose(): void;
  43151. /**
  43152. * Are there axes correlating to this component
  43153. * @return true is axes data is available
  43154. */
  43155. isAxes(): boolean;
  43156. /**
  43157. * Is this component a button (hence - pressable)
  43158. * @returns true if can be pressed
  43159. */
  43160. isButton(): boolean;
  43161. /**
  43162. * update this component using the gamepad object it is in. Called on every frame
  43163. * @param nativeController the native gamepad controller object
  43164. */
  43165. update(nativeController: IMinimalMotionControllerObject): void;
  43166. }
  43167. }
  43168. declare module BABYLON {
  43169. /**
  43170. * Class used to represent data loading progression
  43171. */
  43172. export class SceneLoaderProgressEvent {
  43173. /** defines if data length to load can be evaluated */
  43174. readonly lengthComputable: boolean;
  43175. /** defines the loaded data length */
  43176. readonly loaded: number;
  43177. /** defines the data length to load */
  43178. readonly total: number;
  43179. /**
  43180. * Create a new progress event
  43181. * @param lengthComputable defines if data length to load can be evaluated
  43182. * @param loaded defines the loaded data length
  43183. * @param total defines the data length to load
  43184. */
  43185. constructor(
  43186. /** defines if data length to load can be evaluated */
  43187. lengthComputable: boolean,
  43188. /** defines the loaded data length */
  43189. loaded: number,
  43190. /** defines the data length to load */
  43191. total: number);
  43192. /**
  43193. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43194. * @param event defines the source event
  43195. * @returns a new SceneLoaderProgressEvent
  43196. */
  43197. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43198. }
  43199. /**
  43200. * Interface used by SceneLoader plugins to define supported file extensions
  43201. */
  43202. export interface ISceneLoaderPluginExtensions {
  43203. /**
  43204. * Defines the list of supported extensions
  43205. */
  43206. [extension: string]: {
  43207. isBinary: boolean;
  43208. };
  43209. }
  43210. /**
  43211. * Interface used by SceneLoader plugin factory
  43212. */
  43213. export interface ISceneLoaderPluginFactory {
  43214. /**
  43215. * Defines the name of the factory
  43216. */
  43217. name: string;
  43218. /**
  43219. * Function called to create a new plugin
  43220. * @return the new plugin
  43221. */
  43222. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43223. /**
  43224. * The callback that returns true if the data can be directly loaded.
  43225. * @param data string containing the file data
  43226. * @returns if the data can be loaded directly
  43227. */
  43228. canDirectLoad?(data: string): boolean;
  43229. }
  43230. /**
  43231. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43232. */
  43233. export interface ISceneLoaderPluginBase {
  43234. /**
  43235. * The friendly name of this plugin.
  43236. */
  43237. name: string;
  43238. /**
  43239. * The file extensions supported by this plugin.
  43240. */
  43241. extensions: string | ISceneLoaderPluginExtensions;
  43242. /**
  43243. * The callback called when loading from a url.
  43244. * @param scene scene loading this url
  43245. * @param url url to load
  43246. * @param onSuccess callback called when the file successfully loads
  43247. * @param onProgress callback called while file is loading (if the server supports this mode)
  43248. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43249. * @param onError callback called when the file fails to load
  43250. * @returns a file request object
  43251. */
  43252. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43253. /**
  43254. * The callback called when loading from a file object.
  43255. * @param scene scene loading this file
  43256. * @param file defines the file to load
  43257. * @param onSuccess defines the callback to call when data is loaded
  43258. * @param onProgress defines the callback to call during loading process
  43259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43260. * @param onError defines the callback to call when an error occurs
  43261. * @returns a file request object
  43262. */
  43263. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43264. /**
  43265. * The callback that returns true if the data can be directly loaded.
  43266. * @param data string containing the file data
  43267. * @returns if the data can be loaded directly
  43268. */
  43269. canDirectLoad?(data: string): boolean;
  43270. /**
  43271. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43272. * @param scene scene loading this data
  43273. * @param data string containing the data
  43274. * @returns data to pass to the plugin
  43275. */
  43276. directLoad?(scene: Scene, data: string): any;
  43277. /**
  43278. * The callback that allows custom handling of the root url based on the response url.
  43279. * @param rootUrl the original root url
  43280. * @param responseURL the response url if available
  43281. * @returns the new root url
  43282. */
  43283. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43284. }
  43285. /**
  43286. * Interface used to define a SceneLoader plugin
  43287. */
  43288. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43289. /**
  43290. * Import meshes into a scene.
  43291. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43292. * @param scene The scene to import into
  43293. * @param data The data to import
  43294. * @param rootUrl The root url for scene and resources
  43295. * @param meshes The meshes array to import into
  43296. * @param particleSystems The particle systems array to import into
  43297. * @param skeletons The skeletons array to import into
  43298. * @param onError The callback when import fails
  43299. * @returns True if successful or false otherwise
  43300. */
  43301. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43302. /**
  43303. * Load into a scene.
  43304. * @param scene The scene to load into
  43305. * @param data The data to import
  43306. * @param rootUrl The root url for scene and resources
  43307. * @param onError The callback when import fails
  43308. * @returns True if successful or false otherwise
  43309. */
  43310. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43311. /**
  43312. * Load into an asset container.
  43313. * @param scene The scene to load into
  43314. * @param data The data to import
  43315. * @param rootUrl The root url for scene and resources
  43316. * @param onError The callback when import fails
  43317. * @returns The loaded asset container
  43318. */
  43319. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43320. }
  43321. /**
  43322. * Interface used to define an async SceneLoader plugin
  43323. */
  43324. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43325. /**
  43326. * Import meshes into a scene.
  43327. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43328. * @param scene The scene to import into
  43329. * @param data The data to import
  43330. * @param rootUrl The root url for scene and resources
  43331. * @param onProgress The callback when the load progresses
  43332. * @param fileName Defines the name of the file to load
  43333. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43334. */
  43335. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43336. meshes: AbstractMesh[];
  43337. particleSystems: IParticleSystem[];
  43338. skeletons: Skeleton[];
  43339. animationGroups: AnimationGroup[];
  43340. }>;
  43341. /**
  43342. * Load into a scene.
  43343. * @param scene The scene to load into
  43344. * @param data The data to import
  43345. * @param rootUrl The root url for scene and resources
  43346. * @param onProgress The callback when the load progresses
  43347. * @param fileName Defines the name of the file to load
  43348. * @returns Nothing
  43349. */
  43350. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43351. /**
  43352. * Load into an asset container.
  43353. * @param scene The scene to load into
  43354. * @param data The data to import
  43355. * @param rootUrl The root url for scene and resources
  43356. * @param onProgress The callback when the load progresses
  43357. * @param fileName Defines the name of the file to load
  43358. * @returns The loaded asset container
  43359. */
  43360. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43361. }
  43362. /**
  43363. * Mode that determines how to handle old animation groups before loading new ones.
  43364. */
  43365. export enum SceneLoaderAnimationGroupLoadingMode {
  43366. /**
  43367. * Reset all old animations to initial state then dispose them.
  43368. */
  43369. Clean = 0,
  43370. /**
  43371. * Stop all old animations.
  43372. */
  43373. Stop = 1,
  43374. /**
  43375. * Restart old animations from first frame.
  43376. */
  43377. Sync = 2,
  43378. /**
  43379. * Old animations remains untouched.
  43380. */
  43381. NoSync = 3
  43382. }
  43383. /**
  43384. * Class used to load scene from various file formats using registered plugins
  43385. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43386. */
  43387. export class SceneLoader {
  43388. /**
  43389. * No logging while loading
  43390. */
  43391. static readonly NO_LOGGING: number;
  43392. /**
  43393. * Minimal logging while loading
  43394. */
  43395. static readonly MINIMAL_LOGGING: number;
  43396. /**
  43397. * Summary logging while loading
  43398. */
  43399. static readonly SUMMARY_LOGGING: number;
  43400. /**
  43401. * Detailled logging while loading
  43402. */
  43403. static readonly DETAILED_LOGGING: number;
  43404. /**
  43405. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43406. */
  43407. static get ForceFullSceneLoadingForIncremental(): boolean;
  43408. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43409. /**
  43410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43411. */
  43412. static get ShowLoadingScreen(): boolean;
  43413. static set ShowLoadingScreen(value: boolean);
  43414. /**
  43415. * Defines the current logging level (while loading the scene)
  43416. * @ignorenaming
  43417. */
  43418. static get loggingLevel(): number;
  43419. static set loggingLevel(value: number);
  43420. /**
  43421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43422. */
  43423. static get CleanBoneMatrixWeights(): boolean;
  43424. static set CleanBoneMatrixWeights(value: boolean);
  43425. /**
  43426. * Event raised when a plugin is used to load a scene
  43427. */
  43428. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43429. private static _registeredPlugins;
  43430. private static _getDefaultPlugin;
  43431. private static _getPluginForExtension;
  43432. private static _getPluginForDirectLoad;
  43433. private static _getPluginForFilename;
  43434. private static _getDirectLoad;
  43435. private static _loadData;
  43436. private static _getFileInfo;
  43437. /**
  43438. * Gets a plugin that can load the given extension
  43439. * @param extension defines the extension to load
  43440. * @returns a plugin or null if none works
  43441. */
  43442. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43443. /**
  43444. * Gets a boolean indicating that the given extension can be loaded
  43445. * @param extension defines the extension to load
  43446. * @returns true if the extension is supported
  43447. */
  43448. static IsPluginForExtensionAvailable(extension: string): boolean;
  43449. /**
  43450. * Adds a new plugin to the list of registered plugins
  43451. * @param plugin defines the plugin to add
  43452. */
  43453. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43454. /**
  43455. * Import meshes into a scene
  43456. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43457. * @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)
  43458. * @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)
  43459. * @param scene the instance of BABYLON.Scene to append to
  43460. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43461. * @param onProgress a callback with a progress event for each file being loaded
  43462. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43463. * @param pluginExtension the extension used to determine the plugin
  43464. * @returns The loaded plugin
  43465. */
  43466. 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>;
  43467. /**
  43468. * Import meshes into a scene
  43469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43470. * @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)
  43471. * @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)
  43472. * @param scene the instance of BABYLON.Scene to append to
  43473. * @param onProgress a callback with a progress event for each file being loaded
  43474. * @param pluginExtension the extension used to determine the plugin
  43475. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43476. */
  43477. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43478. meshes: AbstractMesh[];
  43479. particleSystems: IParticleSystem[];
  43480. skeletons: Skeleton[];
  43481. animationGroups: AnimationGroup[];
  43482. }>;
  43483. /**
  43484. * Load a scene
  43485. * @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)
  43486. * @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)
  43487. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43488. * @param onSuccess a callback with the scene when import succeeds
  43489. * @param onProgress a callback with a progress event for each file being loaded
  43490. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43491. * @param pluginExtension the extension used to determine the plugin
  43492. * @returns The loaded plugin
  43493. */
  43494. 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>;
  43495. /**
  43496. * Load a scene
  43497. * @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)
  43498. * @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)
  43499. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43500. * @param onProgress a callback with a progress event for each file being loaded
  43501. * @param pluginExtension the extension used to determine the plugin
  43502. * @returns The loaded scene
  43503. */
  43504. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43505. /**
  43506. * Append a scene
  43507. * @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)
  43508. * @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)
  43509. * @param scene is the instance of BABYLON.Scene to append to
  43510. * @param onSuccess a callback with the scene when import succeeds
  43511. * @param onProgress a callback with a progress event for each file being loaded
  43512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43513. * @param pluginExtension the extension used to determine the plugin
  43514. * @returns The loaded plugin
  43515. */
  43516. 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>;
  43517. /**
  43518. * Append a scene
  43519. * @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)
  43520. * @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)
  43521. * @param scene is the instance of BABYLON.Scene to append to
  43522. * @param onProgress a callback with a progress event for each file being loaded
  43523. * @param pluginExtension the extension used to determine the plugin
  43524. * @returns The given scene
  43525. */
  43526. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43527. /**
  43528. * Load a scene into an asset container
  43529. * @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)
  43530. * @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)
  43531. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43532. * @param onSuccess a callback with the scene when import succeeds
  43533. * @param onProgress a callback with a progress event for each file being loaded
  43534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43535. * @param pluginExtension the extension used to determine the plugin
  43536. * @returns The loaded plugin
  43537. */
  43538. 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>;
  43539. /**
  43540. * Load a scene into an asset container
  43541. * @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)
  43542. * @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)
  43543. * @param scene is the instance of Scene to append to
  43544. * @param onProgress a callback with a progress event for each file being loaded
  43545. * @param pluginExtension the extension used to determine the plugin
  43546. * @returns The loaded asset container
  43547. */
  43548. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43549. /**
  43550. * Import animations from a file into a scene
  43551. * @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)
  43552. * @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)
  43553. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43554. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43555. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43556. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43557. * @param onSuccess a callback with the scene when import succeeds
  43558. * @param onProgress a callback with a progress event for each file being loaded
  43559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43560. */
  43561. 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;
  43562. /**
  43563. * Import animations from a file into a scene
  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 or a File object (default: empty string)
  43566. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43567. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43568. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43569. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43570. * @param onSuccess a callback with the scene when import succeeds
  43571. * @param onProgress a callback with a progress event for each file being loaded
  43572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43573. * @returns the updated scene with imported animations
  43574. */
  43575. 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>;
  43576. }
  43577. }
  43578. declare module BABYLON {
  43579. /**
  43580. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43581. */
  43582. export type MotionControllerHandness = "none" | "left" | "right";
  43583. /**
  43584. * The type of components available in motion controllers.
  43585. * This is not the name of the component.
  43586. */
  43587. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43588. /**
  43589. * The state of a controller component
  43590. */
  43591. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43592. /**
  43593. * The schema of motion controller layout.
  43594. * No object will be initialized using this interface
  43595. * This is used just to define the profile.
  43596. */
  43597. export interface IMotionControllerLayout {
  43598. /**
  43599. * Path to load the assets. Usually relative to the base path
  43600. */
  43601. assetPath: string;
  43602. /**
  43603. * Available components (unsorted)
  43604. */
  43605. components: {
  43606. /**
  43607. * A map of component Ids
  43608. */
  43609. [componentId: string]: {
  43610. /**
  43611. * The type of input the component outputs
  43612. */
  43613. type: MotionControllerComponentType;
  43614. /**
  43615. * The indices of this component in the gamepad object
  43616. */
  43617. gamepadIndices: {
  43618. /**
  43619. * Index of button
  43620. */
  43621. button?: number;
  43622. /**
  43623. * If available, index of x-axis
  43624. */
  43625. xAxis?: number;
  43626. /**
  43627. * If available, index of y-axis
  43628. */
  43629. yAxis?: number;
  43630. };
  43631. /**
  43632. * The mesh's root node name
  43633. */
  43634. rootNodeName: string;
  43635. /**
  43636. * Animation definitions for this model
  43637. */
  43638. visualResponses: {
  43639. [stateKey: string]: {
  43640. /**
  43641. * What property will be animated
  43642. */
  43643. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43644. /**
  43645. * What states influence this visual response
  43646. */
  43647. states: MotionControllerComponentStateType[];
  43648. /**
  43649. * Type of animation - movement or visibility
  43650. */
  43651. valueNodeProperty: "transform" | "visibility";
  43652. /**
  43653. * Base node name to move. Its position will be calculated according to the min and max nodes
  43654. */
  43655. valueNodeName?: string;
  43656. /**
  43657. * Minimum movement node
  43658. */
  43659. minNodeName?: string;
  43660. /**
  43661. * Max movement node
  43662. */
  43663. maxNodeName?: string;
  43664. };
  43665. };
  43666. /**
  43667. * If touch enabled, what is the name of node to display user feedback
  43668. */
  43669. touchPointNodeName?: string;
  43670. };
  43671. };
  43672. /**
  43673. * Is it xr standard mapping or not
  43674. */
  43675. gamepadMapping: "" | "xr-standard";
  43676. /**
  43677. * Base root node of this entire model
  43678. */
  43679. rootNodeName: string;
  43680. /**
  43681. * Defines the main button component id
  43682. */
  43683. selectComponentId: string;
  43684. }
  43685. /**
  43686. * A definition for the layout map in the input profile
  43687. */
  43688. export interface IMotionControllerLayoutMap {
  43689. /**
  43690. * Layouts with handness type as a key
  43691. */
  43692. [handness: string]: IMotionControllerLayout;
  43693. }
  43694. /**
  43695. * The XR Input profile schema
  43696. * Profiles can be found here:
  43697. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43698. */
  43699. export interface IMotionControllerProfile {
  43700. /**
  43701. * fallback profiles for this profileId
  43702. */
  43703. fallbackProfileIds: string[];
  43704. /**
  43705. * The layout map, with handness as key
  43706. */
  43707. layouts: IMotionControllerLayoutMap;
  43708. /**
  43709. * The id of this profile
  43710. * correlates to the profile(s) in the xrInput.profiles array
  43711. */
  43712. profileId: string;
  43713. }
  43714. /**
  43715. * A helper-interface for the 3 meshes needed for controller button animation
  43716. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43717. */
  43718. export interface IMotionControllerButtonMeshMap {
  43719. /**
  43720. * the mesh that defines the pressed value mesh position.
  43721. * This is used to find the max-position of this button
  43722. */
  43723. pressedMesh: AbstractMesh;
  43724. /**
  43725. * the mesh that defines the unpressed value mesh position.
  43726. * This is used to find the min (or initial) position of this button
  43727. */
  43728. unpressedMesh: AbstractMesh;
  43729. /**
  43730. * The mesh that will be changed when value changes
  43731. */
  43732. valueMesh: AbstractMesh;
  43733. }
  43734. /**
  43735. * A helper-interface for the 3 meshes needed for controller axis animation.
  43736. * This will be expanded when touchpad animations are fully supported
  43737. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43738. */
  43739. export interface IMotionControllerMeshMap {
  43740. /**
  43741. * the mesh that defines the maximum value mesh position.
  43742. */
  43743. maxMesh?: AbstractMesh;
  43744. /**
  43745. * the mesh that defines the minimum value mesh position.
  43746. */
  43747. minMesh?: AbstractMesh;
  43748. /**
  43749. * The mesh that will be changed when axis value changes
  43750. */
  43751. valueMesh: AbstractMesh;
  43752. }
  43753. /**
  43754. * The elements needed for change-detection of the gamepad objects in motion controllers
  43755. */
  43756. export interface IMinimalMotionControllerObject {
  43757. /**
  43758. * Available axes of this controller
  43759. */
  43760. axes: number[];
  43761. /**
  43762. * An array of available buttons
  43763. */
  43764. buttons: Array<{
  43765. /**
  43766. * Value of the button/trigger
  43767. */
  43768. value: number;
  43769. /**
  43770. * If the button/trigger is currently touched
  43771. */
  43772. touched: boolean;
  43773. /**
  43774. * If the button/trigger is currently pressed
  43775. */
  43776. pressed: boolean;
  43777. }>;
  43778. }
  43779. /**
  43780. * An Abstract Motion controller
  43781. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43782. * Each component has an observable to check for changes in value and state
  43783. */
  43784. export abstract class WebXRAbstractMotionController implements IDisposable {
  43785. protected scene: Scene;
  43786. protected layout: IMotionControllerLayout;
  43787. /**
  43788. * The gamepad object correlating to this controller
  43789. */
  43790. gamepadObject: IMinimalMotionControllerObject;
  43791. /**
  43792. * handness (left/right/none) of this controller
  43793. */
  43794. handness: MotionControllerHandness;
  43795. private _initComponent;
  43796. private _modelReady;
  43797. /**
  43798. * A map of components (WebXRControllerComponent) in this motion controller
  43799. * Components have a ComponentType and can also have both button and axis definitions
  43800. */
  43801. readonly components: {
  43802. [id: string]: WebXRControllerComponent;
  43803. };
  43804. /**
  43805. * Disable the model's animation. Can be set at any time.
  43806. */
  43807. disableAnimation: boolean;
  43808. /**
  43809. * Observers registered here will be triggered when the model of this controller is done loading
  43810. */
  43811. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43812. /**
  43813. * The profile id of this motion controller
  43814. */
  43815. abstract profileId: string;
  43816. /**
  43817. * The root mesh of the model. It is null if the model was not yet initialized
  43818. */
  43819. rootMesh: Nullable<AbstractMesh>;
  43820. /**
  43821. * constructs a new abstract motion controller
  43822. * @param scene the scene to which the model of the controller will be added
  43823. * @param layout The profile layout to load
  43824. * @param gamepadObject The gamepad object correlating to this controller
  43825. * @param handness handness (left/right/none) of this controller
  43826. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43827. */
  43828. constructor(scene: Scene, layout: IMotionControllerLayout,
  43829. /**
  43830. * The gamepad object correlating to this controller
  43831. */
  43832. gamepadObject: IMinimalMotionControllerObject,
  43833. /**
  43834. * handness (left/right/none) of this controller
  43835. */
  43836. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43837. /**
  43838. * Dispose this controller, the model mesh and all its components
  43839. */
  43840. dispose(): void;
  43841. /**
  43842. * Returns all components of specific type
  43843. * @param type the type to search for
  43844. * @return an array of components with this type
  43845. */
  43846. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43847. /**
  43848. * get a component based an its component id as defined in layout.components
  43849. * @param id the id of the component
  43850. * @returns the component correlates to the id or undefined if not found
  43851. */
  43852. getComponent(id: string): WebXRControllerComponent;
  43853. /**
  43854. * Get the list of components available in this motion controller
  43855. * @returns an array of strings correlating to available components
  43856. */
  43857. getComponentIds(): string[];
  43858. /**
  43859. * Get the first component of specific type
  43860. * @param type type of component to find
  43861. * @return a controller component or null if not found
  43862. */
  43863. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43864. /**
  43865. * Get the main (Select) component of this controller as defined in the layout
  43866. * @returns the main component of this controller
  43867. */
  43868. getMainComponent(): WebXRControllerComponent;
  43869. /**
  43870. * Loads the model correlating to this controller
  43871. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43872. * @returns A promise fulfilled with the result of the model loading
  43873. */
  43874. loadModel(): Promise<boolean>;
  43875. /**
  43876. * Update this model using the current XRFrame
  43877. * @param xrFrame the current xr frame to use and update the model
  43878. */
  43879. updateFromXRFrame(xrFrame: XRFrame): void;
  43880. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43881. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43882. /**
  43883. * Moves the axis on the controller mesh based on its current state
  43884. * @param axis the index of the axis
  43885. * @param axisValue the value of the axis which determines the meshes new position
  43886. * @hidden
  43887. */
  43888. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43889. /**
  43890. * Update the model itself with the current frame data
  43891. * @param xrFrame the frame to use for updating the model mesh
  43892. */
  43893. protected updateModel(xrFrame: XRFrame): void;
  43894. /**
  43895. * Get the filename and path for this controller's model
  43896. * @returns a map of filename and path
  43897. */
  43898. protected abstract _getFilenameAndPath(): {
  43899. filename: string;
  43900. path: string;
  43901. };
  43902. /**
  43903. * This function is called before the mesh is loaded. It checks for loading constraints.
  43904. * For example, this function can check if the GLB loader is available
  43905. * If this function returns false, the generic controller will be loaded instead
  43906. * @returns Is the client ready to load the mesh
  43907. */
  43908. protected abstract _getModelLoadingConstraints(): boolean;
  43909. /**
  43910. * This function will be called after the model was successfully loaded and can be used
  43911. * for mesh transformations before it is available for the user
  43912. * @param meshes the loaded meshes
  43913. */
  43914. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43915. /**
  43916. * Set the root mesh for this controller. Important for the WebXR controller class
  43917. * @param meshes the loaded meshes
  43918. */
  43919. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43920. /**
  43921. * A function executed each frame that updates the mesh (if needed)
  43922. * @param xrFrame the current xrFrame
  43923. */
  43924. protected abstract _updateModel(xrFrame: XRFrame): void;
  43925. private _getGenericFilenameAndPath;
  43926. private _getGenericParentMesh;
  43927. }
  43928. }
  43929. declare module BABYLON {
  43930. /**
  43931. * A generic trigger-only motion controller for WebXR
  43932. */
  43933. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43934. /**
  43935. * Static version of the profile id of this controller
  43936. */
  43937. static ProfileId: string;
  43938. profileId: string;
  43939. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43940. protected _getFilenameAndPath(): {
  43941. filename: string;
  43942. path: string;
  43943. };
  43944. protected _getModelLoadingConstraints(): boolean;
  43945. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43947. protected _updateModel(): void;
  43948. }
  43949. }
  43950. declare module BABYLON {
  43951. /**
  43952. * Class containing static functions to help procedurally build meshes
  43953. */
  43954. export class SphereBuilder {
  43955. /**
  43956. * Creates a sphere mesh
  43957. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43958. * * 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`)
  43959. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43960. * * 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
  43961. * * 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)
  43962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43963. * * 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
  43964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43965. * @param name defines the name of the mesh
  43966. * @param options defines the options used to create the mesh
  43967. * @param scene defines the hosting scene
  43968. * @returns the sphere mesh
  43969. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43970. */
  43971. static CreateSphere(name: string, options: {
  43972. segments?: number;
  43973. diameter?: number;
  43974. diameterX?: number;
  43975. diameterY?: number;
  43976. diameterZ?: number;
  43977. arc?: number;
  43978. slice?: number;
  43979. sideOrientation?: number;
  43980. frontUVs?: Vector4;
  43981. backUVs?: Vector4;
  43982. updatable?: boolean;
  43983. }, scene?: Nullable<Scene>): Mesh;
  43984. }
  43985. }
  43986. declare module BABYLON {
  43987. /**
  43988. * A profiled motion controller has its profile loaded from an online repository.
  43989. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  43990. */
  43991. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  43992. private _repositoryUrl;
  43993. private _buttonMeshMapping;
  43994. private _touchDots;
  43995. /**
  43996. * The profile ID of this controller. Will be populated when the controller initializes.
  43997. */
  43998. profileId: string;
  43999. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44000. dispose(): void;
  44001. protected _getFilenameAndPath(): {
  44002. filename: string;
  44003. path: string;
  44004. };
  44005. protected _getModelLoadingConstraints(): boolean;
  44006. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44007. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44008. protected _updateModel(_xrFrame: XRFrame): void;
  44009. }
  44010. }
  44011. declare module BABYLON {
  44012. /**
  44013. * A construction function type to create a new controller based on an xrInput object
  44014. */
  44015. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44016. /**
  44017. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44018. *
  44019. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44020. * it should be replaced with auto-loaded controllers.
  44021. *
  44022. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44023. */
  44024. export class WebXRMotionControllerManager {
  44025. private static _AvailableControllers;
  44026. private static _Fallbacks;
  44027. private static _ProfileLoadingPromises;
  44028. private static _ProfilesList;
  44029. /**
  44030. * The base URL of the online controller repository. Can be changed at any time.
  44031. */
  44032. static BaseRepositoryUrl: string;
  44033. /**
  44034. * Which repository gets priority - local or online
  44035. */
  44036. static PrioritizeOnlineRepository: boolean;
  44037. /**
  44038. * Use the online repository, or use only locally-defined controllers
  44039. */
  44040. static UseOnlineRepository: boolean;
  44041. /**
  44042. * Clear the cache used for profile loading and reload when requested again
  44043. */
  44044. static ClearProfilesCache(): void;
  44045. /**
  44046. * Register the default fallbacks.
  44047. * This function is called automatically when this file is imported.
  44048. */
  44049. static DefaultFallbacks(): void;
  44050. /**
  44051. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44052. * @param profileId the profile to which a fallback needs to be found
  44053. * @return an array with corresponding fallback profiles
  44054. */
  44055. static FindFallbackWithProfileId(profileId: string): string[];
  44056. /**
  44057. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44058. * The order of search:
  44059. *
  44060. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44061. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44062. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44063. * 4) return the generic trigger controller if none were found
  44064. *
  44065. * @param xrInput the xrInput to which a new controller is initialized
  44066. * @param scene the scene to which the model will be added
  44067. * @param forceProfile force a certain profile for this controller
  44068. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44069. */
  44070. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44071. /**
  44072. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44073. *
  44074. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44075. *
  44076. * @param type the profile type to register
  44077. * @param constructFunction the function to be called when loading this profile
  44078. */
  44079. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44080. /**
  44081. * Register a fallback to a specific profile.
  44082. * @param profileId the profileId that will receive the fallbacks
  44083. * @param fallbacks A list of fallback profiles
  44084. */
  44085. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44086. /**
  44087. * Will update the list of profiles available in the repository
  44088. * @return a promise that resolves to a map of profiles available online
  44089. */
  44090. static UpdateProfilesList(): Promise<{
  44091. [profile: string]: string;
  44092. }>;
  44093. private static _LoadProfileFromRepository;
  44094. private static _LoadProfilesFromAvailableControllers;
  44095. }
  44096. }
  44097. declare module BABYLON {
  44098. /**
  44099. * Configuration options for the WebXR controller creation
  44100. */
  44101. export interface IWebXRControllerOptions {
  44102. /**
  44103. * Should the controller mesh be animated when a user interacts with it
  44104. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44105. */
  44106. disableMotionControllerAnimation?: boolean;
  44107. /**
  44108. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44109. */
  44110. doNotLoadControllerMesh?: boolean;
  44111. /**
  44112. * Force a specific controller type for this controller.
  44113. * This can be used when creating your own profile or when testing different controllers
  44114. */
  44115. forceControllerProfile?: string;
  44116. }
  44117. /**
  44118. * Represents an XR controller
  44119. */
  44120. export class WebXRInputSource {
  44121. private _scene;
  44122. /** The underlying input source for the controller */
  44123. inputSource: XRInputSource;
  44124. private _options;
  44125. private _tmpQuaternion;
  44126. private _tmpVector;
  44127. private _uniqueId;
  44128. /**
  44129. * 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
  44130. */
  44131. grip?: AbstractMesh;
  44132. /**
  44133. * If available, this is the gamepad object related to this controller.
  44134. * Using this object it is possible to get click events and trackpad changes of the
  44135. * webxr controller that is currently being used.
  44136. */
  44137. motionController?: WebXRAbstractMotionController;
  44138. /**
  44139. * Event that fires when the controller is removed/disposed.
  44140. * The object provided as event data is this controller, after associated assets were disposed.
  44141. * uniqueId is still available.
  44142. */
  44143. onDisposeObservable: Observable<WebXRInputSource>;
  44144. /**
  44145. * Will be triggered when the mesh associated with the motion controller is done loading.
  44146. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44147. * A shortened version of controller -> motion controller -> on mesh loaded.
  44148. */
  44149. onMeshLoadedObservable: Observable<AbstractMesh>;
  44150. /**
  44151. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44152. */
  44153. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44154. /**
  44155. * Pointer which can be used to select objects or attach a visible laser to
  44156. */
  44157. pointer: AbstractMesh;
  44158. /**
  44159. * Creates the controller
  44160. * @see https://doc.babylonjs.com/how_to/webxr
  44161. * @param _scene the scene which the controller should be associated to
  44162. * @param inputSource the underlying input source for the controller
  44163. * @param _options options for this controller creation
  44164. */
  44165. constructor(_scene: Scene,
  44166. /** The underlying input source for the controller */
  44167. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44168. /**
  44169. * Get this controllers unique id
  44170. */
  44171. get uniqueId(): string;
  44172. /**
  44173. * Disposes of the object
  44174. */
  44175. dispose(): void;
  44176. /**
  44177. * Gets a world space ray coming from the pointer or grip
  44178. * @param result the resulting ray
  44179. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44180. */
  44181. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44182. /**
  44183. * Updates the controller pose based on the given XRFrame
  44184. * @param xrFrame xr frame to update the pose with
  44185. * @param referenceSpace reference space to use
  44186. */
  44187. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44188. }
  44189. }
  44190. declare module BABYLON {
  44191. /**
  44192. * The schema for initialization options of the XR Input class
  44193. */
  44194. export interface IWebXRInputOptions {
  44195. /**
  44196. * If set to true no model will be automatically loaded
  44197. */
  44198. doNotLoadControllerMeshes?: boolean;
  44199. /**
  44200. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44201. * If not found, the xr input profile data will be used.
  44202. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44203. */
  44204. forceInputProfile?: string;
  44205. /**
  44206. * Do not send a request to the controller repository to load the profile.
  44207. *
  44208. * Instead, use the controllers available in babylon itself.
  44209. */
  44210. disableOnlineControllerRepository?: boolean;
  44211. /**
  44212. * A custom URL for the controllers repository
  44213. */
  44214. customControllersRepositoryURL?: string;
  44215. /**
  44216. * Should the controller model's components not move according to the user input
  44217. */
  44218. disableControllerAnimation?: boolean;
  44219. }
  44220. /**
  44221. * XR input used to track XR inputs such as controllers/rays
  44222. */
  44223. export class WebXRInput implements IDisposable {
  44224. /**
  44225. * the xr session manager for this session
  44226. */
  44227. xrSessionManager: WebXRSessionManager;
  44228. /**
  44229. * the WebXR camera for this session. Mainly used for teleportation
  44230. */
  44231. xrCamera: WebXRCamera;
  44232. private readonly options;
  44233. /**
  44234. * XR controllers being tracked
  44235. */
  44236. controllers: Array<WebXRInputSource>;
  44237. private _frameObserver;
  44238. private _sessionEndedObserver;
  44239. private _sessionInitObserver;
  44240. /**
  44241. * Event when a controller has been connected/added
  44242. */
  44243. onControllerAddedObservable: Observable<WebXRInputSource>;
  44244. /**
  44245. * Event when a controller has been removed/disconnected
  44246. */
  44247. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44248. /**
  44249. * Initializes the WebXRInput
  44250. * @param xrSessionManager the xr session manager for this session
  44251. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44252. * @param options = initialization options for this xr input
  44253. */
  44254. constructor(
  44255. /**
  44256. * the xr session manager for this session
  44257. */
  44258. xrSessionManager: WebXRSessionManager,
  44259. /**
  44260. * the WebXR camera for this session. Mainly used for teleportation
  44261. */
  44262. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44263. private _onInputSourcesChange;
  44264. private _addAndRemoveControllers;
  44265. /**
  44266. * Disposes of the object
  44267. */
  44268. dispose(): void;
  44269. }
  44270. }
  44271. declare module BABYLON {
  44272. /**
  44273. * This is the base class for all WebXR features.
  44274. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44275. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44276. */
  44277. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44278. protected _xrSessionManager: WebXRSessionManager;
  44279. private _attached;
  44280. private _removeOnDetach;
  44281. /**
  44282. * Should auto-attach be disabled?
  44283. */
  44284. disableAutoAttach: boolean;
  44285. /**
  44286. * Construct a new (abstract) WebXR feature
  44287. * @param _xrSessionManager the xr session manager for this feature
  44288. */
  44289. constructor(_xrSessionManager: WebXRSessionManager);
  44290. /**
  44291. * Is this feature attached
  44292. */
  44293. get attached(): boolean;
  44294. /**
  44295. * attach this feature
  44296. *
  44297. * @param force should attachment be forced (even when already attached)
  44298. * @returns true if successful, false is failed or already attached
  44299. */
  44300. attach(force?: boolean): boolean;
  44301. /**
  44302. * detach this feature.
  44303. *
  44304. * @returns true if successful, false if failed or already detached
  44305. */
  44306. detach(): boolean;
  44307. /**
  44308. * Dispose this feature and all of the resources attached
  44309. */
  44310. dispose(): void;
  44311. /**
  44312. * This is used to register callbacks that will automatically be removed when detach is called.
  44313. * @param observable the observable to which the observer will be attached
  44314. * @param callback the callback to register
  44315. */
  44316. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44317. /**
  44318. * Code in this function will be executed on each xrFrame received from the browser.
  44319. * This function will not execute after the feature is detached.
  44320. * @param _xrFrame the current frame
  44321. */
  44322. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44323. }
  44324. }
  44325. declare module BABYLON {
  44326. /**
  44327. * Renders a layer on top of an existing scene
  44328. */
  44329. export class UtilityLayerRenderer implements IDisposable {
  44330. /** the original scene that will be rendered on top of */
  44331. originalScene: Scene;
  44332. private _pointerCaptures;
  44333. private _lastPointerEvents;
  44334. private static _DefaultUtilityLayer;
  44335. private static _DefaultKeepDepthUtilityLayer;
  44336. private _sharedGizmoLight;
  44337. private _renderCamera;
  44338. /**
  44339. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44340. * @returns the camera that is used when rendering the utility layer
  44341. */
  44342. getRenderCamera(): Camera;
  44343. /**
  44344. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44345. * @param cam the camera that should be used when rendering the utility layer
  44346. */
  44347. setRenderCamera(cam: Nullable<Camera>): void;
  44348. /**
  44349. * @hidden
  44350. * Light which used by gizmos to get light shading
  44351. */
  44352. _getSharedGizmoLight(): HemisphericLight;
  44353. /**
  44354. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44355. */
  44356. pickUtilitySceneFirst: boolean;
  44357. /**
  44358. * 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)
  44359. */
  44360. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44361. /**
  44362. * 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)
  44363. */
  44364. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44365. /**
  44366. * The scene that is rendered on top of the original scene
  44367. */
  44368. utilityLayerScene: Scene;
  44369. /**
  44370. * If the utility layer should automatically be rendered on top of existing scene
  44371. */
  44372. shouldRender: boolean;
  44373. /**
  44374. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44375. */
  44376. onlyCheckPointerDownEvents: boolean;
  44377. /**
  44378. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44379. */
  44380. processAllEvents: boolean;
  44381. /**
  44382. * Observable raised when the pointer move from the utility layer scene to the main scene
  44383. */
  44384. onPointerOutObservable: Observable<number>;
  44385. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44386. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44387. private _afterRenderObserver;
  44388. private _sceneDisposeObserver;
  44389. private _originalPointerObserver;
  44390. /**
  44391. * Instantiates a UtilityLayerRenderer
  44392. * @param originalScene the original scene that will be rendered on top of
  44393. * @param handleEvents boolean indicating if the utility layer should handle events
  44394. */
  44395. constructor(
  44396. /** the original scene that will be rendered on top of */
  44397. originalScene: Scene, handleEvents?: boolean);
  44398. private _notifyObservers;
  44399. /**
  44400. * Renders the utility layers scene on top of the original scene
  44401. */
  44402. render(): void;
  44403. /**
  44404. * Disposes of the renderer
  44405. */
  44406. dispose(): void;
  44407. private _updateCamera;
  44408. }
  44409. }
  44410. declare module BABYLON {
  44411. /**
  44412. * Options interface for the pointer selection module
  44413. */
  44414. export interface IWebXRControllerPointerSelectionOptions {
  44415. /**
  44416. * if provided, this scene will be used to render meshes.
  44417. */
  44418. customUtilityLayerScene?: Scene;
  44419. /**
  44420. * 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)
  44421. * If not disabled, the last picked point will be used to execute a pointer up event
  44422. * If disabled, pointer up event will be triggered right after the pointer down event.
  44423. * Used in screen and gaze target ray mode only
  44424. */
  44425. disablePointerUpOnTouchOut: boolean;
  44426. /**
  44427. * For gaze mode (time to select instead of press)
  44428. */
  44429. forceGazeMode: boolean;
  44430. /**
  44431. * 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
  44432. * to start a new countdown to the pointer down event.
  44433. * Defaults to 1.
  44434. */
  44435. gazeModePointerMovedFactor?: number;
  44436. /**
  44437. * Different button type to use instead of the main component
  44438. */
  44439. overrideButtonId?: string;
  44440. /**
  44441. * use this rendering group id for the meshes (optional)
  44442. */
  44443. renderingGroupId?: number;
  44444. /**
  44445. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44446. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44447. * 3000 means 3 seconds between pointing at something and selecting it
  44448. */
  44449. timeToSelect?: number;
  44450. /**
  44451. * Should meshes created here be added to a utility layer or the main scene
  44452. */
  44453. useUtilityLayer?: boolean;
  44454. /**
  44455. * the xr input to use with this pointer selection
  44456. */
  44457. xrInput: WebXRInput;
  44458. }
  44459. /**
  44460. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44461. */
  44462. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44463. private readonly _options;
  44464. private static _idCounter;
  44465. private _attachController;
  44466. private _controllers;
  44467. private _scene;
  44468. private _tmpVectorForPickCompare;
  44469. /**
  44470. * The module's name
  44471. */
  44472. static readonly Name: string;
  44473. /**
  44474. * The (Babylon) version of this module.
  44475. * This is an integer representing the implementation version.
  44476. * This number does not correspond to the WebXR specs version
  44477. */
  44478. static readonly Version: number;
  44479. /**
  44480. * Disable lighting on the laser pointer (so it will always be visible)
  44481. */
  44482. disablePointerLighting: boolean;
  44483. /**
  44484. * Disable lighting on the selection mesh (so it will always be visible)
  44485. */
  44486. disableSelectionMeshLighting: boolean;
  44487. /**
  44488. * Should the laser pointer be displayed
  44489. */
  44490. displayLaserPointer: boolean;
  44491. /**
  44492. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44493. */
  44494. displaySelectionMesh: boolean;
  44495. /**
  44496. * This color will be set to the laser pointer when selection is triggered
  44497. */
  44498. laserPointerPickedColor: Color3;
  44499. /**
  44500. * Default color of the laser pointer
  44501. */
  44502. lasterPointerDefaultColor: Color3;
  44503. /**
  44504. * default color of the selection ring
  44505. */
  44506. selectionMeshDefaultColor: Color3;
  44507. /**
  44508. * This color will be applied to the selection ring when selection is triggered
  44509. */
  44510. selectionMeshPickedColor: Color3;
  44511. /**
  44512. * constructs a new background remover module
  44513. * @param _xrSessionManager the session manager for this module
  44514. * @param _options read-only options to be used in this module
  44515. */
  44516. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44517. /**
  44518. * attach this feature
  44519. * Will usually be called by the features manager
  44520. *
  44521. * @returns true if successful.
  44522. */
  44523. attach(): boolean;
  44524. /**
  44525. * detach this feature.
  44526. * Will usually be called by the features manager
  44527. *
  44528. * @returns true if successful.
  44529. */
  44530. detach(): boolean;
  44531. /**
  44532. * Will get the mesh under a specific pointer.
  44533. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44534. * @param controllerId the controllerId to check
  44535. * @returns The mesh under pointer or null if no mesh is under the pointer
  44536. */
  44537. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44538. /**
  44539. * Get the xr controller that correlates to the pointer id in the pointer event
  44540. *
  44541. * @param id the pointer id to search for
  44542. * @returns the controller that correlates to this id or null if not found
  44543. */
  44544. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44545. protected _onXRFrame(_xrFrame: XRFrame): void;
  44546. private _attachGazeMode;
  44547. private _attachScreenRayMode;
  44548. private _attachTrackedPointerRayMode;
  44549. private _convertNormalToDirectionOfRay;
  44550. private _detachController;
  44551. private _generateNewMeshPair;
  44552. private _pickingMoved;
  44553. private _updatePointerDistance;
  44554. }
  44555. }
  44556. declare module BABYLON {
  44557. /**
  44558. * Button which can be used to enter a different mode of XR
  44559. */
  44560. export class WebXREnterExitUIButton {
  44561. /** button element */
  44562. element: HTMLElement;
  44563. /** XR initialization options for the button */
  44564. sessionMode: XRSessionMode;
  44565. /** Reference space type */
  44566. referenceSpaceType: XRReferenceSpaceType;
  44567. /**
  44568. * Creates a WebXREnterExitUIButton
  44569. * @param element button element
  44570. * @param sessionMode XR initialization session mode
  44571. * @param referenceSpaceType the type of reference space to be used
  44572. */
  44573. constructor(
  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. * Extendable function which can be used to update the button's visuals when the state changes
  44582. * @param activeButton the current active button in the UI
  44583. */
  44584. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44585. }
  44586. /**
  44587. * Options to create the webXR UI
  44588. */
  44589. export class WebXREnterExitUIOptions {
  44590. /**
  44591. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44592. */
  44593. customButtons?: Array<WebXREnterExitUIButton>;
  44594. /**
  44595. * A reference space type to use when creating the default button.
  44596. * Default is local-floor
  44597. */
  44598. referenceSpaceType?: XRReferenceSpaceType;
  44599. /**
  44600. * Context to enter xr with
  44601. */
  44602. renderTarget?: Nullable<WebXRRenderTarget>;
  44603. /**
  44604. * A session mode to use when creating the default button.
  44605. * Default is immersive-vr
  44606. */
  44607. sessionMode?: XRSessionMode;
  44608. }
  44609. /**
  44610. * UI to allow the user to enter/exit XR mode
  44611. */
  44612. export class WebXREnterExitUI implements IDisposable {
  44613. private scene;
  44614. /** version of the options passed to this UI */
  44615. options: WebXREnterExitUIOptions;
  44616. private _activeButton;
  44617. private _buttons;
  44618. private _overlay;
  44619. /**
  44620. * Fired every time the active button is changed.
  44621. *
  44622. * When xr is entered via a button that launches xr that button will be the callback parameter
  44623. *
  44624. * When exiting xr the callback parameter will be null)
  44625. */
  44626. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44627. /**
  44628. *
  44629. * @param scene babylon scene object to use
  44630. * @param options (read-only) version of the options passed to this UI
  44631. */
  44632. private constructor();
  44633. /**
  44634. * Creates UI to allow the user to enter/exit XR mode
  44635. * @param scene the scene to add the ui to
  44636. * @param helper the xr experience helper to enter/exit xr with
  44637. * @param options options to configure the UI
  44638. * @returns the created ui
  44639. */
  44640. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44641. /**
  44642. * Disposes of the XR UI component
  44643. */
  44644. dispose(): void;
  44645. private _updateButtons;
  44646. }
  44647. }
  44648. declare module BABYLON {
  44649. /**
  44650. * Class containing static functions to help procedurally build meshes
  44651. */
  44652. export class LinesBuilder {
  44653. /**
  44654. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44655. * * 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
  44656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44657. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44658. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44659. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44660. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44661. * * 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
  44662. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44665. * @param name defines the name of the new line system
  44666. * @param options defines the options used to create the line system
  44667. * @param scene defines the hosting scene
  44668. * @returns a new line system mesh
  44669. */
  44670. static CreateLineSystem(name: string, options: {
  44671. lines: Vector3[][];
  44672. updatable?: boolean;
  44673. instance?: Nullable<LinesMesh>;
  44674. colors?: Nullable<Color4[][]>;
  44675. useVertexAlpha?: boolean;
  44676. }, scene: Nullable<Scene>): LinesMesh;
  44677. /**
  44678. * Creates a line mesh
  44679. * 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
  44680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44681. * * The parameter `points` is an array successive Vector3
  44682. * * 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
  44683. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44685. * * When updating an instance, remember that only point positions can change, not the number of points
  44686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44688. * @param name defines the name of the new line system
  44689. * @param options defines the options used to create the line system
  44690. * @param scene defines the hosting scene
  44691. * @returns a new line mesh
  44692. */
  44693. static CreateLines(name: string, options: {
  44694. points: Vector3[];
  44695. updatable?: boolean;
  44696. instance?: Nullable<LinesMesh>;
  44697. colors?: Color4[];
  44698. useVertexAlpha?: boolean;
  44699. }, scene?: Nullable<Scene>): LinesMesh;
  44700. /**
  44701. * Creates a dashed line mesh
  44702. * * 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
  44703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44704. * * The parameter `points` is an array successive Vector3
  44705. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44706. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44707. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44708. * * 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
  44709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44710. * * When updating an instance, remember that only point positions can change, not the number of points
  44711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44712. * @param name defines the name of the mesh
  44713. * @param options defines the options used to create the mesh
  44714. * @param scene defines the hosting scene
  44715. * @returns the dashed line mesh
  44716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44717. */
  44718. static CreateDashedLines(name: string, options: {
  44719. points: Vector3[];
  44720. dashSize?: number;
  44721. gapSize?: number;
  44722. dashNb?: number;
  44723. updatable?: boolean;
  44724. instance?: LinesMesh;
  44725. useVertexAlpha?: boolean;
  44726. }, scene?: Nullable<Scene>): LinesMesh;
  44727. }
  44728. }
  44729. declare module BABYLON {
  44730. /**
  44731. * The options container for the teleportation module
  44732. */
  44733. export interface IWebXRTeleportationOptions {
  44734. /**
  44735. * if provided, this scene will be used to render meshes.
  44736. */
  44737. customUtilityLayerScene?: Scene;
  44738. /**
  44739. * Values to configure the default target mesh
  44740. */
  44741. defaultTargetMeshOptions?: {
  44742. /**
  44743. * Fill color of the teleportation area
  44744. */
  44745. teleportationFillColor?: string;
  44746. /**
  44747. * Border color for the teleportation area
  44748. */
  44749. teleportationBorderColor?: string;
  44750. /**
  44751. * Disable the mesh's animation sequence
  44752. */
  44753. disableAnimation?: boolean;
  44754. /**
  44755. * Disable lighting on the material or the ring and arrow
  44756. */
  44757. disableLighting?: boolean;
  44758. /**
  44759. * Override the default material of the torus and arrow
  44760. */
  44761. torusArrowMaterial?: Material;
  44762. };
  44763. /**
  44764. * A list of meshes to use as floor meshes.
  44765. * Meshes can be added and removed after initializing the feature using the
  44766. * addFloorMesh and removeFloorMesh functions
  44767. * If empty, rotation will still work
  44768. */
  44769. floorMeshes?: AbstractMesh[];
  44770. /**
  44771. * use this rendering group id for the meshes (optional)
  44772. */
  44773. renderingGroupId?: number;
  44774. /**
  44775. * Should teleportation move only to snap points
  44776. */
  44777. snapPointsOnly?: boolean;
  44778. /**
  44779. * An array of points to which the teleportation will snap to.
  44780. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44781. */
  44782. snapPositions?: Vector3[];
  44783. /**
  44784. * How close should the teleportation ray be in order to snap to position.
  44785. * Default to 0.8 units (meters)
  44786. */
  44787. snapToPositionRadius?: number;
  44788. /**
  44789. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44790. * If you want to support rotation, make sure your mesh has a direction indicator.
  44791. *
  44792. * When left untouched, the default mesh will be initialized.
  44793. */
  44794. teleportationTargetMesh?: AbstractMesh;
  44795. /**
  44796. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44797. */
  44798. timeToTeleport?: number;
  44799. /**
  44800. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44801. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44802. */
  44803. useMainComponentOnly?: boolean;
  44804. /**
  44805. * Should meshes created here be added to a utility layer or the main scene
  44806. */
  44807. useUtilityLayer?: boolean;
  44808. /**
  44809. * Babylon XR Input class for controller
  44810. */
  44811. xrInput: WebXRInput;
  44812. }
  44813. /**
  44814. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44815. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44816. * the input of the attached controllers.
  44817. */
  44818. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44819. private _options;
  44820. private _controllers;
  44821. private _currentTeleportationControllerId;
  44822. private _floorMeshes;
  44823. private _quadraticBezierCurve;
  44824. private _selectionFeature;
  44825. private _snapToPositions;
  44826. private _snappedToPoint;
  44827. private _teleportationRingMaterial?;
  44828. private _tmpRay;
  44829. private _tmpVector;
  44830. /**
  44831. * The module's name
  44832. */
  44833. static readonly Name: string;
  44834. /**
  44835. * The (Babylon) version of this module.
  44836. * This is an integer representing the implementation version.
  44837. * This number does not correspond to the webxr specs version
  44838. */
  44839. static readonly Version: number;
  44840. /**
  44841. * Is movement backwards enabled
  44842. */
  44843. backwardsMovementEnabled: boolean;
  44844. /**
  44845. * Distance to travel when moving backwards
  44846. */
  44847. backwardsTeleportationDistance: number;
  44848. /**
  44849. * The distance from the user to the inspection point in the direction of the controller
  44850. * A higher number will allow the user to move further
  44851. * defaults to 5 (meters, in xr units)
  44852. */
  44853. parabolicCheckRadius: number;
  44854. /**
  44855. * Should the module support parabolic ray on top of direct ray
  44856. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44857. * Very helpful when moving between floors / different heights
  44858. */
  44859. parabolicRayEnabled: boolean;
  44860. /**
  44861. * How much rotation should be applied when rotating right and left
  44862. */
  44863. rotationAngle: number;
  44864. /**
  44865. * Is rotation enabled when moving forward?
  44866. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44867. */
  44868. rotationEnabled: boolean;
  44869. /**
  44870. * constructs a new anchor system
  44871. * @param _xrSessionManager an instance of WebXRSessionManager
  44872. * @param _options configuration object for this feature
  44873. */
  44874. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44875. /**
  44876. * Get the snapPointsOnly flag
  44877. */
  44878. get snapPointsOnly(): boolean;
  44879. /**
  44880. * Sets the snapPointsOnly flag
  44881. * @param snapToPoints should teleportation be exclusively to snap points
  44882. */
  44883. set snapPointsOnly(snapToPoints: boolean);
  44884. /**
  44885. * Add a new mesh to the floor meshes array
  44886. * @param mesh the mesh to use as floor mesh
  44887. */
  44888. addFloorMesh(mesh: AbstractMesh): void;
  44889. /**
  44890. * Add a new snap-to point to fix teleportation to this position
  44891. * @param newSnapPoint The new Snap-To point
  44892. */
  44893. addSnapPoint(newSnapPoint: Vector3): void;
  44894. attach(): boolean;
  44895. detach(): boolean;
  44896. dispose(): void;
  44897. /**
  44898. * Remove a mesh from the floor meshes array
  44899. * @param mesh the mesh to remove
  44900. */
  44901. removeFloorMesh(mesh: AbstractMesh): void;
  44902. /**
  44903. * Remove a mesh from the floor meshes array using its name
  44904. * @param name the mesh name to remove
  44905. */
  44906. removeFloorMeshByName(name: string): void;
  44907. /**
  44908. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  44909. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44910. * @returns was the point found and removed or not
  44911. */
  44912. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44913. /**
  44914. * This function sets a selection feature that will be disabled when
  44915. * the forward ray is shown and will be reattached when hidden.
  44916. * This is used to remove the selection rays when moving.
  44917. * @param selectionFeature the feature to disable when forward movement is enabled
  44918. */
  44919. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44920. protected _onXRFrame(_xrFrame: XRFrame): void;
  44921. private _attachController;
  44922. private _createDefaultTargetMesh;
  44923. private _detachController;
  44924. private _findClosestSnapPointWithRadius;
  44925. private _setTargetMeshPosition;
  44926. private _setTargetMeshVisibility;
  44927. private _showParabolicPath;
  44928. private _teleportForward;
  44929. }
  44930. }
  44931. declare module BABYLON {
  44932. /**
  44933. * Options for the default xr helper
  44934. */
  44935. export class WebXRDefaultExperienceOptions {
  44936. /**
  44937. * Enable or disable default UI to enter XR
  44938. */
  44939. disableDefaultUI?: boolean;
  44940. /**
  44941. * Should teleportation not initialize. defaults to false.
  44942. */
  44943. disableTeleportation?: boolean;
  44944. /**
  44945. * Floor meshes that will be used for teleport
  44946. */
  44947. floorMeshes?: Array<AbstractMesh>;
  44948. /**
  44949. * If set to true, the first frame will not be used to reset position
  44950. * The first frame is mainly used when copying transformation from the old camera
  44951. * Mainly used in AR
  44952. */
  44953. ignoreNativeCameraTransformation?: boolean;
  44954. /**
  44955. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44956. */
  44957. inputOptions?: IWebXRInputOptions;
  44958. /**
  44959. * optional configuration for the output canvas
  44960. */
  44961. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44962. /**
  44963. * optional UI options. This can be used among other to change session mode and reference space type
  44964. */
  44965. uiOptions?: WebXREnterExitUIOptions;
  44966. /**
  44967. * When loading teleportation and pointer select, use stable versions instead of latest.
  44968. */
  44969. useStablePlugins?: boolean;
  44970. }
  44971. /**
  44972. * Default experience which provides a similar setup to the previous webVRExperience
  44973. */
  44974. export class WebXRDefaultExperience {
  44975. /**
  44976. * Base experience
  44977. */
  44978. baseExperience: WebXRExperienceHelper;
  44979. /**
  44980. * Enables ui for entering/exiting xr
  44981. */
  44982. enterExitUI: WebXREnterExitUI;
  44983. /**
  44984. * Input experience extension
  44985. */
  44986. input: WebXRInput;
  44987. /**
  44988. * Enables laser pointer and selection
  44989. */
  44990. pointerSelection: WebXRControllerPointerSelection;
  44991. /**
  44992. * Default target xr should render to
  44993. */
  44994. renderTarget: WebXRRenderTarget;
  44995. /**
  44996. * Enables teleportation
  44997. */
  44998. teleportation: WebXRMotionControllerTeleportation;
  44999. private constructor();
  45000. /**
  45001. * Creates the default xr experience
  45002. * @param scene scene
  45003. * @param options options for basic configuration
  45004. * @returns resulting WebXRDefaultExperience
  45005. */
  45006. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45007. /**
  45008. * DIsposes of the experience helper
  45009. */
  45010. dispose(): void;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /**
  45015. * Options to modify the vr teleportation behavior.
  45016. */
  45017. export interface VRTeleportationOptions {
  45018. /**
  45019. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45020. */
  45021. floorMeshName?: string;
  45022. /**
  45023. * A list of meshes to be used as the teleportation floor. (default: empty)
  45024. */
  45025. floorMeshes?: Mesh[];
  45026. /**
  45027. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45028. */
  45029. teleportationMode?: number;
  45030. /**
  45031. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45032. */
  45033. teleportationTime?: number;
  45034. /**
  45035. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45036. */
  45037. teleportationSpeed?: number;
  45038. /**
  45039. * The easing function used in the animation or null for Linear. (default CircleEase)
  45040. */
  45041. easingFunction?: EasingFunction;
  45042. }
  45043. /**
  45044. * Options to modify the vr experience helper's behavior.
  45045. */
  45046. export interface VRExperienceHelperOptions extends WebVROptions {
  45047. /**
  45048. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45049. */
  45050. createDeviceOrientationCamera?: boolean;
  45051. /**
  45052. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45053. */
  45054. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45055. /**
  45056. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45057. */
  45058. laserToggle?: boolean;
  45059. /**
  45060. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45061. */
  45062. floorMeshes?: Mesh[];
  45063. /**
  45064. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45065. */
  45066. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45067. /**
  45068. * Defines if WebXR should be used instead of WebVR (if available)
  45069. */
  45070. useXR?: boolean;
  45071. }
  45072. /**
  45073. * Event containing information after VR has been entered
  45074. */
  45075. export class OnAfterEnteringVRObservableEvent {
  45076. /**
  45077. * If entering vr was successful
  45078. */
  45079. success: boolean;
  45080. }
  45081. /**
  45082. * Helps to quickly add VR support to an existing scene.
  45083. * See http://doc.babylonjs.com/how_to/webvr_helper
  45084. */
  45085. export class VRExperienceHelper {
  45086. /** Options to modify the vr experience helper's behavior. */
  45087. webVROptions: VRExperienceHelperOptions;
  45088. private _scene;
  45089. private _position;
  45090. private _btnVR;
  45091. private _btnVRDisplayed;
  45092. private _webVRsupported;
  45093. private _webVRready;
  45094. private _webVRrequesting;
  45095. private _webVRpresenting;
  45096. private _hasEnteredVR;
  45097. private _fullscreenVRpresenting;
  45098. private _inputElement;
  45099. private _webVRCamera;
  45100. private _vrDeviceOrientationCamera;
  45101. private _deviceOrientationCamera;
  45102. private _existingCamera;
  45103. private _onKeyDown;
  45104. private _onVrDisplayPresentChange;
  45105. private _onVRDisplayChanged;
  45106. private _onVRRequestPresentStart;
  45107. private _onVRRequestPresentComplete;
  45108. /**
  45109. * 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)
  45110. */
  45111. enableGazeEvenWhenNoPointerLock: boolean;
  45112. /**
  45113. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45114. */
  45115. exitVROnDoubleTap: boolean;
  45116. /**
  45117. * Observable raised right before entering VR.
  45118. */
  45119. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45120. /**
  45121. * Observable raised when entering VR has completed.
  45122. */
  45123. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45124. /**
  45125. * Observable raised when exiting VR.
  45126. */
  45127. onExitingVRObservable: Observable<VRExperienceHelper>;
  45128. /**
  45129. * Observable raised when controller mesh is loaded.
  45130. */
  45131. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45132. /** Return this.onEnteringVRObservable
  45133. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45134. */
  45135. get onEnteringVR(): Observable<VRExperienceHelper>;
  45136. /** Return this.onExitingVRObservable
  45137. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45138. */
  45139. get onExitingVR(): Observable<VRExperienceHelper>;
  45140. /** Return this.onControllerMeshLoadedObservable
  45141. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45142. */
  45143. get onControllerMeshLoaded(): Observable<WebVRController>;
  45144. private _rayLength;
  45145. private _useCustomVRButton;
  45146. private _teleportationRequested;
  45147. private _teleportActive;
  45148. private _floorMeshName;
  45149. private _floorMeshesCollection;
  45150. private _teleportationMode;
  45151. private _teleportationTime;
  45152. private _teleportationSpeed;
  45153. private _teleportationEasing;
  45154. private _rotationAllowed;
  45155. private _teleportBackwardsVector;
  45156. private _teleportationTarget;
  45157. private _isDefaultTeleportationTarget;
  45158. private _postProcessMove;
  45159. private _teleportationFillColor;
  45160. private _teleportationBorderColor;
  45161. private _rotationAngle;
  45162. private _haloCenter;
  45163. private _cameraGazer;
  45164. private _padSensibilityUp;
  45165. private _padSensibilityDown;
  45166. private _leftController;
  45167. private _rightController;
  45168. private _gazeColor;
  45169. private _laserColor;
  45170. private _pickedLaserColor;
  45171. private _pickedGazeColor;
  45172. /**
  45173. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45174. */
  45175. onNewMeshSelected: Observable<AbstractMesh>;
  45176. /**
  45177. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45178. * This observable will provide the mesh and the controller used to select the mesh
  45179. */
  45180. onMeshSelectedWithController: Observable<{
  45181. mesh: AbstractMesh;
  45182. controller: WebVRController;
  45183. }>;
  45184. /**
  45185. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45186. */
  45187. onNewMeshPicked: Observable<PickingInfo>;
  45188. private _circleEase;
  45189. /**
  45190. * Observable raised before camera teleportation
  45191. */
  45192. onBeforeCameraTeleport: Observable<Vector3>;
  45193. /**
  45194. * Observable raised after camera teleportation
  45195. */
  45196. onAfterCameraTeleport: Observable<Vector3>;
  45197. /**
  45198. * Observable raised when current selected mesh gets unselected
  45199. */
  45200. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45201. private _raySelectionPredicate;
  45202. /**
  45203. * To be optionaly changed by user to define custom ray selection
  45204. */
  45205. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45206. /**
  45207. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45208. */
  45209. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45210. /**
  45211. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45212. */
  45213. teleportationEnabled: boolean;
  45214. private _defaultHeight;
  45215. private _teleportationInitialized;
  45216. private _interactionsEnabled;
  45217. private _interactionsRequested;
  45218. private _displayGaze;
  45219. private _displayLaserPointer;
  45220. /**
  45221. * The mesh used to display where the user is going to teleport.
  45222. */
  45223. get teleportationTarget(): Mesh;
  45224. /**
  45225. * Sets the mesh to be used to display where the user is going to teleport.
  45226. */
  45227. set teleportationTarget(value: Mesh);
  45228. /**
  45229. * 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
  45230. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45231. * See http://doc.babylonjs.com/resources/baking_transformations
  45232. */
  45233. get gazeTrackerMesh(): Mesh;
  45234. set gazeTrackerMesh(value: Mesh);
  45235. /**
  45236. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45237. */
  45238. updateGazeTrackerScale: boolean;
  45239. /**
  45240. * If the gaze trackers color should be updated when selecting meshes
  45241. */
  45242. updateGazeTrackerColor: boolean;
  45243. /**
  45244. * If the controller laser color should be updated when selecting meshes
  45245. */
  45246. updateControllerLaserColor: boolean;
  45247. /**
  45248. * The gaze tracking mesh corresponding to the left controller
  45249. */
  45250. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45251. /**
  45252. * The gaze tracking mesh corresponding to the right controller
  45253. */
  45254. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45255. /**
  45256. * If the ray of the gaze should be displayed.
  45257. */
  45258. get displayGaze(): boolean;
  45259. /**
  45260. * Sets if the ray of the gaze should be displayed.
  45261. */
  45262. set displayGaze(value: boolean);
  45263. /**
  45264. * If the ray of the LaserPointer should be displayed.
  45265. */
  45266. get displayLaserPointer(): boolean;
  45267. /**
  45268. * Sets if the ray of the LaserPointer should be displayed.
  45269. */
  45270. set displayLaserPointer(value: boolean);
  45271. /**
  45272. * The deviceOrientationCamera used as the camera when not in VR.
  45273. */
  45274. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45275. /**
  45276. * Based on the current WebVR support, returns the current VR camera used.
  45277. */
  45278. get currentVRCamera(): Nullable<Camera>;
  45279. /**
  45280. * The webVRCamera which is used when in VR.
  45281. */
  45282. get webVRCamera(): WebVRFreeCamera;
  45283. /**
  45284. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45285. */
  45286. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45287. /**
  45288. * The html button that is used to trigger entering into VR.
  45289. */
  45290. get vrButton(): Nullable<HTMLButtonElement>;
  45291. private get _teleportationRequestInitiated();
  45292. /**
  45293. * Defines whether or not Pointer lock should be requested when switching to
  45294. * full screen.
  45295. */
  45296. requestPointerLockOnFullScreen: boolean;
  45297. /**
  45298. * If asking to force XR, this will be populated with the default xr experience
  45299. */
  45300. xr: WebXRDefaultExperience;
  45301. /**
  45302. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45303. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45304. */
  45305. xrTestDone: boolean;
  45306. /**
  45307. * Instantiates a VRExperienceHelper.
  45308. * Helps to quickly add VR support to an existing scene.
  45309. * @param scene The scene the VRExperienceHelper belongs to.
  45310. * @param webVROptions Options to modify the vr experience helper's behavior.
  45311. */
  45312. constructor(scene: Scene,
  45313. /** Options to modify the vr experience helper's behavior. */
  45314. webVROptions?: VRExperienceHelperOptions);
  45315. private completeVRInit;
  45316. private _onDefaultMeshLoaded;
  45317. private _onResize;
  45318. private _onFullscreenChange;
  45319. /**
  45320. * Gets a value indicating if we are currently in VR mode.
  45321. */
  45322. get isInVRMode(): boolean;
  45323. private onVrDisplayPresentChange;
  45324. private onVRDisplayChanged;
  45325. private moveButtonToBottomRight;
  45326. private displayVRButton;
  45327. private updateButtonVisibility;
  45328. private _cachedAngularSensibility;
  45329. /**
  45330. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45331. * Otherwise, will use the fullscreen API.
  45332. */
  45333. enterVR(): void;
  45334. /**
  45335. * Attempt to exit VR, or fullscreen.
  45336. */
  45337. exitVR(): void;
  45338. /**
  45339. * The position of the vr experience helper.
  45340. */
  45341. get position(): Vector3;
  45342. /**
  45343. * Sets the position of the vr experience helper.
  45344. */
  45345. set position(value: Vector3);
  45346. /**
  45347. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45348. */
  45349. enableInteractions(): void;
  45350. private get _noControllerIsActive();
  45351. private beforeRender;
  45352. private _isTeleportationFloor;
  45353. /**
  45354. * Adds a floor mesh to be used for teleportation.
  45355. * @param floorMesh the mesh to be used for teleportation.
  45356. */
  45357. addFloorMesh(floorMesh: Mesh): void;
  45358. /**
  45359. * Removes a floor mesh from being used for teleportation.
  45360. * @param floorMesh the mesh to be removed.
  45361. */
  45362. removeFloorMesh(floorMesh: Mesh): void;
  45363. /**
  45364. * Enables interactions and teleportation using the VR controllers and gaze.
  45365. * @param vrTeleportationOptions options to modify teleportation behavior.
  45366. */
  45367. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45368. private _onNewGamepadConnected;
  45369. private _tryEnableInteractionOnController;
  45370. private _onNewGamepadDisconnected;
  45371. private _enableInteractionOnController;
  45372. private _checkTeleportWithRay;
  45373. private _checkRotate;
  45374. private _checkTeleportBackwards;
  45375. private _enableTeleportationOnController;
  45376. private _createTeleportationCircles;
  45377. private _displayTeleportationTarget;
  45378. private _hideTeleportationTarget;
  45379. private _rotateCamera;
  45380. private _moveTeleportationSelectorTo;
  45381. private _workingVector;
  45382. private _workingQuaternion;
  45383. private _workingMatrix;
  45384. /**
  45385. * Time Constant Teleportation Mode
  45386. */
  45387. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45388. /**
  45389. * Speed Constant Teleportation Mode
  45390. */
  45391. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45392. /**
  45393. * Teleports the users feet to the desired location
  45394. * @param location The location where the user's feet should be placed
  45395. */
  45396. teleportCamera(location: Vector3): void;
  45397. private _convertNormalToDirectionOfRay;
  45398. private _castRayAndSelectObject;
  45399. private _notifySelectedMeshUnselected;
  45400. /**
  45401. * Permanently set new colors for the laser pointer
  45402. * @param color the new laser color
  45403. * @param pickedColor the new laser color when picked mesh detected
  45404. */
  45405. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45406. /**
  45407. * Set lighting enabled / disabled on the laser pointer of both controllers
  45408. * @param enabled should the lighting be enabled on the laser pointer
  45409. */
  45410. setLaserLightingState(enabled?: boolean): void;
  45411. /**
  45412. * Permanently set new colors for the gaze pointer
  45413. * @param color the new gaze color
  45414. * @param pickedColor the new gaze color when picked mesh detected
  45415. */
  45416. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45417. /**
  45418. * Sets the color of the laser ray from the vr controllers.
  45419. * @param color new color for the ray.
  45420. */
  45421. changeLaserColor(color: Color3): void;
  45422. /**
  45423. * Sets the color of the ray from the vr headsets gaze.
  45424. * @param color new color for the ray.
  45425. */
  45426. changeGazeColor(color: Color3): void;
  45427. /**
  45428. * Exits VR and disposes of the vr experience helper
  45429. */
  45430. dispose(): void;
  45431. /**
  45432. * Gets the name of the VRExperienceHelper class
  45433. * @returns "VRExperienceHelper"
  45434. */
  45435. getClassName(): string;
  45436. }
  45437. }
  45438. declare module BABYLON {
  45439. /**
  45440. * Contains an array of blocks representing the octree
  45441. */
  45442. export interface IOctreeContainer<T> {
  45443. /**
  45444. * Blocks within the octree
  45445. */
  45446. blocks: Array<OctreeBlock<T>>;
  45447. }
  45448. /**
  45449. * Class used to store a cell in an octree
  45450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45451. */
  45452. export class OctreeBlock<T> {
  45453. /**
  45454. * Gets the content of the current block
  45455. */
  45456. entries: T[];
  45457. /**
  45458. * Gets the list of block children
  45459. */
  45460. blocks: Array<OctreeBlock<T>>;
  45461. private _depth;
  45462. private _maxDepth;
  45463. private _capacity;
  45464. private _minPoint;
  45465. private _maxPoint;
  45466. private _boundingVectors;
  45467. private _creationFunc;
  45468. /**
  45469. * Creates a new block
  45470. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45471. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45472. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45473. * @param depth defines the current depth of this block in the octree
  45474. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45475. * @param creationFunc defines a callback to call when an element is added to the block
  45476. */
  45477. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45478. /**
  45479. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45480. */
  45481. get capacity(): number;
  45482. /**
  45483. * Gets the minimum vector (in world space) of the block's bounding box
  45484. */
  45485. get minPoint(): Vector3;
  45486. /**
  45487. * Gets the maximum vector (in world space) of the block's bounding box
  45488. */
  45489. get maxPoint(): Vector3;
  45490. /**
  45491. * Add a new element to this block
  45492. * @param entry defines the element to add
  45493. */
  45494. addEntry(entry: T): void;
  45495. /**
  45496. * Remove an element from this block
  45497. * @param entry defines the element to remove
  45498. */
  45499. removeEntry(entry: T): void;
  45500. /**
  45501. * Add an array of elements to this block
  45502. * @param entries defines the array of elements to add
  45503. */
  45504. addEntries(entries: T[]): void;
  45505. /**
  45506. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45507. * @param frustumPlanes defines the frustum planes to test
  45508. * @param selection defines the array to store current content if selection is positive
  45509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45510. */
  45511. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45512. /**
  45513. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45514. * @param sphereCenter defines the bounding sphere center
  45515. * @param sphereRadius defines the bounding sphere radius
  45516. * @param selection defines the array to store current content if selection is positive
  45517. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45518. */
  45519. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45520. /**
  45521. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45522. * @param ray defines the ray to test with
  45523. * @param selection defines the array to store current content if selection is positive
  45524. */
  45525. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45526. /**
  45527. * Subdivide the content into child blocks (this block will then be empty)
  45528. */
  45529. createInnerBlocks(): void;
  45530. /**
  45531. * @hidden
  45532. */
  45533. 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;
  45534. }
  45535. }
  45536. declare module BABYLON {
  45537. /**
  45538. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45540. */
  45541. export class Octree<T> {
  45542. /** 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.) */
  45543. maxDepth: number;
  45544. /**
  45545. * Blocks within the octree containing objects
  45546. */
  45547. blocks: Array<OctreeBlock<T>>;
  45548. /**
  45549. * Content stored in the octree
  45550. */
  45551. dynamicContent: T[];
  45552. private _maxBlockCapacity;
  45553. private _selectionContent;
  45554. private _creationFunc;
  45555. /**
  45556. * Creates a octree
  45557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45558. * @param creationFunc function to be used to instatiate the octree
  45559. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45560. * @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.)
  45561. */
  45562. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45563. /** 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.) */
  45564. maxDepth?: number);
  45565. /**
  45566. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45567. * @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);
  45568. * @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);
  45569. * @param entries meshes to be added to the octree blocks
  45570. */
  45571. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45572. /**
  45573. * Adds a mesh to the octree
  45574. * @param entry Mesh to add to the octree
  45575. */
  45576. addMesh(entry: T): void;
  45577. /**
  45578. * Remove an element from the octree
  45579. * @param entry defines the element to remove
  45580. */
  45581. removeMesh(entry: T): void;
  45582. /**
  45583. * Selects an array of meshes within the frustum
  45584. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45585. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45586. * @returns array of meshes within the frustum
  45587. */
  45588. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45589. /**
  45590. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45591. * @param sphereCenter defines the bounding sphere center
  45592. * @param sphereRadius defines the bounding sphere radius
  45593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45594. * @returns an array of objects that intersect the sphere
  45595. */
  45596. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45597. /**
  45598. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45599. * @param ray defines the ray to test with
  45600. * @returns array of intersected objects
  45601. */
  45602. intersectsRay(ray: Ray): SmartArray<T>;
  45603. /**
  45604. * Adds a mesh into the octree block if it intersects the block
  45605. */
  45606. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45607. /**
  45608. * Adds a submesh into the octree block if it intersects the block
  45609. */
  45610. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45611. }
  45612. }
  45613. declare module BABYLON {
  45614. interface Scene {
  45615. /**
  45616. * @hidden
  45617. * Backing Filed
  45618. */
  45619. _selectionOctree: Octree<AbstractMesh>;
  45620. /**
  45621. * Gets the octree used to boost mesh selection (picking)
  45622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45623. */
  45624. selectionOctree: Octree<AbstractMesh>;
  45625. /**
  45626. * Creates or updates the octree used to boost selection (picking)
  45627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45628. * @param maxCapacity defines the maximum capacity per leaf
  45629. * @param maxDepth defines the maximum depth of the octree
  45630. * @returns an octree of AbstractMesh
  45631. */
  45632. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45633. }
  45634. interface AbstractMesh {
  45635. /**
  45636. * @hidden
  45637. * Backing Field
  45638. */
  45639. _submeshesOctree: Octree<SubMesh>;
  45640. /**
  45641. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45642. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45643. * @param maxCapacity defines the maximum size of each block (64 by default)
  45644. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45645. * @returns the new octree
  45646. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45648. */
  45649. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45650. }
  45651. /**
  45652. * Defines the octree scene component responsible to manage any octrees
  45653. * in a given scene.
  45654. */
  45655. export class OctreeSceneComponent {
  45656. /**
  45657. * The component name help to identify the component in the list of scene components.
  45658. */
  45659. readonly name: string;
  45660. /**
  45661. * The scene the component belongs to.
  45662. */
  45663. scene: Scene;
  45664. /**
  45665. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45666. */
  45667. readonly checksIsEnabled: boolean;
  45668. /**
  45669. * Creates a new instance of the component for the given scene
  45670. * @param scene Defines the scene to register the component in
  45671. */
  45672. constructor(scene: Scene);
  45673. /**
  45674. * Registers the component in a given scene
  45675. */
  45676. register(): void;
  45677. /**
  45678. * Return the list of active meshes
  45679. * @returns the list of active meshes
  45680. */
  45681. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45682. /**
  45683. * Return the list of active sub meshes
  45684. * @param mesh The mesh to get the candidates sub meshes from
  45685. * @returns the list of active sub meshes
  45686. */
  45687. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45688. private _tempRay;
  45689. /**
  45690. * Return the list of sub meshes intersecting with a given local ray
  45691. * @param mesh defines the mesh to find the submesh for
  45692. * @param localRay defines the ray in local space
  45693. * @returns the list of intersecting sub meshes
  45694. */
  45695. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45696. /**
  45697. * Return the list of sub meshes colliding with a collider
  45698. * @param mesh defines the mesh to find the submesh for
  45699. * @param collider defines the collider to evaluate the collision against
  45700. * @returns the list of colliding sub meshes
  45701. */
  45702. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45703. /**
  45704. * Rebuilds the elements related to this component in case of
  45705. * context lost for instance.
  45706. */
  45707. rebuild(): void;
  45708. /**
  45709. * Disposes the component and the associated ressources.
  45710. */
  45711. dispose(): void;
  45712. }
  45713. }
  45714. declare module BABYLON {
  45715. /**
  45716. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45717. */
  45718. export class Gizmo implements IDisposable {
  45719. /** The utility layer the gizmo will be added to */
  45720. gizmoLayer: UtilityLayerRenderer;
  45721. /**
  45722. * The root mesh of the gizmo
  45723. */
  45724. _rootMesh: Mesh;
  45725. private _attachedMesh;
  45726. /**
  45727. * Ratio for the scale of the gizmo (Default: 1)
  45728. */
  45729. scaleRatio: number;
  45730. /**
  45731. * If a custom mesh has been set (Default: false)
  45732. */
  45733. protected _customMeshSet: boolean;
  45734. /**
  45735. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45736. * * When set, interactions will be enabled
  45737. */
  45738. get attachedMesh(): Nullable<AbstractMesh>;
  45739. set attachedMesh(value: Nullable<AbstractMesh>);
  45740. /**
  45741. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45742. * @param mesh The mesh to replace the default mesh of the gizmo
  45743. */
  45744. setCustomMesh(mesh: Mesh): void;
  45745. /**
  45746. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45747. */
  45748. updateGizmoRotationToMatchAttachedMesh: boolean;
  45749. /**
  45750. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45751. */
  45752. updateGizmoPositionToMatchAttachedMesh: boolean;
  45753. /**
  45754. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45755. */
  45756. updateScale: boolean;
  45757. protected _interactionsEnabled: boolean;
  45758. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45759. private _beforeRenderObserver;
  45760. private _tempVector;
  45761. /**
  45762. * Creates a gizmo
  45763. * @param gizmoLayer The utility layer the gizmo will be added to
  45764. */
  45765. constructor(
  45766. /** The utility layer the gizmo will be added to */
  45767. gizmoLayer?: UtilityLayerRenderer);
  45768. /**
  45769. * Updates the gizmo to match the attached mesh's position/rotation
  45770. */
  45771. protected _update(): void;
  45772. /**
  45773. * Disposes of the gizmo
  45774. */
  45775. dispose(): void;
  45776. }
  45777. }
  45778. declare module BABYLON {
  45779. /**
  45780. * Single plane drag gizmo
  45781. */
  45782. export class PlaneDragGizmo extends Gizmo {
  45783. /**
  45784. * Drag behavior responsible for the gizmos dragging interactions
  45785. */
  45786. dragBehavior: PointerDragBehavior;
  45787. private _pointerObserver;
  45788. /**
  45789. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45790. */
  45791. snapDistance: number;
  45792. /**
  45793. * Event that fires each time the gizmo snaps to a new location.
  45794. * * snapDistance is the the change in distance
  45795. */
  45796. onSnapObservable: Observable<{
  45797. snapDistance: number;
  45798. }>;
  45799. private _plane;
  45800. private _coloredMaterial;
  45801. private _hoverMaterial;
  45802. private _isEnabled;
  45803. private _parent;
  45804. /** @hidden */
  45805. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45806. /** @hidden */
  45807. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45808. /**
  45809. * Creates a PlaneDragGizmo
  45810. * @param gizmoLayer The utility layer the gizmo will be added to
  45811. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45812. * @param color The color of the gizmo
  45813. */
  45814. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45815. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45816. /**
  45817. * If the gizmo is enabled
  45818. */
  45819. set isEnabled(value: boolean);
  45820. get isEnabled(): boolean;
  45821. /**
  45822. * Disposes of the gizmo
  45823. */
  45824. dispose(): void;
  45825. }
  45826. }
  45827. declare module BABYLON {
  45828. /**
  45829. * Gizmo that enables dragging a mesh along 3 axis
  45830. */
  45831. export class PositionGizmo extends Gizmo {
  45832. /**
  45833. * Internal gizmo used for interactions on the x axis
  45834. */
  45835. xGizmo: AxisDragGizmo;
  45836. /**
  45837. * Internal gizmo used for interactions on the y axis
  45838. */
  45839. yGizmo: AxisDragGizmo;
  45840. /**
  45841. * Internal gizmo used for interactions on the z axis
  45842. */
  45843. zGizmo: AxisDragGizmo;
  45844. /**
  45845. * Internal gizmo used for interactions on the yz plane
  45846. */
  45847. xPlaneGizmo: PlaneDragGizmo;
  45848. /**
  45849. * Internal gizmo used for interactions on the xz plane
  45850. */
  45851. yPlaneGizmo: PlaneDragGizmo;
  45852. /**
  45853. * Internal gizmo used for interactions on the xy plane
  45854. */
  45855. zPlaneGizmo: PlaneDragGizmo;
  45856. /**
  45857. * private variables
  45858. */
  45859. private _meshAttached;
  45860. private _updateGizmoRotationToMatchAttachedMesh;
  45861. private _snapDistance;
  45862. private _scaleRatio;
  45863. /** Fires an event when any of it's sub gizmos are dragged */
  45864. onDragStartObservable: Observable<unknown>;
  45865. /** Fires an event when any of it's sub gizmos are released from dragging */
  45866. onDragEndObservable: Observable<unknown>;
  45867. /**
  45868. * If set to true, planar drag is enabled
  45869. */
  45870. private _planarGizmoEnabled;
  45871. get attachedMesh(): Nullable<AbstractMesh>;
  45872. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45873. /**
  45874. * Creates a PositionGizmo
  45875. * @param gizmoLayer The utility layer the gizmo will be added to
  45876. */
  45877. constructor(gizmoLayer?: UtilityLayerRenderer);
  45878. /**
  45879. * If the planar drag gizmo is enabled
  45880. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45881. */
  45882. set planarGizmoEnabled(value: boolean);
  45883. get planarGizmoEnabled(): boolean;
  45884. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45885. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45886. /**
  45887. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45888. */
  45889. set snapDistance(value: number);
  45890. get snapDistance(): number;
  45891. /**
  45892. * Ratio for the scale of the gizmo (Default: 1)
  45893. */
  45894. set scaleRatio(value: number);
  45895. get scaleRatio(): number;
  45896. /**
  45897. * Disposes of the gizmo
  45898. */
  45899. dispose(): void;
  45900. /**
  45901. * CustomMeshes are not supported by this gizmo
  45902. * @param mesh The mesh to replace the default mesh of the gizmo
  45903. */
  45904. setCustomMesh(mesh: Mesh): void;
  45905. }
  45906. }
  45907. declare module BABYLON {
  45908. /**
  45909. * Single axis drag gizmo
  45910. */
  45911. export class AxisDragGizmo extends Gizmo {
  45912. /**
  45913. * Drag behavior responsible for the gizmos dragging interactions
  45914. */
  45915. dragBehavior: PointerDragBehavior;
  45916. private _pointerObserver;
  45917. /**
  45918. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45919. */
  45920. snapDistance: number;
  45921. /**
  45922. * Event that fires each time the gizmo snaps to a new location.
  45923. * * snapDistance is the the change in distance
  45924. */
  45925. onSnapObservable: Observable<{
  45926. snapDistance: number;
  45927. }>;
  45928. private _isEnabled;
  45929. private _parent;
  45930. private _arrow;
  45931. private _coloredMaterial;
  45932. private _hoverMaterial;
  45933. /** @hidden */
  45934. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45935. /** @hidden */
  45936. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45937. /**
  45938. * Creates an AxisDragGizmo
  45939. * @param gizmoLayer The utility layer the gizmo will be added to
  45940. * @param dragAxis The axis which the gizmo will be able to drag on
  45941. * @param color The color of the gizmo
  45942. */
  45943. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45944. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45945. /**
  45946. * If the gizmo is enabled
  45947. */
  45948. set isEnabled(value: boolean);
  45949. get isEnabled(): boolean;
  45950. /**
  45951. * Disposes of the gizmo
  45952. */
  45953. dispose(): void;
  45954. }
  45955. }
  45956. declare module BABYLON.Debug {
  45957. /**
  45958. * The Axes viewer will show 3 axes in a specific point in space
  45959. */
  45960. export class AxesViewer {
  45961. private _xAxis;
  45962. private _yAxis;
  45963. private _zAxis;
  45964. private _scaleLinesFactor;
  45965. private _instanced;
  45966. /**
  45967. * Gets the hosting scene
  45968. */
  45969. scene: Scene;
  45970. /**
  45971. * Gets or sets a number used to scale line length
  45972. */
  45973. scaleLines: number;
  45974. /** Gets the node hierarchy used to render x-axis */
  45975. get xAxis(): TransformNode;
  45976. /** Gets the node hierarchy used to render y-axis */
  45977. get yAxis(): TransformNode;
  45978. /** Gets the node hierarchy used to render z-axis */
  45979. get zAxis(): TransformNode;
  45980. /**
  45981. * Creates a new AxesViewer
  45982. * @param scene defines the hosting scene
  45983. * @param scaleLines defines a number used to scale line length (1 by default)
  45984. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45985. * @param xAxis defines the node hierarchy used to render the x-axis
  45986. * @param yAxis defines the node hierarchy used to render the y-axis
  45987. * @param zAxis defines the node hierarchy used to render the z-axis
  45988. */
  45989. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45990. /**
  45991. * Force the viewer to update
  45992. * @param position defines the position of the viewer
  45993. * @param xaxis defines the x axis of the viewer
  45994. * @param yaxis defines the y axis of the viewer
  45995. * @param zaxis defines the z axis of the viewer
  45996. */
  45997. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45998. /**
  45999. * Creates an instance of this axes viewer.
  46000. * @returns a new axes viewer with instanced meshes
  46001. */
  46002. createInstance(): AxesViewer;
  46003. /** Releases resources */
  46004. dispose(): void;
  46005. private static _SetRenderingGroupId;
  46006. }
  46007. }
  46008. declare module BABYLON.Debug {
  46009. /**
  46010. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46011. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46012. */
  46013. export class BoneAxesViewer extends AxesViewer {
  46014. /**
  46015. * Gets or sets the target mesh where to display the axes viewer
  46016. */
  46017. mesh: Nullable<Mesh>;
  46018. /**
  46019. * Gets or sets the target bone where to display the axes viewer
  46020. */
  46021. bone: Nullable<Bone>;
  46022. /** Gets current position */
  46023. pos: Vector3;
  46024. /** Gets direction of X axis */
  46025. xaxis: Vector3;
  46026. /** Gets direction of Y axis */
  46027. yaxis: Vector3;
  46028. /** Gets direction of Z axis */
  46029. zaxis: Vector3;
  46030. /**
  46031. * Creates a new BoneAxesViewer
  46032. * @param scene defines the hosting scene
  46033. * @param bone defines the target bone
  46034. * @param mesh defines the target mesh
  46035. * @param scaleLines defines a scaling factor for line length (1 by default)
  46036. */
  46037. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46038. /**
  46039. * Force the viewer to update
  46040. */
  46041. update(): void;
  46042. /** Releases resources */
  46043. dispose(): void;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Interface used to define scene explorer extensibility option
  46049. */
  46050. export interface IExplorerExtensibilityOption {
  46051. /**
  46052. * Define the option label
  46053. */
  46054. label: string;
  46055. /**
  46056. * Defines the action to execute on click
  46057. */
  46058. action: (entity: any) => void;
  46059. }
  46060. /**
  46061. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46062. */
  46063. export interface IExplorerExtensibilityGroup {
  46064. /**
  46065. * Defines a predicate to test if a given type mut be extended
  46066. */
  46067. predicate: (entity: any) => boolean;
  46068. /**
  46069. * Gets the list of options added to a type
  46070. */
  46071. entries: IExplorerExtensibilityOption[];
  46072. }
  46073. /**
  46074. * Interface used to define the options to use to create the Inspector
  46075. */
  46076. export interface IInspectorOptions {
  46077. /**
  46078. * Display in overlay mode (default: false)
  46079. */
  46080. overlay?: boolean;
  46081. /**
  46082. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46083. */
  46084. globalRoot?: HTMLElement;
  46085. /**
  46086. * Display the Scene explorer
  46087. */
  46088. showExplorer?: boolean;
  46089. /**
  46090. * Display the property inspector
  46091. */
  46092. showInspector?: boolean;
  46093. /**
  46094. * Display in embed mode (both panes on the right)
  46095. */
  46096. embedMode?: boolean;
  46097. /**
  46098. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46099. */
  46100. handleResize?: boolean;
  46101. /**
  46102. * Allow the panes to popup (default: true)
  46103. */
  46104. enablePopup?: boolean;
  46105. /**
  46106. * Allow the panes to be closed by users (default: true)
  46107. */
  46108. enableClose?: boolean;
  46109. /**
  46110. * Optional list of extensibility entries
  46111. */
  46112. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46113. /**
  46114. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46115. */
  46116. inspectorURL?: string;
  46117. /**
  46118. * Optional initial tab (default to DebugLayerTab.Properties)
  46119. */
  46120. initialTab?: DebugLayerTab;
  46121. }
  46122. interface Scene {
  46123. /**
  46124. * @hidden
  46125. * Backing field
  46126. */
  46127. _debugLayer: DebugLayer;
  46128. /**
  46129. * Gets the debug layer (aka Inspector) associated with the scene
  46130. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46131. */
  46132. debugLayer: DebugLayer;
  46133. }
  46134. /**
  46135. * Enum of inspector action tab
  46136. */
  46137. export enum DebugLayerTab {
  46138. /**
  46139. * Properties tag (default)
  46140. */
  46141. Properties = 0,
  46142. /**
  46143. * Debug tab
  46144. */
  46145. Debug = 1,
  46146. /**
  46147. * Statistics tab
  46148. */
  46149. Statistics = 2,
  46150. /**
  46151. * Tools tab
  46152. */
  46153. Tools = 3,
  46154. /**
  46155. * Settings tab
  46156. */
  46157. Settings = 4
  46158. }
  46159. /**
  46160. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46161. * what is happening in your scene
  46162. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46163. */
  46164. export class DebugLayer {
  46165. /**
  46166. * Define the url to get the inspector script from.
  46167. * By default it uses the babylonjs CDN.
  46168. * @ignoreNaming
  46169. */
  46170. static InspectorURL: string;
  46171. private _scene;
  46172. private BJSINSPECTOR;
  46173. private _onPropertyChangedObservable?;
  46174. /**
  46175. * Observable triggered when a property is changed through the inspector.
  46176. */
  46177. get onPropertyChangedObservable(): any;
  46178. /**
  46179. * Instantiates a new debug layer.
  46180. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46181. * what is happening in your scene
  46182. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46183. * @param scene Defines the scene to inspect
  46184. */
  46185. constructor(scene: Scene);
  46186. /** Creates the inspector window. */
  46187. private _createInspector;
  46188. /**
  46189. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46190. * @param entity defines the entity to select
  46191. * @param lineContainerTitle defines the specific block to highlight
  46192. */
  46193. select(entity: any, lineContainerTitle?: string): void;
  46194. /** Get the inspector from bundle or global */
  46195. private _getGlobalInspector;
  46196. /**
  46197. * Get if the inspector is visible or not.
  46198. * @returns true if visible otherwise, false
  46199. */
  46200. isVisible(): boolean;
  46201. /**
  46202. * Hide the inspector and close its window.
  46203. */
  46204. hide(): void;
  46205. /**
  46206. * Launch the debugLayer.
  46207. * @param config Define the configuration of the inspector
  46208. * @return a promise fulfilled when the debug layer is visible
  46209. */
  46210. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46211. }
  46212. }
  46213. declare module BABYLON {
  46214. /**
  46215. * Class containing static functions to help procedurally build meshes
  46216. */
  46217. export class BoxBuilder {
  46218. /**
  46219. * Creates a box mesh
  46220. * * The parameter `size` sets the size (float) of each box side (default 1)
  46221. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46222. * * 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)
  46223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46225. * * 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
  46226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46227. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46228. * @param name defines the name of the mesh
  46229. * @param options defines the options used to create the mesh
  46230. * @param scene defines the hosting scene
  46231. * @returns the box mesh
  46232. */
  46233. static CreateBox(name: string, options: {
  46234. size?: number;
  46235. width?: number;
  46236. height?: number;
  46237. depth?: number;
  46238. faceUV?: Vector4[];
  46239. faceColors?: Color4[];
  46240. sideOrientation?: number;
  46241. frontUVs?: Vector4;
  46242. backUVs?: Vector4;
  46243. wrap?: boolean;
  46244. topBaseAt?: number;
  46245. bottomBaseAt?: number;
  46246. updatable?: boolean;
  46247. }, scene?: Nullable<Scene>): Mesh;
  46248. }
  46249. }
  46250. declare module BABYLON.Debug {
  46251. /**
  46252. * Used to show the physics impostor around the specific mesh
  46253. */
  46254. export class PhysicsViewer {
  46255. /** @hidden */
  46256. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46257. /** @hidden */
  46258. protected _meshes: Array<Nullable<AbstractMesh>>;
  46259. /** @hidden */
  46260. protected _scene: Nullable<Scene>;
  46261. /** @hidden */
  46262. protected _numMeshes: number;
  46263. /** @hidden */
  46264. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46265. private _renderFunction;
  46266. private _utilityLayer;
  46267. private _debugBoxMesh;
  46268. private _debugSphereMesh;
  46269. private _debugCylinderMesh;
  46270. private _debugMaterial;
  46271. private _debugMeshMeshes;
  46272. /**
  46273. * Creates a new PhysicsViewer
  46274. * @param scene defines the hosting scene
  46275. */
  46276. constructor(scene: Scene);
  46277. /** @hidden */
  46278. protected _updateDebugMeshes(): void;
  46279. /**
  46280. * Renders a specified physic impostor
  46281. * @param impostor defines the impostor to render
  46282. * @param targetMesh defines the mesh represented by the impostor
  46283. * @returns the new debug mesh used to render the impostor
  46284. */
  46285. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46286. /**
  46287. * Hides a specified physic impostor
  46288. * @param impostor defines the impostor to hide
  46289. */
  46290. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46291. private _getDebugMaterial;
  46292. private _getDebugBoxMesh;
  46293. private _getDebugSphereMesh;
  46294. private _getDebugCylinderMesh;
  46295. private _getDebugMeshMesh;
  46296. private _getDebugMesh;
  46297. /** Releases all resources */
  46298. dispose(): void;
  46299. }
  46300. }
  46301. declare module BABYLON {
  46302. /**
  46303. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46304. * in order to better appreciate the issue one might have.
  46305. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46306. */
  46307. export class RayHelper {
  46308. /**
  46309. * Defines the ray we are currently tryin to visualize.
  46310. */
  46311. ray: Nullable<Ray>;
  46312. private _renderPoints;
  46313. private _renderLine;
  46314. private _renderFunction;
  46315. private _scene;
  46316. private _updateToMeshFunction;
  46317. private _attachedToMesh;
  46318. private _meshSpaceDirection;
  46319. private _meshSpaceOrigin;
  46320. /**
  46321. * Helper function to create a colored helper in a scene in one line.
  46322. * @param ray Defines the ray we are currently tryin to visualize
  46323. * @param scene Defines the scene the ray is used in
  46324. * @param color Defines the color we want to see the ray in
  46325. * @returns The newly created ray helper.
  46326. */
  46327. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46328. /**
  46329. * Instantiate a new ray helper.
  46330. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46331. * in order to better appreciate the issue one might have.
  46332. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46333. * @param ray Defines the ray we are currently tryin to visualize
  46334. */
  46335. constructor(ray: Ray);
  46336. /**
  46337. * Shows the ray we are willing to debug.
  46338. * @param scene Defines the scene the ray needs to be rendered in
  46339. * @param color Defines the color the ray needs to be rendered in
  46340. */
  46341. show(scene: Scene, color?: Color3): void;
  46342. /**
  46343. * Hides the ray we are debugging.
  46344. */
  46345. hide(): void;
  46346. private _render;
  46347. /**
  46348. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46349. * @param mesh Defines the mesh we want the helper attached to
  46350. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46351. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46352. * @param length Defines the length of the ray
  46353. */
  46354. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46355. /**
  46356. * Detach the ray helper from the mesh it has previously been attached to.
  46357. */
  46358. detachFromMesh(): void;
  46359. private _updateToMesh;
  46360. /**
  46361. * Dispose the helper and release its associated resources.
  46362. */
  46363. dispose(): void;
  46364. }
  46365. }
  46366. declare module BABYLON.Debug {
  46367. /**
  46368. * Class used to render a debug view of a given skeleton
  46369. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46370. */
  46371. export class SkeletonViewer {
  46372. /** defines the skeleton to render */
  46373. skeleton: Skeleton;
  46374. /** defines the mesh attached to the skeleton */
  46375. mesh: AbstractMesh;
  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 the color used to render the skeleton */
  46381. color: Color3;
  46382. private _scene;
  46383. private _debugLines;
  46384. private _debugMesh;
  46385. private _isEnabled;
  46386. private _renderFunction;
  46387. private _utilityLayer;
  46388. /**
  46389. * Returns the mesh used to render the bones
  46390. */
  46391. get debugMesh(): Nullable<LinesMesh>;
  46392. /**
  46393. * Creates a new SkeletonViewer
  46394. * @param skeleton defines the skeleton to render
  46395. * @param mesh defines the mesh attached to the skeleton
  46396. * @param scene defines the hosting scene
  46397. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46398. * @param renderingGroupId defines the rendering group id to use with the viewer
  46399. */
  46400. constructor(
  46401. /** defines the skeleton to render */
  46402. skeleton: Skeleton,
  46403. /** defines the mesh attached to the skeleton */
  46404. mesh: AbstractMesh, scene: Scene,
  46405. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46406. autoUpdateBonesMatrices?: boolean,
  46407. /** defines the rendering group id to use with the viewer */
  46408. renderingGroupId?: number);
  46409. /** Gets or sets a boolean indicating if the viewer is enabled */
  46410. set isEnabled(value: boolean);
  46411. get isEnabled(): boolean;
  46412. private _getBonePosition;
  46413. private _getLinesForBonesWithLength;
  46414. private _getLinesForBonesNoLength;
  46415. /** Update the viewer to sync with current skeleton state */
  46416. update(): void;
  46417. /** Release associated resources */
  46418. dispose(): void;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /**
  46423. * Options to create the null engine
  46424. */
  46425. export class NullEngineOptions {
  46426. /**
  46427. * Render width (Default: 512)
  46428. */
  46429. renderWidth: number;
  46430. /**
  46431. * Render height (Default: 256)
  46432. */
  46433. renderHeight: number;
  46434. /**
  46435. * Texture size (Default: 512)
  46436. */
  46437. textureSize: number;
  46438. /**
  46439. * If delta time between frames should be constant
  46440. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46441. */
  46442. deterministicLockstep: boolean;
  46443. /**
  46444. * Maximum about of steps between frames (Default: 4)
  46445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46446. */
  46447. lockstepMaxSteps: number;
  46448. }
  46449. /**
  46450. * The null engine class provides support for headless version of babylon.js.
  46451. * This can be used in server side scenario or for testing purposes
  46452. */
  46453. export class NullEngine extends Engine {
  46454. private _options;
  46455. /**
  46456. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46458. * @returns true if engine is in deterministic lock step mode
  46459. */
  46460. isDeterministicLockStep(): boolean;
  46461. /**
  46462. * Gets the max steps when engine is running in deterministic lock step
  46463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46464. * @returns the max steps
  46465. */
  46466. getLockstepMaxSteps(): number;
  46467. /**
  46468. * Gets the current hardware scaling level.
  46469. * By default the hardware scaling level is computed from the window device ratio.
  46470. * 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.
  46471. * @returns a number indicating the current hardware scaling level
  46472. */
  46473. getHardwareScalingLevel(): number;
  46474. constructor(options?: NullEngineOptions);
  46475. /**
  46476. * Creates a vertex buffer
  46477. * @param vertices the data for the vertex buffer
  46478. * @returns the new WebGL static buffer
  46479. */
  46480. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46481. /**
  46482. * Creates a new index buffer
  46483. * @param indices defines the content of the index buffer
  46484. * @param updatable defines if the index buffer must be updatable
  46485. * @returns a new webGL buffer
  46486. */
  46487. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46488. /**
  46489. * Clear the current render buffer or the current render target (if any is set up)
  46490. * @param color defines the color to use
  46491. * @param backBuffer defines if the back buffer must be cleared
  46492. * @param depth defines if the depth buffer must be cleared
  46493. * @param stencil defines if the stencil buffer must be cleared
  46494. */
  46495. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46496. /**
  46497. * Gets the current render width
  46498. * @param useScreen defines if screen size must be used (or the current render target if any)
  46499. * @returns a number defining the current render width
  46500. */
  46501. getRenderWidth(useScreen?: boolean): number;
  46502. /**
  46503. * Gets the current render height
  46504. * @param useScreen defines if screen size must be used (or the current render target if any)
  46505. * @returns a number defining the current render height
  46506. */
  46507. getRenderHeight(useScreen?: boolean): number;
  46508. /**
  46509. * Set the WebGL's viewport
  46510. * @param viewport defines the viewport element to be used
  46511. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46512. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46513. */
  46514. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46515. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46516. /**
  46517. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46518. * @param pipelineContext defines the pipeline context to use
  46519. * @param uniformsNames defines the list of uniform names
  46520. * @returns an array of webGL uniform locations
  46521. */
  46522. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46523. /**
  46524. * Gets the lsit of active attributes for a given webGL program
  46525. * @param pipelineContext defines the pipeline context to use
  46526. * @param attributesNames defines the list of attribute names to get
  46527. * @returns an array of indices indicating the offset of each attribute
  46528. */
  46529. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46530. /**
  46531. * Binds an effect to the webGL context
  46532. * @param effect defines the effect to bind
  46533. */
  46534. bindSamplers(effect: Effect): void;
  46535. /**
  46536. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46537. * @param effect defines the effect to activate
  46538. */
  46539. enableEffect(effect: Effect): void;
  46540. /**
  46541. * Set various states to the webGL context
  46542. * @param culling defines backface culling state
  46543. * @param zOffset defines the value to apply to zOffset (0 by default)
  46544. * @param force defines if states must be applied even if cache is up to date
  46545. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46546. */
  46547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46548. /**
  46549. * Set the value of an uniform to an array of int32
  46550. * @param uniform defines the webGL uniform location where to store the value
  46551. * @param array defines the array of int32 to store
  46552. */
  46553. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46554. /**
  46555. * Set the value of an uniform to an array of int32 (stored as vec2)
  46556. * @param uniform defines the webGL uniform location where to store the value
  46557. * @param array defines the array of int32 to store
  46558. */
  46559. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46560. /**
  46561. * Set the value of an uniform to an array of int32 (stored as vec3)
  46562. * @param uniform defines the webGL uniform location where to store the value
  46563. * @param array defines the array of int32 to store
  46564. */
  46565. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46566. /**
  46567. * Set the value of an uniform to an array of int32 (stored as vec4)
  46568. * @param uniform defines the webGL uniform location where to store the value
  46569. * @param array defines the array of int32 to store
  46570. */
  46571. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46572. /**
  46573. * Set the value of an uniform to an array of float32
  46574. * @param uniform defines the webGL uniform location where to store the value
  46575. * @param array defines the array of float32 to store
  46576. */
  46577. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46578. /**
  46579. * Set the value of an uniform to an array of float32 (stored as vec2)
  46580. * @param uniform defines the webGL uniform location where to store the value
  46581. * @param array defines the array of float32 to store
  46582. */
  46583. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46584. /**
  46585. * Set the value of an uniform to an array of float32 (stored as vec3)
  46586. * @param uniform defines the webGL uniform location where to store the value
  46587. * @param array defines the array of float32 to store
  46588. */
  46589. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46590. /**
  46591. * Set the value of an uniform to an array of float32 (stored as vec4)
  46592. * @param uniform defines the webGL uniform location where to store the value
  46593. * @param array defines the array of float32 to store
  46594. */
  46595. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46596. /**
  46597. * Set the value of an uniform to an array of number
  46598. * @param uniform defines the webGL uniform location where to store the value
  46599. * @param array defines the array of number to store
  46600. */
  46601. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46602. /**
  46603. * Set the value of an uniform to an array of number (stored as vec2)
  46604. * @param uniform defines the webGL uniform location where to store the value
  46605. * @param array defines the array of number to store
  46606. */
  46607. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46608. /**
  46609. * Set the value of an uniform to an array of number (stored as vec3)
  46610. * @param uniform defines the webGL uniform location where to store the value
  46611. * @param array defines the array of number to store
  46612. */
  46613. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46614. /**
  46615. * Set the value of an uniform to an array of number (stored as vec4)
  46616. * @param uniform defines the webGL uniform location where to store the value
  46617. * @param array defines the array of number to store
  46618. */
  46619. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46620. /**
  46621. * Set the value of an uniform to an array of float32 (stored as matrices)
  46622. * @param uniform defines the webGL uniform location where to store the value
  46623. * @param matrices defines the array of float32 to store
  46624. */
  46625. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46626. /**
  46627. * Set the value of an uniform to a matrix (3x3)
  46628. * @param uniform defines the webGL uniform location where to store the value
  46629. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46630. */
  46631. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46632. /**
  46633. * Set the value of an uniform to a matrix (2x2)
  46634. * @param uniform defines the webGL uniform location where to store the value
  46635. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46636. */
  46637. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46638. /**
  46639. * Set the value of an uniform to a number (float)
  46640. * @param uniform defines the webGL uniform location where to store the value
  46641. * @param value defines the float number to store
  46642. */
  46643. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46644. /**
  46645. * Set the value of an uniform to a vec2
  46646. * @param uniform defines the webGL uniform location where to store the value
  46647. * @param x defines the 1st component of the value
  46648. * @param y defines the 2nd component of the value
  46649. */
  46650. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46651. /**
  46652. * Set the value of an uniform to a vec3
  46653. * @param uniform defines the webGL uniform location where to store the value
  46654. * @param x defines the 1st component of the value
  46655. * @param y defines the 2nd component of the value
  46656. * @param z defines the 3rd component of the value
  46657. */
  46658. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46659. /**
  46660. * Set the value of an uniform to a boolean
  46661. * @param uniform defines the webGL uniform location where to store the value
  46662. * @param bool defines the boolean to store
  46663. */
  46664. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46665. /**
  46666. * Set the value of an uniform to a vec4
  46667. * @param uniform defines the webGL uniform location where to store the value
  46668. * @param x defines the 1st component of the value
  46669. * @param y defines the 2nd component of the value
  46670. * @param z defines the 3rd component of the value
  46671. * @param w defines the 4th component of the value
  46672. */
  46673. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46674. /**
  46675. * Sets the current alpha mode
  46676. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46677. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46678. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46679. */
  46680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46681. /**
  46682. * Bind webGl buffers directly to the webGL context
  46683. * @param vertexBuffers defines the vertex buffer to bind
  46684. * @param indexBuffer defines the index buffer to bind
  46685. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46686. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46687. * @param effect defines the effect associated with the vertex buffer
  46688. */
  46689. bindBuffers(vertexBuffers: {
  46690. [key: string]: VertexBuffer;
  46691. }, indexBuffer: DataBuffer, effect: Effect): void;
  46692. /**
  46693. * Force the entire cache to be cleared
  46694. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46695. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46696. */
  46697. wipeCaches(bruteForce?: boolean): void;
  46698. /**
  46699. * Send a draw order
  46700. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46701. * @param indexStart defines the starting index
  46702. * @param indexCount defines the number of index to draw
  46703. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46704. */
  46705. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46706. /**
  46707. * Draw a list of indexed primitives
  46708. * @param fillMode defines the primitive to use
  46709. * @param indexStart defines the starting index
  46710. * @param indexCount defines the number of index to draw
  46711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46712. */
  46713. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46714. /**
  46715. * Draw a list of unindexed primitives
  46716. * @param fillMode defines the primitive to use
  46717. * @param verticesStart defines the index of first vertex to draw
  46718. * @param verticesCount defines the count of vertices to draw
  46719. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46720. */
  46721. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46722. /** @hidden */
  46723. _createTexture(): WebGLTexture;
  46724. /** @hidden */
  46725. _releaseTexture(texture: InternalTexture): void;
  46726. /**
  46727. * Usually called from Texture.ts.
  46728. * Passed information to create a WebGLTexture
  46729. * @param urlArg defines a value which contains one of the following:
  46730. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46731. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46732. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46733. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46734. * @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)
  46735. * @param scene needed for loading to the correct scene
  46736. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46737. * @param onLoad optional callback to be called upon successful completion
  46738. * @param onError optional callback to be called upon failure
  46739. * @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
  46740. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46741. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46742. * @param forcedExtension defines the extension to use to pick the right loader
  46743. * @param mimeType defines an optional mime type
  46744. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46745. */
  46746. 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>, mimeType?: string): InternalTexture;
  46747. /**
  46748. * Creates a new render target texture
  46749. * @param size defines the size of the texture
  46750. * @param options defines the options used to create the texture
  46751. * @returns a new render target texture stored in an InternalTexture
  46752. */
  46753. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46754. /**
  46755. * Update the sampling mode of a given texture
  46756. * @param samplingMode defines the required sampling mode
  46757. * @param texture defines the texture to update
  46758. */
  46759. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46760. /**
  46761. * Binds the frame buffer to the specified texture.
  46762. * @param texture The texture to render to or null for the default canvas
  46763. * @param faceIndex The face of the texture to render to in case of cube texture
  46764. * @param requiredWidth The width of the target to render to
  46765. * @param requiredHeight The height of the target to render to
  46766. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46767. * @param lodLevel defines le lod level to bind to the frame buffer
  46768. */
  46769. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46770. /**
  46771. * Unbind the current render target texture from the webGL context
  46772. * @param texture defines the render target texture to unbind
  46773. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46774. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46775. */
  46776. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46777. /**
  46778. * Creates a dynamic vertex buffer
  46779. * @param vertices the data for the dynamic vertex buffer
  46780. * @returns the new WebGL dynamic buffer
  46781. */
  46782. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46783. /**
  46784. * Update the content of a dynamic texture
  46785. * @param texture defines the texture to update
  46786. * @param canvas defines the canvas containing the source
  46787. * @param invertY defines if data must be stored with Y axis inverted
  46788. * @param premulAlpha defines if alpha is stored as premultiplied
  46789. * @param format defines the format of the data
  46790. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46791. */
  46792. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46793. /**
  46794. * Gets a boolean indicating if all created effects are ready
  46795. * @returns true if all effects are ready
  46796. */
  46797. areAllEffectsReady(): boolean;
  46798. /**
  46799. * @hidden
  46800. * Get the current error code of the webGL context
  46801. * @returns the error code
  46802. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46803. */
  46804. getError(): number;
  46805. /** @hidden */
  46806. _getUnpackAlignement(): number;
  46807. /** @hidden */
  46808. _unpackFlipY(value: boolean): void;
  46809. /**
  46810. * Update a dynamic index buffer
  46811. * @param indexBuffer defines the target index buffer
  46812. * @param indices defines the data to update
  46813. * @param offset defines the offset in the target index buffer where update should start
  46814. */
  46815. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46816. /**
  46817. * Updates a dynamic vertex buffer.
  46818. * @param vertexBuffer the vertex buffer to update
  46819. * @param vertices the data used to update the vertex buffer
  46820. * @param byteOffset the byte offset of the data (optional)
  46821. * @param byteLength the byte length of the data (optional)
  46822. */
  46823. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46824. /** @hidden */
  46825. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46826. /** @hidden */
  46827. _bindTexture(channel: number, texture: InternalTexture): void;
  46828. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46829. /**
  46830. * 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
  46831. */
  46832. releaseEffects(): void;
  46833. displayLoadingUI(): void;
  46834. hideLoadingUI(): void;
  46835. /** @hidden */
  46836. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46837. /** @hidden */
  46838. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46839. /** @hidden */
  46840. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46841. /** @hidden */
  46842. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46843. }
  46844. }
  46845. declare module BABYLON {
  46846. /**
  46847. * @hidden
  46848. **/
  46849. export class _TimeToken {
  46850. _startTimeQuery: Nullable<WebGLQuery>;
  46851. _endTimeQuery: Nullable<WebGLQuery>;
  46852. _timeElapsedQuery: Nullable<WebGLQuery>;
  46853. _timeElapsedQueryEnded: boolean;
  46854. }
  46855. }
  46856. declare module BABYLON {
  46857. /** @hidden */
  46858. export class _OcclusionDataStorage {
  46859. /** @hidden */
  46860. occlusionInternalRetryCounter: number;
  46861. /** @hidden */
  46862. isOcclusionQueryInProgress: boolean;
  46863. /** @hidden */
  46864. isOccluded: boolean;
  46865. /** @hidden */
  46866. occlusionRetryCount: number;
  46867. /** @hidden */
  46868. occlusionType: number;
  46869. /** @hidden */
  46870. occlusionQueryAlgorithmType: number;
  46871. }
  46872. interface Engine {
  46873. /**
  46874. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46875. * @return the new query
  46876. */
  46877. createQuery(): WebGLQuery;
  46878. /**
  46879. * Delete and release a webGL query
  46880. * @param query defines the query to delete
  46881. * @return the current engine
  46882. */
  46883. deleteQuery(query: WebGLQuery): Engine;
  46884. /**
  46885. * Check if a given query has resolved and got its value
  46886. * @param query defines the query to check
  46887. * @returns true if the query got its value
  46888. */
  46889. isQueryResultAvailable(query: WebGLQuery): boolean;
  46890. /**
  46891. * Gets the value of a given query
  46892. * @param query defines the query to check
  46893. * @returns the value of the query
  46894. */
  46895. getQueryResult(query: WebGLQuery): number;
  46896. /**
  46897. * Initiates an occlusion query
  46898. * @param algorithmType defines the algorithm to use
  46899. * @param query defines the query to use
  46900. * @returns the current engine
  46901. * @see http://doc.babylonjs.com/features/occlusionquery
  46902. */
  46903. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46904. /**
  46905. * Ends an occlusion query
  46906. * @see http://doc.babylonjs.com/features/occlusionquery
  46907. * @param algorithmType defines the algorithm to use
  46908. * @returns the current engine
  46909. */
  46910. endOcclusionQuery(algorithmType: number): Engine;
  46911. /**
  46912. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46913. * Please note that only one query can be issued at a time
  46914. * @returns a time token used to track the time span
  46915. */
  46916. startTimeQuery(): Nullable<_TimeToken>;
  46917. /**
  46918. * Ends a time query
  46919. * @param token defines the token used to measure the time span
  46920. * @returns the time spent (in ns)
  46921. */
  46922. endTimeQuery(token: _TimeToken): int;
  46923. /** @hidden */
  46924. _currentNonTimestampToken: Nullable<_TimeToken>;
  46925. /** @hidden */
  46926. _createTimeQuery(): WebGLQuery;
  46927. /** @hidden */
  46928. _deleteTimeQuery(query: WebGLQuery): void;
  46929. /** @hidden */
  46930. _getGlAlgorithmType(algorithmType: number): number;
  46931. /** @hidden */
  46932. _getTimeQueryResult(query: WebGLQuery): any;
  46933. /** @hidden */
  46934. _getTimeQueryAvailability(query: WebGLQuery): any;
  46935. }
  46936. interface AbstractMesh {
  46937. /**
  46938. * Backing filed
  46939. * @hidden
  46940. */
  46941. __occlusionDataStorage: _OcclusionDataStorage;
  46942. /**
  46943. * Access property
  46944. * @hidden
  46945. */
  46946. _occlusionDataStorage: _OcclusionDataStorage;
  46947. /**
  46948. * 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.
  46949. * The default value is -1 which means don't break the query and wait till the result
  46950. * @see http://doc.babylonjs.com/features/occlusionquery
  46951. */
  46952. occlusionRetryCount: number;
  46953. /**
  46954. * 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:
  46955. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46956. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46957. * * 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.
  46958. * @see http://doc.babylonjs.com/features/occlusionquery
  46959. */
  46960. occlusionType: number;
  46961. /**
  46962. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46963. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46964. * * 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.
  46965. * @see http://doc.babylonjs.com/features/occlusionquery
  46966. */
  46967. occlusionQueryAlgorithmType: number;
  46968. /**
  46969. * 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
  46970. * @see http://doc.babylonjs.com/features/occlusionquery
  46971. */
  46972. isOccluded: boolean;
  46973. /**
  46974. * Flag to check the progress status of the query
  46975. * @see http://doc.babylonjs.com/features/occlusionquery
  46976. */
  46977. isOcclusionQueryInProgress: boolean;
  46978. }
  46979. }
  46980. declare module BABYLON {
  46981. /** @hidden */
  46982. export var _forceTransformFeedbackToBundle: boolean;
  46983. interface Engine {
  46984. /**
  46985. * Creates a webGL transform feedback object
  46986. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46987. * @returns the webGL transform feedback object
  46988. */
  46989. createTransformFeedback(): WebGLTransformFeedback;
  46990. /**
  46991. * Delete a webGL transform feedback object
  46992. * @param value defines the webGL transform feedback object to delete
  46993. */
  46994. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46995. /**
  46996. * Bind a webGL transform feedback object to the webgl context
  46997. * @param value defines the webGL transform feedback object to bind
  46998. */
  46999. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47000. /**
  47001. * Begins a transform feedback operation
  47002. * @param usePoints defines if points or triangles must be used
  47003. */
  47004. beginTransformFeedback(usePoints: boolean): void;
  47005. /**
  47006. * Ends a transform feedback operation
  47007. */
  47008. endTransformFeedback(): void;
  47009. /**
  47010. * Specify the varyings to use with transform feedback
  47011. * @param program defines the associated webGL program
  47012. * @param value defines the list of strings representing the varying names
  47013. */
  47014. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47015. /**
  47016. * Bind a webGL buffer for a transform feedback operation
  47017. * @param value defines the webGL buffer to bind
  47018. */
  47019. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47020. }
  47021. }
  47022. declare module BABYLON {
  47023. /**
  47024. * Creation options of the multi render target texture.
  47025. */
  47026. export interface IMultiRenderTargetOptions {
  47027. /**
  47028. * Define if the texture needs to create mip maps after render.
  47029. */
  47030. generateMipMaps?: boolean;
  47031. /**
  47032. * Define the types of all the draw buffers we want to create
  47033. */
  47034. types?: number[];
  47035. /**
  47036. * Define the sampling modes of all the draw buffers we want to create
  47037. */
  47038. samplingModes?: number[];
  47039. /**
  47040. * Define if a depth buffer is required
  47041. */
  47042. generateDepthBuffer?: boolean;
  47043. /**
  47044. * Define if a stencil buffer is required
  47045. */
  47046. generateStencilBuffer?: boolean;
  47047. /**
  47048. * Define if a depth texture is required instead of a depth buffer
  47049. */
  47050. generateDepthTexture?: boolean;
  47051. /**
  47052. * Define the number of desired draw buffers
  47053. */
  47054. textureCount?: number;
  47055. /**
  47056. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47057. */
  47058. doNotChangeAspectRatio?: boolean;
  47059. /**
  47060. * Define the default type of the buffers we are creating
  47061. */
  47062. defaultType?: number;
  47063. }
  47064. /**
  47065. * A multi render target, like a render target provides the ability to render to a texture.
  47066. * Unlike the render target, it can render to several draw buffers in one draw.
  47067. * This is specially interesting in deferred rendering or for any effects requiring more than
  47068. * just one color from a single pass.
  47069. */
  47070. export class MultiRenderTarget extends RenderTargetTexture {
  47071. private _internalTextures;
  47072. private _textures;
  47073. private _multiRenderTargetOptions;
  47074. /**
  47075. * Get if draw buffers are currently supported by the used hardware and browser.
  47076. */
  47077. get isSupported(): boolean;
  47078. /**
  47079. * Get the list of textures generated by the multi render target.
  47080. */
  47081. get textures(): Texture[];
  47082. /**
  47083. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47084. */
  47085. get depthTexture(): Texture;
  47086. /**
  47087. * Set the wrapping mode on U of all the textures we are rendering to.
  47088. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47089. */
  47090. set wrapU(wrap: number);
  47091. /**
  47092. * Set the wrapping mode on V of all the textures we are rendering to.
  47093. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47094. */
  47095. set wrapV(wrap: number);
  47096. /**
  47097. * Instantiate a new multi render target texture.
  47098. * A multi render target, like a render target provides the ability to render to a texture.
  47099. * Unlike the render target, it can render to several draw buffers in one draw.
  47100. * This is specially interesting in deferred rendering or for any effects requiring more than
  47101. * just one color from a single pass.
  47102. * @param name Define the name of the texture
  47103. * @param size Define the size of the buffers to render to
  47104. * @param count Define the number of target we are rendering into
  47105. * @param scene Define the scene the texture belongs to
  47106. * @param options Define the options used to create the multi render target
  47107. */
  47108. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47109. /** @hidden */
  47110. _rebuild(): void;
  47111. private _createInternalTextures;
  47112. private _createTextures;
  47113. /**
  47114. * Define the number of samples used if MSAA is enabled.
  47115. */
  47116. get samples(): number;
  47117. set samples(value: number);
  47118. /**
  47119. * Resize all the textures in the multi render target.
  47120. * Be carrefull as it will recreate all the data in the new texture.
  47121. * @param size Define the new size
  47122. */
  47123. resize(size: any): void;
  47124. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47125. /**
  47126. * Dispose the render targets and their associated resources
  47127. */
  47128. dispose(): void;
  47129. /**
  47130. * Release all the underlying texture used as draw buffers.
  47131. */
  47132. releaseInternalTextures(): void;
  47133. }
  47134. }
  47135. declare module BABYLON {
  47136. interface ThinEngine {
  47137. /**
  47138. * Unbind a list of render target textures from the webGL context
  47139. * This is used only when drawBuffer extension or webGL2 are active
  47140. * @param textures defines the render target textures to unbind
  47141. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47142. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47143. */
  47144. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47145. /**
  47146. * Create a multi render target texture
  47147. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47148. * @param size defines the size of the texture
  47149. * @param options defines the creation options
  47150. * @returns the cube texture as an InternalTexture
  47151. */
  47152. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47153. /**
  47154. * Update the sample count for a given multiple render target texture
  47155. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47156. * @param textures defines the textures to update
  47157. * @param samples defines the sample count to set
  47158. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47159. */
  47160. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47161. }
  47162. }
  47163. declare module BABYLON {
  47164. /**
  47165. * Class used to define an additional view for the engine
  47166. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47167. */
  47168. export class EngineView {
  47169. /** Defines the canvas where to render the view */
  47170. target: HTMLCanvasElement;
  47171. /** Defines an optional camera used to render the view (will use active camera else) */
  47172. camera?: Camera;
  47173. }
  47174. interface Engine {
  47175. /**
  47176. * Gets or sets the HTML element to use for attaching events
  47177. */
  47178. inputElement: Nullable<HTMLElement>;
  47179. /**
  47180. * Gets the current engine view
  47181. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47182. */
  47183. activeView: Nullable<EngineView>;
  47184. /** Gets or sets the list of views */
  47185. views: EngineView[];
  47186. /**
  47187. * Register a new child canvas
  47188. * @param canvas defines the canvas to register
  47189. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47190. * @returns the associated view
  47191. */
  47192. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47193. /**
  47194. * Remove a registered child canvas
  47195. * @param canvas defines the canvas to remove
  47196. * @returns the current engine
  47197. */
  47198. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47199. }
  47200. }
  47201. declare module BABYLON {
  47202. /**
  47203. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47204. */
  47205. export interface CubeMapInfo {
  47206. /**
  47207. * The pixel array for the front face.
  47208. * This is stored in format, left to right, up to down format.
  47209. */
  47210. front: Nullable<ArrayBufferView>;
  47211. /**
  47212. * The pixel array for the back face.
  47213. * This is stored in format, left to right, up to down format.
  47214. */
  47215. back: Nullable<ArrayBufferView>;
  47216. /**
  47217. * The pixel array for the left face.
  47218. * This is stored in format, left to right, up to down format.
  47219. */
  47220. left: Nullable<ArrayBufferView>;
  47221. /**
  47222. * The pixel array for the right face.
  47223. * This is stored in format, left to right, up to down format.
  47224. */
  47225. right: Nullable<ArrayBufferView>;
  47226. /**
  47227. * The pixel array for the up face.
  47228. * This is stored in format, left to right, up to down format.
  47229. */
  47230. up: Nullable<ArrayBufferView>;
  47231. /**
  47232. * The pixel array for the down face.
  47233. * This is stored in format, left to right, up to down format.
  47234. */
  47235. down: Nullable<ArrayBufferView>;
  47236. /**
  47237. * The size of the cubemap stored.
  47238. *
  47239. * Each faces will be size * size pixels.
  47240. */
  47241. size: number;
  47242. /**
  47243. * The format of the texture.
  47244. *
  47245. * RGBA, RGB.
  47246. */
  47247. format: number;
  47248. /**
  47249. * The type of the texture data.
  47250. *
  47251. * UNSIGNED_INT, FLOAT.
  47252. */
  47253. type: number;
  47254. /**
  47255. * Specifies whether the texture is in gamma space.
  47256. */
  47257. gammaSpace: boolean;
  47258. }
  47259. /**
  47260. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47261. */
  47262. export class PanoramaToCubeMapTools {
  47263. private static FACE_FRONT;
  47264. private static FACE_BACK;
  47265. private static FACE_RIGHT;
  47266. private static FACE_LEFT;
  47267. private static FACE_DOWN;
  47268. private static FACE_UP;
  47269. /**
  47270. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47271. *
  47272. * @param float32Array The source data.
  47273. * @param inputWidth The width of the input panorama.
  47274. * @param inputHeight The height of the input panorama.
  47275. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47276. * @return The cubemap data
  47277. */
  47278. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47279. private static CreateCubemapTexture;
  47280. private static CalcProjectionSpherical;
  47281. }
  47282. }
  47283. declare module BABYLON {
  47284. /**
  47285. * Helper class dealing with the extraction of spherical polynomial dataArray
  47286. * from a cube map.
  47287. */
  47288. export class CubeMapToSphericalPolynomialTools {
  47289. private static FileFaces;
  47290. /**
  47291. * Converts a texture to the according Spherical Polynomial data.
  47292. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47293. *
  47294. * @param texture The texture to extract the information from.
  47295. * @return The Spherical Polynomial data.
  47296. */
  47297. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47298. /**
  47299. * Converts a cubemap to the according Spherical Polynomial data.
  47300. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47301. *
  47302. * @param cubeInfo The Cube map to extract the information from.
  47303. * @return The Spherical Polynomial data.
  47304. */
  47305. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47306. }
  47307. }
  47308. declare module BABYLON {
  47309. interface BaseTexture {
  47310. /**
  47311. * Get the polynomial representation of the texture data.
  47312. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47313. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47314. */
  47315. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47316. }
  47317. }
  47318. declare module BABYLON {
  47319. /** @hidden */
  47320. export var rgbdEncodePixelShader: {
  47321. name: string;
  47322. shader: string;
  47323. };
  47324. }
  47325. declare module BABYLON {
  47326. /** @hidden */
  47327. export var rgbdDecodePixelShader: {
  47328. name: string;
  47329. shader: string;
  47330. };
  47331. }
  47332. declare module BABYLON {
  47333. /**
  47334. * Raw texture data and descriptor sufficient for WebGL texture upload
  47335. */
  47336. export interface EnvironmentTextureInfo {
  47337. /**
  47338. * Version of the environment map
  47339. */
  47340. version: number;
  47341. /**
  47342. * Width of image
  47343. */
  47344. width: number;
  47345. /**
  47346. * Irradiance information stored in the file.
  47347. */
  47348. irradiance: any;
  47349. /**
  47350. * Specular information stored in the file.
  47351. */
  47352. specular: any;
  47353. }
  47354. /**
  47355. * Defines One Image in the file. It requires only the position in the file
  47356. * as well as the length.
  47357. */
  47358. interface BufferImageData {
  47359. /**
  47360. * Length of the image data.
  47361. */
  47362. length: number;
  47363. /**
  47364. * Position of the data from the null terminator delimiting the end of the JSON.
  47365. */
  47366. position: number;
  47367. }
  47368. /**
  47369. * Defines the specular data enclosed in the file.
  47370. * This corresponds to the version 1 of the data.
  47371. */
  47372. export interface EnvironmentTextureSpecularInfoV1 {
  47373. /**
  47374. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47375. */
  47376. specularDataPosition?: number;
  47377. /**
  47378. * This contains all the images data needed to reconstruct the cubemap.
  47379. */
  47380. mipmaps: Array<BufferImageData>;
  47381. /**
  47382. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47383. */
  47384. lodGenerationScale: number;
  47385. }
  47386. /**
  47387. * Sets of helpers addressing the serialization and deserialization of environment texture
  47388. * stored in a BabylonJS env file.
  47389. * Those files are usually stored as .env files.
  47390. */
  47391. export class EnvironmentTextureTools {
  47392. /**
  47393. * Magic number identifying the env file.
  47394. */
  47395. private static _MagicBytes;
  47396. /**
  47397. * Gets the environment info from an env file.
  47398. * @param data The array buffer containing the .env bytes.
  47399. * @returns the environment file info (the json header) if successfully parsed.
  47400. */
  47401. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47402. /**
  47403. * Creates an environment texture from a loaded cube texture.
  47404. * @param texture defines the cube texture to convert in env file
  47405. * @return a promise containing the environment data if succesfull.
  47406. */
  47407. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47408. /**
  47409. * Creates a JSON representation of the spherical data.
  47410. * @param texture defines the texture containing the polynomials
  47411. * @return the JSON representation of the spherical info
  47412. */
  47413. private static _CreateEnvTextureIrradiance;
  47414. /**
  47415. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47416. * @param data the image data
  47417. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47418. * @return the views described by info providing access to the underlying buffer
  47419. */
  47420. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47421. /**
  47422. * Uploads the texture info contained in the env file to the GPU.
  47423. * @param texture defines the internal texture to upload to
  47424. * @param data defines the data to load
  47425. * @param info defines the texture info retrieved through the GetEnvInfo method
  47426. * @returns a promise
  47427. */
  47428. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47429. private static _OnImageReadyAsync;
  47430. /**
  47431. * Uploads the levels of image data to the GPU.
  47432. * @param texture defines the internal texture to upload to
  47433. * @param imageData defines the array buffer views of image data [mipmap][face]
  47434. * @returns a promise
  47435. */
  47436. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47437. /**
  47438. * Uploads spherical polynomials information to the texture.
  47439. * @param texture defines the texture we are trying to upload the information to
  47440. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47441. */
  47442. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47443. /** @hidden */
  47444. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47445. }
  47446. }
  47447. declare module BABYLON {
  47448. /**
  47449. * Contains position and normal vectors for a vertex
  47450. */
  47451. export class PositionNormalVertex {
  47452. /** the position of the vertex (defaut: 0,0,0) */
  47453. position: Vector3;
  47454. /** the normal of the vertex (defaut: 0,1,0) */
  47455. normal: Vector3;
  47456. /**
  47457. * Creates a PositionNormalVertex
  47458. * @param position the position of the vertex (defaut: 0,0,0)
  47459. * @param normal the normal of the vertex (defaut: 0,1,0)
  47460. */
  47461. constructor(
  47462. /** the position of the vertex (defaut: 0,0,0) */
  47463. position?: Vector3,
  47464. /** the normal of the vertex (defaut: 0,1,0) */
  47465. normal?: Vector3);
  47466. /**
  47467. * Clones the PositionNormalVertex
  47468. * @returns the cloned PositionNormalVertex
  47469. */
  47470. clone(): PositionNormalVertex;
  47471. }
  47472. /**
  47473. * Contains position, normal and uv vectors for a vertex
  47474. */
  47475. export class PositionNormalTextureVertex {
  47476. /** the position of the vertex (defaut: 0,0,0) */
  47477. position: Vector3;
  47478. /** the normal of the vertex (defaut: 0,1,0) */
  47479. normal: Vector3;
  47480. /** the uv of the vertex (default: 0,0) */
  47481. uv: Vector2;
  47482. /**
  47483. * Creates a PositionNormalTextureVertex
  47484. * @param position the position of the vertex (defaut: 0,0,0)
  47485. * @param normal the normal of the vertex (defaut: 0,1,0)
  47486. * @param uv the uv of the vertex (default: 0,0)
  47487. */
  47488. constructor(
  47489. /** the position of the vertex (defaut: 0,0,0) */
  47490. position?: Vector3,
  47491. /** the normal of the vertex (defaut: 0,1,0) */
  47492. normal?: Vector3,
  47493. /** the uv of the vertex (default: 0,0) */
  47494. uv?: Vector2);
  47495. /**
  47496. * Clones the PositionNormalTextureVertex
  47497. * @returns the cloned PositionNormalTextureVertex
  47498. */
  47499. clone(): PositionNormalTextureVertex;
  47500. }
  47501. }
  47502. declare module BABYLON {
  47503. /** @hidden */
  47504. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47505. private _genericAttributeLocation;
  47506. private _varyingLocationCount;
  47507. private _varyingLocationMap;
  47508. private _replacements;
  47509. private _textureCount;
  47510. private _uniforms;
  47511. lineProcessor(line: string): string;
  47512. attributeProcessor(attribute: string): string;
  47513. varyingProcessor(varying: string, isFragment: boolean): string;
  47514. uniformProcessor(uniform: string): string;
  47515. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47516. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * Container for accessors for natively-stored mesh data buffers.
  47522. */
  47523. class NativeDataBuffer extends DataBuffer {
  47524. /**
  47525. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47526. */
  47527. nativeIndexBuffer?: any;
  47528. /**
  47529. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47530. */
  47531. nativeVertexBuffer?: any;
  47532. }
  47533. /** @hidden */
  47534. class NativeTexture extends InternalTexture {
  47535. getInternalTexture(): InternalTexture;
  47536. getViewCount(): number;
  47537. }
  47538. /** @hidden */
  47539. export class NativeEngine extends Engine {
  47540. private readonly _native;
  47541. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47542. private readonly INVALID_HANDLE;
  47543. getHardwareScalingLevel(): number;
  47544. constructor();
  47545. /**
  47546. * Can be used to override the current requestAnimationFrame requester.
  47547. * @hidden
  47548. */
  47549. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47550. /**
  47551. * Override default engine behavior.
  47552. * @param color
  47553. * @param backBuffer
  47554. * @param depth
  47555. * @param stencil
  47556. */
  47557. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47558. /**
  47559. * Gets host document
  47560. * @returns the host document object
  47561. */
  47562. getHostDocument(): Nullable<Document>;
  47563. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47564. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47565. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47566. recordVertexArrayObject(vertexBuffers: {
  47567. [key: string]: VertexBuffer;
  47568. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47569. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47570. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47572. /**
  47573. * Draw a list of indexed primitives
  47574. * @param fillMode defines the primitive to use
  47575. * @param indexStart defines the starting index
  47576. * @param indexCount defines the number of index to draw
  47577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47578. */
  47579. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47580. /**
  47581. * Draw a list of unindexed primitives
  47582. * @param fillMode defines the primitive to use
  47583. * @param verticesStart defines the index of first vertex to draw
  47584. * @param verticesCount defines the count of vertices to draw
  47585. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47586. */
  47587. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47588. createPipelineContext(): IPipelineContext;
  47589. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47590. /** @hidden */
  47591. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47592. /** @hidden */
  47593. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47594. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47595. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47596. protected _setProgram(program: WebGLProgram): void;
  47597. _releaseEffect(effect: Effect): void;
  47598. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47599. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47600. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47601. bindSamplers(effect: Effect): void;
  47602. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47603. getRenderWidth(useScreen?: boolean): number;
  47604. getRenderHeight(useScreen?: boolean): number;
  47605. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47606. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47607. /**
  47608. * Set the z offset to apply to current rendering
  47609. * @param value defines the offset to apply
  47610. */
  47611. setZOffset(value: number): void;
  47612. /**
  47613. * Gets the current value of the zOffset
  47614. * @returns the current zOffset state
  47615. */
  47616. getZOffset(): number;
  47617. /**
  47618. * Enable or disable depth buffering
  47619. * @param enable defines the state to set
  47620. */
  47621. setDepthBuffer(enable: boolean): void;
  47622. /**
  47623. * Gets a boolean indicating if depth writing is enabled
  47624. * @returns the current depth writing state
  47625. */
  47626. getDepthWrite(): boolean;
  47627. /**
  47628. * Enable or disable depth writing
  47629. * @param enable defines the state to set
  47630. */
  47631. setDepthWrite(enable: boolean): void;
  47632. /**
  47633. * Enable or disable color writing
  47634. * @param enable defines the state to set
  47635. */
  47636. setColorWrite(enable: boolean): void;
  47637. /**
  47638. * Gets a boolean indicating if color writing is enabled
  47639. * @returns the current color writing state
  47640. */
  47641. getColorWrite(): boolean;
  47642. /**
  47643. * Sets alpha constants used by some alpha blending modes
  47644. * @param r defines the red component
  47645. * @param g defines the green component
  47646. * @param b defines the blue component
  47647. * @param a defines the alpha component
  47648. */
  47649. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47650. /**
  47651. * Sets the current alpha mode
  47652. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47653. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47655. */
  47656. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47657. /**
  47658. * Gets the current alpha mode
  47659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47660. * @returns the current alpha mode
  47661. */
  47662. getAlphaMode(): number;
  47663. setInt(uniform: WebGLUniformLocation, int: number): void;
  47664. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47665. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47666. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47667. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47668. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47669. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47670. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47671. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47672. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47673. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47674. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47675. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47676. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47677. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47678. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47679. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47680. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47681. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47682. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47683. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47684. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47685. wipeCaches(bruteForce?: boolean): void;
  47686. _createTexture(): WebGLTexture;
  47687. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47688. /**
  47689. * Usually called from Texture.ts.
  47690. * Passed information to create a WebGLTexture
  47691. * @param urlArg defines a value which contains one of the following:
  47692. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47693. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47694. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47696. * @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)
  47697. * @param scene needed for loading to the correct scene
  47698. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47699. * @param onLoad optional callback to be called upon successful completion
  47700. * @param onError optional callback to be called upon failure
  47701. * @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
  47702. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47703. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47704. * @param forcedExtension defines the extension to use to pick the right loader
  47705. * @param mimeType defines an optional mime type
  47706. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47707. */
  47708. 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>, mimeType?: string): InternalTexture;
  47709. /**
  47710. * Creates a cube texture
  47711. * @param rootUrl defines the url where the files to load is located
  47712. * @param scene defines the current scene
  47713. * @param files defines the list of files to load (1 per face)
  47714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47715. * @param onLoad defines an optional callback raised when the texture is loaded
  47716. * @param onError defines an optional callback raised if there is an issue to load the texture
  47717. * @param format defines the format of the data
  47718. * @param forcedExtension defines the extension to use to pick the right loader
  47719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47722. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47723. * @returns the cube texture as an InternalTexture
  47724. */
  47725. 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;
  47726. private _getSamplingFilter;
  47727. private static _GetNativeTextureFormat;
  47728. createRenderTargetTexture(size: number | {
  47729. width: number;
  47730. height: number;
  47731. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47732. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47733. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47734. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47735. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47736. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47737. /**
  47738. * Updates a dynamic vertex buffer.
  47739. * @param vertexBuffer the vertex buffer to update
  47740. * @param data the data used to update the vertex buffer
  47741. * @param byteOffset the byte offset of the data (optional)
  47742. * @param byteLength the byte length of the data (optional)
  47743. */
  47744. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47745. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47746. private _updateAnisotropicLevel;
  47747. private _getAddressMode;
  47748. /** @hidden */
  47749. _bindTexture(channel: number, texture: InternalTexture): void;
  47750. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47751. releaseEffects(): void;
  47752. /** @hidden */
  47753. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47754. /** @hidden */
  47755. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47756. /** @hidden */
  47757. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47758. /** @hidden */
  47759. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47760. }
  47761. }
  47762. declare module BABYLON {
  47763. /**
  47764. * Gather the list of clipboard event types as constants.
  47765. */
  47766. export class ClipboardEventTypes {
  47767. /**
  47768. * The clipboard event is fired when a copy command is active (pressed).
  47769. */
  47770. static readonly COPY: number;
  47771. /**
  47772. * The clipboard event is fired when a cut command is active (pressed).
  47773. */
  47774. static readonly CUT: number;
  47775. /**
  47776. * The clipboard event is fired when a paste command is active (pressed).
  47777. */
  47778. static readonly PASTE: number;
  47779. }
  47780. /**
  47781. * This class is used to store clipboard related info for the onClipboardObservable event.
  47782. */
  47783. export class ClipboardInfo {
  47784. /**
  47785. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47786. */
  47787. type: number;
  47788. /**
  47789. * Defines the related dom event
  47790. */
  47791. event: ClipboardEvent;
  47792. /**
  47793. *Creates an instance of ClipboardInfo.
  47794. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47795. * @param event Defines the related dom event
  47796. */
  47797. constructor(
  47798. /**
  47799. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47800. */
  47801. type: number,
  47802. /**
  47803. * Defines the related dom event
  47804. */
  47805. event: ClipboardEvent);
  47806. /**
  47807. * Get the clipboard event's type from the keycode.
  47808. * @param keyCode Defines the keyCode for the current keyboard event.
  47809. * @return {number}
  47810. */
  47811. static GetTypeFromCharacter(keyCode: number): number;
  47812. }
  47813. }
  47814. declare module BABYLON {
  47815. /**
  47816. * Google Daydream controller
  47817. */
  47818. export class DaydreamController extends WebVRController {
  47819. /**
  47820. * Base Url for the controller model.
  47821. */
  47822. static MODEL_BASE_URL: string;
  47823. /**
  47824. * File name for the controller model.
  47825. */
  47826. static MODEL_FILENAME: string;
  47827. /**
  47828. * Gamepad Id prefix used to identify Daydream Controller.
  47829. */
  47830. static readonly GAMEPAD_ID_PREFIX: string;
  47831. /**
  47832. * Creates a new DaydreamController from a gamepad
  47833. * @param vrGamepad the gamepad that the controller should be created from
  47834. */
  47835. constructor(vrGamepad: any);
  47836. /**
  47837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47838. * @param scene scene in which to add meshes
  47839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47840. */
  47841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47842. /**
  47843. * Called once for each button that changed state since the last frame
  47844. * @param buttonIdx Which button index changed
  47845. * @param state New state of the button
  47846. * @param changes Which properties on the state changed since last frame
  47847. */
  47848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47849. }
  47850. }
  47851. declare module BABYLON {
  47852. /**
  47853. * Gear VR Controller
  47854. */
  47855. export class GearVRController extends WebVRController {
  47856. /**
  47857. * Base Url for the controller model.
  47858. */
  47859. static MODEL_BASE_URL: string;
  47860. /**
  47861. * File name for the controller model.
  47862. */
  47863. static MODEL_FILENAME: string;
  47864. /**
  47865. * Gamepad Id prefix used to identify this controller.
  47866. */
  47867. static readonly GAMEPAD_ID_PREFIX: string;
  47868. private readonly _buttonIndexToObservableNameMap;
  47869. /**
  47870. * Creates a new GearVRController from a gamepad
  47871. * @param vrGamepad the gamepad that the controller should be created from
  47872. */
  47873. constructor(vrGamepad: any);
  47874. /**
  47875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47876. * @param scene scene in which to add meshes
  47877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47878. */
  47879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47880. /**
  47881. * Called once for each button that changed state since the last frame
  47882. * @param buttonIdx Which button index changed
  47883. * @param state New state of the button
  47884. * @param changes Which properties on the state changed since last frame
  47885. */
  47886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47887. }
  47888. }
  47889. declare module BABYLON {
  47890. /**
  47891. * Generic Controller
  47892. */
  47893. export class GenericController extends WebVRController {
  47894. /**
  47895. * Base Url for the controller model.
  47896. */
  47897. static readonly MODEL_BASE_URL: string;
  47898. /**
  47899. * File name for the controller model.
  47900. */
  47901. static readonly MODEL_FILENAME: string;
  47902. /**
  47903. * Creates a new GenericController from a gamepad
  47904. * @param vrGamepad the gamepad that the controller should be created from
  47905. */
  47906. constructor(vrGamepad: any);
  47907. /**
  47908. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47909. * @param scene scene in which to add meshes
  47910. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47911. */
  47912. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47913. /**
  47914. * Called once for each button that changed state since the last frame
  47915. * @param buttonIdx Which button index changed
  47916. * @param state New state of the button
  47917. * @param changes Which properties on the state changed since last frame
  47918. */
  47919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47920. }
  47921. }
  47922. declare module BABYLON {
  47923. /**
  47924. * Oculus Touch Controller
  47925. */
  47926. export class OculusTouchController extends WebVRController {
  47927. /**
  47928. * Base Url for the controller model.
  47929. */
  47930. static MODEL_BASE_URL: string;
  47931. /**
  47932. * File name for the left controller model.
  47933. */
  47934. static MODEL_LEFT_FILENAME: string;
  47935. /**
  47936. * File name for the right controller model.
  47937. */
  47938. static MODEL_RIGHT_FILENAME: string;
  47939. /**
  47940. * Base Url for the Quest controller model.
  47941. */
  47942. static QUEST_MODEL_BASE_URL: string;
  47943. /**
  47944. * @hidden
  47945. * If the controllers are running on a device that needs the updated Quest controller models
  47946. */
  47947. static _IsQuest: boolean;
  47948. /**
  47949. * Fired when the secondary trigger on this controller is modified
  47950. */
  47951. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47952. /**
  47953. * Fired when the thumb rest on this controller is modified
  47954. */
  47955. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47956. /**
  47957. * Creates a new OculusTouchController from a gamepad
  47958. * @param vrGamepad the gamepad that the controller should be created from
  47959. */
  47960. constructor(vrGamepad: any);
  47961. /**
  47962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47963. * @param scene scene in which to add meshes
  47964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47965. */
  47966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47967. /**
  47968. * Fired when the A button on this controller is modified
  47969. */
  47970. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47971. /**
  47972. * Fired when the B button on this controller is modified
  47973. */
  47974. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47975. /**
  47976. * Fired when the X button on this controller is modified
  47977. */
  47978. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47979. /**
  47980. * Fired when the Y button on this controller is modified
  47981. */
  47982. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47983. /**
  47984. * Called once for each button that changed state since the last frame
  47985. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47986. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47987. * 2) secondary trigger (same)
  47988. * 3) A (right) X (left), touch, pressed = value
  47989. * 4) B / Y
  47990. * 5) thumb rest
  47991. * @param buttonIdx Which button index changed
  47992. * @param state New state of the button
  47993. * @param changes Which properties on the state changed since last frame
  47994. */
  47995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47996. }
  47997. }
  47998. declare module BABYLON {
  47999. /**
  48000. * Vive Controller
  48001. */
  48002. export class ViveController extends WebVRController {
  48003. /**
  48004. * Base Url for the controller model.
  48005. */
  48006. static MODEL_BASE_URL: string;
  48007. /**
  48008. * File name for the controller model.
  48009. */
  48010. static MODEL_FILENAME: string;
  48011. /**
  48012. * Creates a new ViveController from a gamepad
  48013. * @param vrGamepad the gamepad that the controller should be created from
  48014. */
  48015. constructor(vrGamepad: any);
  48016. /**
  48017. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48018. * @param scene scene in which to add meshes
  48019. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48020. */
  48021. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48022. /**
  48023. * Fired when the left button on this controller is modified
  48024. */
  48025. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48026. /**
  48027. * Fired when the right button on this controller is modified
  48028. */
  48029. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48030. /**
  48031. * Fired when the menu button on this controller is modified
  48032. */
  48033. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48034. /**
  48035. * Called once for each button that changed state since the last frame
  48036. * Vive mapping:
  48037. * 0: touchpad
  48038. * 1: trigger
  48039. * 2: left AND right buttons
  48040. * 3: menu button
  48041. * @param buttonIdx Which button index changed
  48042. * @param state New state of the button
  48043. * @param changes Which properties on the state changed since last frame
  48044. */
  48045. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48046. }
  48047. }
  48048. declare module BABYLON {
  48049. /**
  48050. * Defines the WindowsMotionController object that the state of the windows motion controller
  48051. */
  48052. export class WindowsMotionController extends WebVRController {
  48053. /**
  48054. * The base url used to load the left and right controller models
  48055. */
  48056. static MODEL_BASE_URL: string;
  48057. /**
  48058. * The name of the left controller model file
  48059. */
  48060. static MODEL_LEFT_FILENAME: string;
  48061. /**
  48062. * The name of the right controller model file
  48063. */
  48064. static MODEL_RIGHT_FILENAME: string;
  48065. /**
  48066. * The controller name prefix for this controller type
  48067. */
  48068. static readonly GAMEPAD_ID_PREFIX: string;
  48069. /**
  48070. * The controller id pattern for this controller type
  48071. */
  48072. private static readonly GAMEPAD_ID_PATTERN;
  48073. private _loadedMeshInfo;
  48074. protected readonly _mapping: {
  48075. buttons: string[];
  48076. buttonMeshNames: {
  48077. 'trigger': string;
  48078. 'menu': string;
  48079. 'grip': string;
  48080. 'thumbstick': string;
  48081. 'trackpad': string;
  48082. };
  48083. buttonObservableNames: {
  48084. 'trigger': string;
  48085. 'menu': string;
  48086. 'grip': string;
  48087. 'thumbstick': string;
  48088. 'trackpad': string;
  48089. };
  48090. axisMeshNames: string[];
  48091. pointingPoseMeshName: string;
  48092. };
  48093. /**
  48094. * Fired when the trackpad on this controller is clicked
  48095. */
  48096. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48097. /**
  48098. * Fired when the trackpad on this controller is modified
  48099. */
  48100. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48101. /**
  48102. * The current x and y values of this controller's trackpad
  48103. */
  48104. trackpad: StickValues;
  48105. /**
  48106. * Creates a new WindowsMotionController from a gamepad
  48107. * @param vrGamepad the gamepad that the controller should be created from
  48108. */
  48109. constructor(vrGamepad: any);
  48110. /**
  48111. * Fired when the trigger on this controller is modified
  48112. */
  48113. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48114. /**
  48115. * Fired when the menu button on this controller is modified
  48116. */
  48117. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48118. /**
  48119. * Fired when the grip button on this controller is modified
  48120. */
  48121. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48122. /**
  48123. * Fired when the thumbstick button on this controller is modified
  48124. */
  48125. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48126. /**
  48127. * Fired when the touchpad button on this controller is modified
  48128. */
  48129. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48130. /**
  48131. * Fired when the touchpad values on this controller are modified
  48132. */
  48133. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48134. protected _updateTrackpad(): void;
  48135. /**
  48136. * Called once per frame by the engine.
  48137. */
  48138. update(): void;
  48139. /**
  48140. * Called once for each button that changed state since the last frame
  48141. * @param buttonIdx Which button index changed
  48142. * @param state New state of the button
  48143. * @param changes Which properties on the state changed since last frame
  48144. */
  48145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48146. /**
  48147. * Moves the buttons on the controller mesh based on their current state
  48148. * @param buttonName the name of the button to move
  48149. * @param buttonValue the value of the button which determines the buttons new position
  48150. */
  48151. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48152. /**
  48153. * Moves the axis on the controller mesh based on its current state
  48154. * @param axis the index of the axis
  48155. * @param axisValue the value of the axis which determines the meshes new position
  48156. * @hidden
  48157. */
  48158. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48159. /**
  48160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48161. * @param scene scene in which to add meshes
  48162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48163. */
  48164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48165. /**
  48166. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48167. * can be transformed by button presses and axes values, based on this._mapping.
  48168. *
  48169. * @param scene scene in which the meshes exist
  48170. * @param meshes list of meshes that make up the controller model to process
  48171. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48172. */
  48173. private processModel;
  48174. private createMeshInfo;
  48175. /**
  48176. * Gets the ray of the controller in the direction the controller is pointing
  48177. * @param length the length the resulting ray should be
  48178. * @returns a ray in the direction the controller is pointing
  48179. */
  48180. getForwardRay(length?: number): Ray;
  48181. /**
  48182. * Disposes of the controller
  48183. */
  48184. dispose(): void;
  48185. }
  48186. /**
  48187. * This class represents a new windows motion controller in XR.
  48188. */
  48189. export class XRWindowsMotionController extends WindowsMotionController {
  48190. /**
  48191. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48192. */
  48193. protected readonly _mapping: {
  48194. buttons: string[];
  48195. buttonMeshNames: {
  48196. 'trigger': string;
  48197. 'menu': string;
  48198. 'grip': string;
  48199. 'thumbstick': string;
  48200. 'trackpad': string;
  48201. };
  48202. buttonObservableNames: {
  48203. 'trigger': string;
  48204. 'menu': string;
  48205. 'grip': string;
  48206. 'thumbstick': string;
  48207. 'trackpad': string;
  48208. };
  48209. axisMeshNames: string[];
  48210. pointingPoseMeshName: string;
  48211. };
  48212. /**
  48213. * Construct a new XR-Based windows motion controller
  48214. *
  48215. * @param gamepadInfo the gamepad object from the browser
  48216. */
  48217. constructor(gamepadInfo: any);
  48218. /**
  48219. * holds the thumbstick values (X,Y)
  48220. */
  48221. thumbstickValues: StickValues;
  48222. /**
  48223. * Fired when the thumbstick on this controller is clicked
  48224. */
  48225. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48226. /**
  48227. * Fired when the thumbstick on this controller is modified
  48228. */
  48229. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48230. /**
  48231. * Fired when the touchpad button on this controller is modified
  48232. */
  48233. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48234. /**
  48235. * Fired when the touchpad values on this controller are modified
  48236. */
  48237. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48238. /**
  48239. * Fired when the thumbstick button on this controller is modified
  48240. * here to prevent breaking changes
  48241. */
  48242. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48243. /**
  48244. * updating the thumbstick(!) and not the trackpad.
  48245. * This is named this way due to the difference between WebVR and XR and to avoid
  48246. * changing the parent class.
  48247. */
  48248. protected _updateTrackpad(): void;
  48249. /**
  48250. * Disposes the class with joy
  48251. */
  48252. dispose(): void;
  48253. }
  48254. }
  48255. declare module BABYLON {
  48256. /**
  48257. * Class containing static functions to help procedurally build meshes
  48258. */
  48259. export class PolyhedronBuilder {
  48260. /**
  48261. * Creates a polyhedron mesh
  48262. * * 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
  48263. * * The parameter `size` (positive float, default 1) sets the polygon size
  48264. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48265. * * 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`
  48266. * * 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
  48267. * * 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)`)
  48268. * * 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
  48269. * * 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
  48270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48271. * * 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
  48272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48273. * @param name defines the name of the mesh
  48274. * @param options defines the options used to create the mesh
  48275. * @param scene defines the hosting scene
  48276. * @returns the polyhedron mesh
  48277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48278. */
  48279. static CreatePolyhedron(name: string, options: {
  48280. type?: number;
  48281. size?: number;
  48282. sizeX?: number;
  48283. sizeY?: number;
  48284. sizeZ?: number;
  48285. custom?: any;
  48286. faceUV?: Vector4[];
  48287. faceColors?: Color4[];
  48288. flat?: boolean;
  48289. updatable?: boolean;
  48290. sideOrientation?: number;
  48291. frontUVs?: Vector4;
  48292. backUVs?: Vector4;
  48293. }, scene?: Nullable<Scene>): Mesh;
  48294. }
  48295. }
  48296. declare module BABYLON {
  48297. /**
  48298. * Gizmo that enables scaling a mesh along 3 axis
  48299. */
  48300. export class ScaleGizmo extends Gizmo {
  48301. /**
  48302. * Internal gizmo used for interactions on the x axis
  48303. */
  48304. xGizmo: AxisScaleGizmo;
  48305. /**
  48306. * Internal gizmo used for interactions on the y axis
  48307. */
  48308. yGizmo: AxisScaleGizmo;
  48309. /**
  48310. * Internal gizmo used for interactions on the z axis
  48311. */
  48312. zGizmo: AxisScaleGizmo;
  48313. /**
  48314. * Internal gizmo used to scale all axis equally
  48315. */
  48316. uniformScaleGizmo: AxisScaleGizmo;
  48317. private _meshAttached;
  48318. private _updateGizmoRotationToMatchAttachedMesh;
  48319. private _snapDistance;
  48320. private _scaleRatio;
  48321. private _uniformScalingMesh;
  48322. private _octahedron;
  48323. private _sensitivity;
  48324. /** Fires an event when any of it's sub gizmos are dragged */
  48325. onDragStartObservable: Observable<unknown>;
  48326. /** Fires an event when any of it's sub gizmos are released from dragging */
  48327. onDragEndObservable: Observable<unknown>;
  48328. get attachedMesh(): Nullable<AbstractMesh>;
  48329. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48330. /**
  48331. * Creates a ScaleGizmo
  48332. * @param gizmoLayer The utility layer the gizmo will be added to
  48333. */
  48334. constructor(gizmoLayer?: UtilityLayerRenderer);
  48335. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48336. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48337. /**
  48338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48339. */
  48340. set snapDistance(value: number);
  48341. get snapDistance(): number;
  48342. /**
  48343. * Ratio for the scale of the gizmo (Default: 1)
  48344. */
  48345. set scaleRatio(value: number);
  48346. get scaleRatio(): number;
  48347. /**
  48348. * Sensitivity factor for dragging (Default: 1)
  48349. */
  48350. set sensitivity(value: number);
  48351. get sensitivity(): number;
  48352. /**
  48353. * Disposes of the gizmo
  48354. */
  48355. dispose(): void;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /**
  48360. * Single axis scale gizmo
  48361. */
  48362. export class AxisScaleGizmo extends Gizmo {
  48363. /**
  48364. * Drag behavior responsible for the gizmos dragging interactions
  48365. */
  48366. dragBehavior: PointerDragBehavior;
  48367. private _pointerObserver;
  48368. /**
  48369. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48370. */
  48371. snapDistance: number;
  48372. /**
  48373. * Event that fires each time the gizmo snaps to a new location.
  48374. * * snapDistance is the the change in distance
  48375. */
  48376. onSnapObservable: Observable<{
  48377. snapDistance: number;
  48378. }>;
  48379. /**
  48380. * If the scaling operation should be done on all axis (default: false)
  48381. */
  48382. uniformScaling: boolean;
  48383. /**
  48384. * Custom sensitivity value for the drag strength
  48385. */
  48386. sensitivity: number;
  48387. private _isEnabled;
  48388. private _parent;
  48389. private _arrow;
  48390. private _coloredMaterial;
  48391. private _hoverMaterial;
  48392. /**
  48393. * Creates an AxisScaleGizmo
  48394. * @param gizmoLayer The utility layer the gizmo will be added to
  48395. * @param dragAxis The axis which the gizmo will be able to scale on
  48396. * @param color The color of the gizmo
  48397. */
  48398. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48399. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48400. /**
  48401. * If the gizmo is enabled
  48402. */
  48403. set isEnabled(value: boolean);
  48404. get isEnabled(): boolean;
  48405. /**
  48406. * Disposes of the gizmo
  48407. */
  48408. dispose(): void;
  48409. /**
  48410. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48411. * @param mesh The mesh to replace the default mesh of the gizmo
  48412. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48413. */
  48414. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48415. }
  48416. }
  48417. declare module BABYLON {
  48418. /**
  48419. * Bounding box gizmo
  48420. */
  48421. export class BoundingBoxGizmo extends Gizmo {
  48422. private _lineBoundingBox;
  48423. private _rotateSpheresParent;
  48424. private _scaleBoxesParent;
  48425. private _boundingDimensions;
  48426. private _renderObserver;
  48427. private _pointerObserver;
  48428. private _scaleDragSpeed;
  48429. private _tmpQuaternion;
  48430. private _tmpVector;
  48431. private _tmpRotationMatrix;
  48432. /**
  48433. * 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)
  48434. */
  48435. ignoreChildren: boolean;
  48436. /**
  48437. * 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)
  48438. */
  48439. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48440. /**
  48441. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48442. */
  48443. rotationSphereSize: number;
  48444. /**
  48445. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48446. */
  48447. scaleBoxSize: number;
  48448. /**
  48449. * 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)
  48450. */
  48451. fixedDragMeshScreenSize: boolean;
  48452. /**
  48453. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48454. */
  48455. fixedDragMeshScreenSizeDistanceFactor: number;
  48456. /**
  48457. * Fired when a rotation sphere or scale box is dragged
  48458. */
  48459. onDragStartObservable: Observable<{}>;
  48460. /**
  48461. * Fired when a scale box is dragged
  48462. */
  48463. onScaleBoxDragObservable: Observable<{}>;
  48464. /**
  48465. * Fired when a scale box drag is ended
  48466. */
  48467. onScaleBoxDragEndObservable: Observable<{}>;
  48468. /**
  48469. * Fired when a rotation sphere is dragged
  48470. */
  48471. onRotationSphereDragObservable: Observable<{}>;
  48472. /**
  48473. * Fired when a rotation sphere drag is ended
  48474. */
  48475. onRotationSphereDragEndObservable: Observable<{}>;
  48476. /**
  48477. * 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)
  48478. */
  48479. scalePivot: Nullable<Vector3>;
  48480. /**
  48481. * Mesh used as a pivot to rotate the attached mesh
  48482. */
  48483. private _anchorMesh;
  48484. private _existingMeshScale;
  48485. private _dragMesh;
  48486. private pointerDragBehavior;
  48487. private coloredMaterial;
  48488. private hoverColoredMaterial;
  48489. /**
  48490. * Sets the color of the bounding box gizmo
  48491. * @param color the color to set
  48492. */
  48493. setColor(color: Color3): void;
  48494. /**
  48495. * Creates an BoundingBoxGizmo
  48496. * @param gizmoLayer The utility layer the gizmo will be added to
  48497. * @param color The color of the gizmo
  48498. */
  48499. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48501. private _selectNode;
  48502. /**
  48503. * Updates the bounding box information for the Gizmo
  48504. */
  48505. updateBoundingBox(): void;
  48506. private _updateRotationSpheres;
  48507. private _updateScaleBoxes;
  48508. /**
  48509. * Enables rotation on the specified axis and disables rotation on the others
  48510. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48511. */
  48512. setEnabledRotationAxis(axis: string): void;
  48513. /**
  48514. * Enables/disables scaling
  48515. * @param enable if scaling should be enabled
  48516. */
  48517. setEnabledScaling(enable: boolean): void;
  48518. private _updateDummy;
  48519. /**
  48520. * Enables a pointer drag behavior on the bounding box of the gizmo
  48521. */
  48522. enableDragBehavior(): void;
  48523. /**
  48524. * Disposes of the gizmo
  48525. */
  48526. dispose(): void;
  48527. /**
  48528. * 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)
  48529. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48530. * @returns the bounding box mesh with the passed in mesh as a child
  48531. */
  48532. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48533. /**
  48534. * CustomMeshes are not supported by this gizmo
  48535. * @param mesh The mesh to replace the default mesh of the gizmo
  48536. */
  48537. setCustomMesh(mesh: Mesh): void;
  48538. }
  48539. }
  48540. declare module BABYLON {
  48541. /**
  48542. * Single plane rotation gizmo
  48543. */
  48544. export class PlaneRotationGizmo extends Gizmo {
  48545. /**
  48546. * Drag behavior responsible for the gizmos dragging interactions
  48547. */
  48548. dragBehavior: PointerDragBehavior;
  48549. private _pointerObserver;
  48550. /**
  48551. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48552. */
  48553. snapDistance: number;
  48554. /**
  48555. * Event that fires each time the gizmo snaps to a new location.
  48556. * * snapDistance is the the change in distance
  48557. */
  48558. onSnapObservable: Observable<{
  48559. snapDistance: number;
  48560. }>;
  48561. private _isEnabled;
  48562. private _parent;
  48563. /**
  48564. * Creates a PlaneRotationGizmo
  48565. * @param gizmoLayer The utility layer the gizmo will be added to
  48566. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48567. * @param color The color of the gizmo
  48568. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48569. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48570. */
  48571. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48573. /**
  48574. * If the gizmo is enabled
  48575. */
  48576. set isEnabled(value: boolean);
  48577. get isEnabled(): boolean;
  48578. /**
  48579. * Disposes of the gizmo
  48580. */
  48581. dispose(): void;
  48582. }
  48583. }
  48584. declare module BABYLON {
  48585. /**
  48586. * Gizmo that enables rotating a mesh along 3 axis
  48587. */
  48588. export class RotationGizmo extends Gizmo {
  48589. /**
  48590. * Internal gizmo used for interactions on the x axis
  48591. */
  48592. xGizmo: PlaneRotationGizmo;
  48593. /**
  48594. * Internal gizmo used for interactions on the y axis
  48595. */
  48596. yGizmo: PlaneRotationGizmo;
  48597. /**
  48598. * Internal gizmo used for interactions on the z axis
  48599. */
  48600. zGizmo: PlaneRotationGizmo;
  48601. /** Fires an event when any of it's sub gizmos are dragged */
  48602. onDragStartObservable: Observable<unknown>;
  48603. /** Fires an event when any of it's sub gizmos are released from dragging */
  48604. onDragEndObservable: Observable<unknown>;
  48605. private _meshAttached;
  48606. get attachedMesh(): Nullable<AbstractMesh>;
  48607. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48608. /**
  48609. * Creates a RotationGizmo
  48610. * @param gizmoLayer The utility layer the gizmo will be added to
  48611. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48612. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48613. */
  48614. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48615. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48616. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48617. /**
  48618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48619. */
  48620. set snapDistance(value: number);
  48621. get snapDistance(): number;
  48622. /**
  48623. * Ratio for the scale of the gizmo (Default: 1)
  48624. */
  48625. set scaleRatio(value: number);
  48626. get scaleRatio(): number;
  48627. /**
  48628. * Disposes of the gizmo
  48629. */
  48630. dispose(): void;
  48631. /**
  48632. * CustomMeshes are not supported by this gizmo
  48633. * @param mesh The mesh to replace the default mesh of the gizmo
  48634. */
  48635. setCustomMesh(mesh: Mesh): void;
  48636. }
  48637. }
  48638. declare module BABYLON {
  48639. /**
  48640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48641. */
  48642. export class GizmoManager implements IDisposable {
  48643. private scene;
  48644. /**
  48645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48646. */
  48647. gizmos: {
  48648. positionGizmo: Nullable<PositionGizmo>;
  48649. rotationGizmo: Nullable<RotationGizmo>;
  48650. scaleGizmo: Nullable<ScaleGizmo>;
  48651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48652. };
  48653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48654. clearGizmoOnEmptyPointerEvent: boolean;
  48655. /** Fires an event when the manager is attached to a mesh */
  48656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48657. private _gizmosEnabled;
  48658. private _pointerObserver;
  48659. private _attachedMesh;
  48660. private _boundingBoxColor;
  48661. private _defaultUtilityLayer;
  48662. private _defaultKeepDepthUtilityLayer;
  48663. /**
  48664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48665. */
  48666. boundingBoxDragBehavior: SixDofDragBehavior;
  48667. /**
  48668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48669. */
  48670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48671. /**
  48672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48673. */
  48674. usePointerToAttachGizmos: boolean;
  48675. /**
  48676. * Utility layer that the bounding box gizmo belongs to
  48677. */
  48678. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48679. /**
  48680. * Utility layer that all gizmos besides bounding box belong to
  48681. */
  48682. get utilityLayer(): UtilityLayerRenderer;
  48683. /**
  48684. * Instatiates a gizmo manager
  48685. * @param scene the scene to overlay the gizmos on top of
  48686. */
  48687. constructor(scene: Scene);
  48688. /**
  48689. * Attaches a set of gizmos to the specified mesh
  48690. * @param mesh The mesh the gizmo's should be attached to
  48691. */
  48692. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48693. /**
  48694. * If the position gizmo is enabled
  48695. */
  48696. set positionGizmoEnabled(value: boolean);
  48697. get positionGizmoEnabled(): boolean;
  48698. /**
  48699. * If the rotation gizmo is enabled
  48700. */
  48701. set rotationGizmoEnabled(value: boolean);
  48702. get rotationGizmoEnabled(): boolean;
  48703. /**
  48704. * If the scale gizmo is enabled
  48705. */
  48706. set scaleGizmoEnabled(value: boolean);
  48707. get scaleGizmoEnabled(): boolean;
  48708. /**
  48709. * If the boundingBox gizmo is enabled
  48710. */
  48711. set boundingBoxGizmoEnabled(value: boolean);
  48712. get boundingBoxGizmoEnabled(): boolean;
  48713. /**
  48714. * Disposes of the gizmo manager
  48715. */
  48716. dispose(): void;
  48717. }
  48718. }
  48719. declare module BABYLON {
  48720. /**
  48721. * A directional light is defined by a direction (what a surprise!).
  48722. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48723. * 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.
  48724. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48725. */
  48726. export class DirectionalLight extends ShadowLight {
  48727. private _shadowFrustumSize;
  48728. /**
  48729. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48730. */
  48731. get shadowFrustumSize(): number;
  48732. /**
  48733. * Specifies a fix frustum size for the shadow generation.
  48734. */
  48735. set shadowFrustumSize(value: number);
  48736. private _shadowOrthoScale;
  48737. /**
  48738. * Gets the shadow projection scale against the optimal computed one.
  48739. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48740. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48741. */
  48742. get shadowOrthoScale(): number;
  48743. /**
  48744. * Sets the shadow projection scale against the optimal computed one.
  48745. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48746. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48747. */
  48748. set shadowOrthoScale(value: number);
  48749. /**
  48750. * Automatically compute the projection matrix to best fit (including all the casters)
  48751. * on each frame.
  48752. */
  48753. autoUpdateExtends: boolean;
  48754. /**
  48755. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48756. * on each frame. autoUpdateExtends must be set to true for this to work
  48757. */
  48758. autoCalcShadowZBounds: boolean;
  48759. private _orthoLeft;
  48760. private _orthoRight;
  48761. private _orthoTop;
  48762. private _orthoBottom;
  48763. /**
  48764. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48765. * The directional light is emitted from everywhere in the given direction.
  48766. * It can cast shadows.
  48767. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48768. * @param name The friendly name of the light
  48769. * @param direction The direction of the light
  48770. * @param scene The scene the light belongs to
  48771. */
  48772. constructor(name: string, direction: Vector3, scene: Scene);
  48773. /**
  48774. * Returns the string "DirectionalLight".
  48775. * @return The class name
  48776. */
  48777. getClassName(): string;
  48778. /**
  48779. * Returns the integer 1.
  48780. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48781. */
  48782. getTypeID(): number;
  48783. /**
  48784. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48785. * Returns the DirectionalLight Shadow projection matrix.
  48786. */
  48787. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48788. /**
  48789. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48790. * Returns the DirectionalLight Shadow projection matrix.
  48791. */
  48792. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48793. /**
  48794. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48795. * Returns the DirectionalLight Shadow projection matrix.
  48796. */
  48797. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48798. protected _buildUniformLayout(): void;
  48799. /**
  48800. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48801. * @param effect The effect to update
  48802. * @param lightIndex The index of the light in the effect to update
  48803. * @returns The directional light
  48804. */
  48805. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48806. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48807. /**
  48808. * Gets the minZ used for shadow according to both the scene and the light.
  48809. *
  48810. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48811. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48812. * @param activeCamera The camera we are returning the min for
  48813. * @returns the depth min z
  48814. */
  48815. getDepthMinZ(activeCamera: Camera): number;
  48816. /**
  48817. * Gets the maxZ used for shadow according to both the scene and the light.
  48818. *
  48819. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48820. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48821. * @param activeCamera The camera we are returning the max for
  48822. * @returns the depth max z
  48823. */
  48824. getDepthMaxZ(activeCamera: Camera): number;
  48825. /**
  48826. * Prepares the list of defines specific to the light type.
  48827. * @param defines the list of defines
  48828. * @param lightIndex defines the index of the light for the effect
  48829. */
  48830. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * Class containing static functions to help procedurally build meshes
  48836. */
  48837. export class HemisphereBuilder {
  48838. /**
  48839. * Creates a hemisphere mesh
  48840. * @param name defines the name of the mesh
  48841. * @param options defines the options used to create the mesh
  48842. * @param scene defines the hosting scene
  48843. * @returns the hemisphere mesh
  48844. */
  48845. static CreateHemisphere(name: string, options: {
  48846. segments?: number;
  48847. diameter?: number;
  48848. sideOrientation?: number;
  48849. }, scene: any): Mesh;
  48850. }
  48851. }
  48852. declare module BABYLON {
  48853. /**
  48854. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48855. * These values define a cone of light starting from the position, emitting toward the direction.
  48856. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48857. * and the exponent defines the speed of the decay of the light with distance (reach).
  48858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48859. */
  48860. export class SpotLight extends ShadowLight {
  48861. private _angle;
  48862. private _innerAngle;
  48863. private _cosHalfAngle;
  48864. private _lightAngleScale;
  48865. private _lightAngleOffset;
  48866. /**
  48867. * Gets the cone angle of the spot light in Radians.
  48868. */
  48869. get angle(): number;
  48870. /**
  48871. * Sets the cone angle of the spot light in Radians.
  48872. */
  48873. set angle(value: number);
  48874. /**
  48875. * Only used in gltf falloff mode, this defines the angle where
  48876. * the directional falloff will start before cutting at angle which could be seen
  48877. * as outer angle.
  48878. */
  48879. get innerAngle(): number;
  48880. /**
  48881. * Only used in gltf falloff mode, this defines the angle where
  48882. * the directional falloff will start before cutting at angle which could be seen
  48883. * as outer angle.
  48884. */
  48885. set innerAngle(value: number);
  48886. private _shadowAngleScale;
  48887. /**
  48888. * Allows scaling the angle of the light for shadow generation only.
  48889. */
  48890. get shadowAngleScale(): number;
  48891. /**
  48892. * Allows scaling the angle of the light for shadow generation only.
  48893. */
  48894. set shadowAngleScale(value: number);
  48895. /**
  48896. * The light decay speed with the distance from the emission spot.
  48897. */
  48898. exponent: number;
  48899. private _projectionTextureMatrix;
  48900. /**
  48901. * Allows reading the projecton texture
  48902. */
  48903. get projectionTextureMatrix(): Matrix;
  48904. protected _projectionTextureLightNear: number;
  48905. /**
  48906. * Gets the near clip of the Spotlight for texture projection.
  48907. */
  48908. get projectionTextureLightNear(): number;
  48909. /**
  48910. * Sets the near clip of the Spotlight for texture projection.
  48911. */
  48912. set projectionTextureLightNear(value: number);
  48913. protected _projectionTextureLightFar: number;
  48914. /**
  48915. * Gets the far clip of the Spotlight for texture projection.
  48916. */
  48917. get projectionTextureLightFar(): number;
  48918. /**
  48919. * Sets the far clip of the Spotlight for texture projection.
  48920. */
  48921. set projectionTextureLightFar(value: number);
  48922. protected _projectionTextureUpDirection: Vector3;
  48923. /**
  48924. * Gets the Up vector of the Spotlight for texture projection.
  48925. */
  48926. get projectionTextureUpDirection(): Vector3;
  48927. /**
  48928. * Sets the Up vector of the Spotlight for texture projection.
  48929. */
  48930. set projectionTextureUpDirection(value: Vector3);
  48931. private _projectionTexture;
  48932. /**
  48933. * Gets the projection texture of the light.
  48934. */
  48935. get projectionTexture(): Nullable<BaseTexture>;
  48936. /**
  48937. * Sets the projection texture of the light.
  48938. */
  48939. set projectionTexture(value: Nullable<BaseTexture>);
  48940. private _projectionTextureViewLightDirty;
  48941. private _projectionTextureProjectionLightDirty;
  48942. private _projectionTextureDirty;
  48943. private _projectionTextureViewTargetVector;
  48944. private _projectionTextureViewLightMatrix;
  48945. private _projectionTextureProjectionLightMatrix;
  48946. private _projectionTextureScalingMatrix;
  48947. /**
  48948. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48949. * It can cast shadows.
  48950. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48951. * @param name The light friendly name
  48952. * @param position The position of the spot light in the scene
  48953. * @param direction The direction of the light in the scene
  48954. * @param angle The cone angle of the light in Radians
  48955. * @param exponent The light decay speed with the distance from the emission spot
  48956. * @param scene The scene the lights belongs to
  48957. */
  48958. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48959. /**
  48960. * Returns the string "SpotLight".
  48961. * @returns the class name
  48962. */
  48963. getClassName(): string;
  48964. /**
  48965. * Returns the integer 2.
  48966. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48967. */
  48968. getTypeID(): number;
  48969. /**
  48970. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48971. */
  48972. protected _setDirection(value: Vector3): void;
  48973. /**
  48974. * Overrides the position setter to recompute the projection texture view light Matrix.
  48975. */
  48976. protected _setPosition(value: Vector3): void;
  48977. /**
  48978. * 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.
  48979. * Returns the SpotLight.
  48980. */
  48981. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48982. protected _computeProjectionTextureViewLightMatrix(): void;
  48983. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48984. /**
  48985. * Main function for light texture projection matrix computing.
  48986. */
  48987. protected _computeProjectionTextureMatrix(): void;
  48988. protected _buildUniformLayout(): void;
  48989. private _computeAngleValues;
  48990. /**
  48991. * Sets the passed Effect "effect" with the Light textures.
  48992. * @param effect The effect to update
  48993. * @param lightIndex The index of the light in the effect to update
  48994. * @returns The light
  48995. */
  48996. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48997. /**
  48998. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48999. * @param effect The effect to update
  49000. * @param lightIndex The index of the light in the effect to update
  49001. * @returns The spot light
  49002. */
  49003. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49004. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49005. /**
  49006. * Disposes the light and the associated resources.
  49007. */
  49008. dispose(): void;
  49009. /**
  49010. * Prepares the list of defines specific to the light type.
  49011. * @param defines the list of defines
  49012. * @param lightIndex defines the index of the light for the effect
  49013. */
  49014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49015. }
  49016. }
  49017. declare module BABYLON {
  49018. /**
  49019. * Gizmo that enables viewing a light
  49020. */
  49021. export class LightGizmo extends Gizmo {
  49022. private _lightMesh;
  49023. private _material;
  49024. private _cachedPosition;
  49025. private _cachedForward;
  49026. private _attachedMeshParent;
  49027. /**
  49028. * Creates a LightGizmo
  49029. * @param gizmoLayer The utility layer the gizmo will be added to
  49030. */
  49031. constructor(gizmoLayer?: UtilityLayerRenderer);
  49032. private _light;
  49033. /**
  49034. * The light that the gizmo is attached to
  49035. */
  49036. set light(light: Nullable<Light>);
  49037. get light(): Nullable<Light>;
  49038. /**
  49039. * Gets the material used to render the light gizmo
  49040. */
  49041. get material(): StandardMaterial;
  49042. /**
  49043. * @hidden
  49044. * Updates the gizmo to match the attached mesh's position/rotation
  49045. */
  49046. protected _update(): void;
  49047. private static _Scale;
  49048. /**
  49049. * Creates the lines for a light mesh
  49050. */
  49051. private static _CreateLightLines;
  49052. /**
  49053. * Disposes of the light gizmo
  49054. */
  49055. dispose(): void;
  49056. private static _CreateHemisphericLightMesh;
  49057. private static _CreatePointLightMesh;
  49058. private static _CreateSpotLightMesh;
  49059. private static _CreateDirectionalLightMesh;
  49060. }
  49061. }
  49062. declare module BABYLON {
  49063. /** @hidden */
  49064. export var backgroundFragmentDeclaration: {
  49065. name: string;
  49066. shader: string;
  49067. };
  49068. }
  49069. declare module BABYLON {
  49070. /** @hidden */
  49071. export var backgroundUboDeclaration: {
  49072. name: string;
  49073. shader: string;
  49074. };
  49075. }
  49076. declare module BABYLON {
  49077. /** @hidden */
  49078. export var backgroundPixelShader: {
  49079. name: string;
  49080. shader: string;
  49081. };
  49082. }
  49083. declare module BABYLON {
  49084. /** @hidden */
  49085. export var backgroundVertexDeclaration: {
  49086. name: string;
  49087. shader: string;
  49088. };
  49089. }
  49090. declare module BABYLON {
  49091. /** @hidden */
  49092. export var backgroundVertexShader: {
  49093. name: string;
  49094. shader: string;
  49095. };
  49096. }
  49097. declare module BABYLON {
  49098. /**
  49099. * Background material used to create an efficient environement around your scene.
  49100. */
  49101. export class BackgroundMaterial extends PushMaterial {
  49102. /**
  49103. * Standard reflectance value at parallel view angle.
  49104. */
  49105. static StandardReflectance0: number;
  49106. /**
  49107. * Standard reflectance value at grazing angle.
  49108. */
  49109. static StandardReflectance90: number;
  49110. protected _primaryColor: Color3;
  49111. /**
  49112. * Key light Color (multiply against the environement texture)
  49113. */
  49114. primaryColor: Color3;
  49115. protected __perceptualColor: Nullable<Color3>;
  49116. /**
  49117. * Experimental Internal Use Only.
  49118. *
  49119. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49120. * This acts as a helper to set the primary color to a more "human friendly" value.
  49121. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49122. * output color as close as possible from the chosen value.
  49123. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49124. * part of lighting setup.)
  49125. */
  49126. get _perceptualColor(): Nullable<Color3>;
  49127. set _perceptualColor(value: Nullable<Color3>);
  49128. protected _primaryColorShadowLevel: float;
  49129. /**
  49130. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49131. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49132. */
  49133. get primaryColorShadowLevel(): float;
  49134. set primaryColorShadowLevel(value: float);
  49135. protected _primaryColorHighlightLevel: float;
  49136. /**
  49137. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49138. * The primary color is used at the level chosen to define what the white area would look.
  49139. */
  49140. get primaryColorHighlightLevel(): float;
  49141. set primaryColorHighlightLevel(value: float);
  49142. protected _reflectionTexture: Nullable<BaseTexture>;
  49143. /**
  49144. * Reflection Texture used in the material.
  49145. * Should be author in a specific way for the best result (refer to the documentation).
  49146. */
  49147. reflectionTexture: Nullable<BaseTexture>;
  49148. protected _reflectionBlur: float;
  49149. /**
  49150. * Reflection Texture level of blur.
  49151. *
  49152. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49153. * texture twice.
  49154. */
  49155. reflectionBlur: float;
  49156. protected _diffuseTexture: Nullable<BaseTexture>;
  49157. /**
  49158. * Diffuse Texture used in the material.
  49159. * Should be author in a specific way for the best result (refer to the documentation).
  49160. */
  49161. diffuseTexture: Nullable<BaseTexture>;
  49162. protected _shadowLights: Nullable<IShadowLight[]>;
  49163. /**
  49164. * Specify the list of lights casting shadow on the material.
  49165. * All scene shadow lights will be included if null.
  49166. */
  49167. shadowLights: Nullable<IShadowLight[]>;
  49168. protected _shadowLevel: float;
  49169. /**
  49170. * Helps adjusting the shadow to a softer level if required.
  49171. * 0 means black shadows and 1 means no shadows.
  49172. */
  49173. shadowLevel: float;
  49174. protected _sceneCenter: Vector3;
  49175. /**
  49176. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49177. * It is usually zero but might be interesting to modify according to your setup.
  49178. */
  49179. sceneCenter: Vector3;
  49180. protected _opacityFresnel: boolean;
  49181. /**
  49182. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49183. * This helps ensuring a nice transition when the camera goes under the ground.
  49184. */
  49185. opacityFresnel: boolean;
  49186. protected _reflectionFresnel: boolean;
  49187. /**
  49188. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49189. * This helps adding a mirror texture on the ground.
  49190. */
  49191. reflectionFresnel: boolean;
  49192. protected _reflectionFalloffDistance: number;
  49193. /**
  49194. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49195. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49196. */
  49197. reflectionFalloffDistance: number;
  49198. protected _reflectionAmount: number;
  49199. /**
  49200. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49201. */
  49202. reflectionAmount: number;
  49203. protected _reflectionReflectance0: number;
  49204. /**
  49205. * This specifies the weight of the reflection at grazing angle.
  49206. */
  49207. reflectionReflectance0: number;
  49208. protected _reflectionReflectance90: number;
  49209. /**
  49210. * This specifies the weight of the reflection at a perpendicular point of view.
  49211. */
  49212. reflectionReflectance90: number;
  49213. /**
  49214. * Sets the reflection reflectance fresnel values according to the default standard
  49215. * empirically know to work well :-)
  49216. */
  49217. set reflectionStandardFresnelWeight(value: number);
  49218. protected _useRGBColor: boolean;
  49219. /**
  49220. * Helps to directly use the maps channels instead of their level.
  49221. */
  49222. useRGBColor: boolean;
  49223. protected _enableNoise: boolean;
  49224. /**
  49225. * This helps reducing the banding effect that could occur on the background.
  49226. */
  49227. enableNoise: boolean;
  49228. /**
  49229. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49230. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49231. * Recommended to be keep at 1.0 except for special cases.
  49232. */
  49233. get fovMultiplier(): number;
  49234. set fovMultiplier(value: number);
  49235. private _fovMultiplier;
  49236. /**
  49237. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49238. */
  49239. useEquirectangularFOV: boolean;
  49240. private _maxSimultaneousLights;
  49241. /**
  49242. * Number of Simultaneous lights allowed on the material.
  49243. */
  49244. maxSimultaneousLights: int;
  49245. /**
  49246. * Default configuration related to image processing available in the Background Material.
  49247. */
  49248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49249. /**
  49250. * Keep track of the image processing observer to allow dispose and replace.
  49251. */
  49252. private _imageProcessingObserver;
  49253. /**
  49254. * Attaches a new image processing configuration to the PBR Material.
  49255. * @param configuration (if null the scene configuration will be use)
  49256. */
  49257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49258. /**
  49259. * Gets the image processing configuration used either in this material.
  49260. */
  49261. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49262. /**
  49263. * Sets the Default image processing configuration used either in the this material.
  49264. *
  49265. * If sets to null, the scene one is in use.
  49266. */
  49267. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49268. /**
  49269. * Gets wether the color curves effect is enabled.
  49270. */
  49271. get cameraColorCurvesEnabled(): boolean;
  49272. /**
  49273. * Sets wether the color curves effect is enabled.
  49274. */
  49275. set cameraColorCurvesEnabled(value: boolean);
  49276. /**
  49277. * Gets wether the color grading effect is enabled.
  49278. */
  49279. get cameraColorGradingEnabled(): boolean;
  49280. /**
  49281. * Gets wether the color grading effect is enabled.
  49282. */
  49283. set cameraColorGradingEnabled(value: boolean);
  49284. /**
  49285. * Gets wether tonemapping is enabled or not.
  49286. */
  49287. get cameraToneMappingEnabled(): boolean;
  49288. /**
  49289. * Sets wether tonemapping is enabled or not
  49290. */
  49291. set cameraToneMappingEnabled(value: boolean);
  49292. /**
  49293. * The camera exposure used on this material.
  49294. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49295. * This corresponds to a photographic exposure.
  49296. */
  49297. get cameraExposure(): float;
  49298. /**
  49299. * The camera exposure used on this material.
  49300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49301. * This corresponds to a photographic exposure.
  49302. */
  49303. set cameraExposure(value: float);
  49304. /**
  49305. * Gets The camera contrast used on this material.
  49306. */
  49307. get cameraContrast(): float;
  49308. /**
  49309. * Sets The camera contrast used on this material.
  49310. */
  49311. set cameraContrast(value: float);
  49312. /**
  49313. * Gets the Color Grading 2D Lookup Texture.
  49314. */
  49315. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49316. /**
  49317. * Sets the Color Grading 2D Lookup Texture.
  49318. */
  49319. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49320. /**
  49321. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49322. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49323. * 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;
  49324. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49325. */
  49326. get cameraColorCurves(): Nullable<ColorCurves>;
  49327. /**
  49328. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49329. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49330. * 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;
  49331. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49332. */
  49333. set cameraColorCurves(value: Nullable<ColorCurves>);
  49334. /**
  49335. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49336. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49337. */
  49338. switchToBGR: boolean;
  49339. private _renderTargets;
  49340. private _reflectionControls;
  49341. private _white;
  49342. private _primaryShadowColor;
  49343. private _primaryHighlightColor;
  49344. /**
  49345. * Instantiates a Background Material in the given scene
  49346. * @param name The friendly name of the material
  49347. * @param scene The scene to add the material to
  49348. */
  49349. constructor(name: string, scene: Scene);
  49350. /**
  49351. * Gets a boolean indicating that current material needs to register RTT
  49352. */
  49353. get hasRenderTargetTextures(): boolean;
  49354. /**
  49355. * The entire material has been created in order to prevent overdraw.
  49356. * @returns false
  49357. */
  49358. needAlphaTesting(): boolean;
  49359. /**
  49360. * The entire material has been created in order to prevent overdraw.
  49361. * @returns true if blending is enable
  49362. */
  49363. needAlphaBlending(): boolean;
  49364. /**
  49365. * Checks wether the material is ready to be rendered for a given mesh.
  49366. * @param mesh The mesh to render
  49367. * @param subMesh The submesh to check against
  49368. * @param useInstances Specify wether or not the material is used with instances
  49369. * @returns true if all the dependencies are ready (Textures, Effects...)
  49370. */
  49371. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49372. /**
  49373. * Compute the primary color according to the chosen perceptual color.
  49374. */
  49375. private _computePrimaryColorFromPerceptualColor;
  49376. /**
  49377. * Compute the highlights and shadow colors according to their chosen levels.
  49378. */
  49379. private _computePrimaryColors;
  49380. /**
  49381. * Build the uniform buffer used in the material.
  49382. */
  49383. buildUniformLayout(): void;
  49384. /**
  49385. * Unbind the material.
  49386. */
  49387. unbind(): void;
  49388. /**
  49389. * Bind only the world matrix to the material.
  49390. * @param world The world matrix to bind.
  49391. */
  49392. bindOnlyWorldMatrix(world: Matrix): void;
  49393. /**
  49394. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49395. * @param world The world matrix to bind.
  49396. * @param subMesh The submesh to bind for.
  49397. */
  49398. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49399. /**
  49400. * Checks to see if a texture is used in the material.
  49401. * @param texture - Base texture to use.
  49402. * @returns - Boolean specifying if a texture is used in the material.
  49403. */
  49404. hasTexture(texture: BaseTexture): boolean;
  49405. /**
  49406. * Dispose the material.
  49407. * @param forceDisposeEffect Force disposal of the associated effect.
  49408. * @param forceDisposeTextures Force disposal of the associated textures.
  49409. */
  49410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49411. /**
  49412. * Clones the material.
  49413. * @param name The cloned name.
  49414. * @returns The cloned material.
  49415. */
  49416. clone(name: string): BackgroundMaterial;
  49417. /**
  49418. * Serializes the current material to its JSON representation.
  49419. * @returns The JSON representation.
  49420. */
  49421. serialize(): any;
  49422. /**
  49423. * Gets the class name of the material
  49424. * @returns "BackgroundMaterial"
  49425. */
  49426. getClassName(): string;
  49427. /**
  49428. * Parse a JSON input to create back a background material.
  49429. * @param source The JSON data to parse
  49430. * @param scene The scene to create the parsed material in
  49431. * @param rootUrl The root url of the assets the material depends upon
  49432. * @returns the instantiated BackgroundMaterial.
  49433. */
  49434. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49435. }
  49436. }
  49437. declare module BABYLON {
  49438. /**
  49439. * Represents the different options available during the creation of
  49440. * a Environment helper.
  49441. *
  49442. * This can control the default ground, skybox and image processing setup of your scene.
  49443. */
  49444. export interface IEnvironmentHelperOptions {
  49445. /**
  49446. * Specifies whether or not to create a ground.
  49447. * True by default.
  49448. */
  49449. createGround: boolean;
  49450. /**
  49451. * Specifies the ground size.
  49452. * 15 by default.
  49453. */
  49454. groundSize: number;
  49455. /**
  49456. * The texture used on the ground for the main color.
  49457. * Comes from the BabylonJS CDN by default.
  49458. *
  49459. * Remarks: Can be either a texture or a url.
  49460. */
  49461. groundTexture: string | BaseTexture;
  49462. /**
  49463. * The color mixed in the ground texture by default.
  49464. * BabylonJS clearColor by default.
  49465. */
  49466. groundColor: Color3;
  49467. /**
  49468. * Specifies the ground opacity.
  49469. * 1 by default.
  49470. */
  49471. groundOpacity: number;
  49472. /**
  49473. * Enables the ground to receive shadows.
  49474. * True by default.
  49475. */
  49476. enableGroundShadow: boolean;
  49477. /**
  49478. * Helps preventing the shadow to be fully black on the ground.
  49479. * 0.5 by default.
  49480. */
  49481. groundShadowLevel: number;
  49482. /**
  49483. * Creates a mirror texture attach to the ground.
  49484. * false by default.
  49485. */
  49486. enableGroundMirror: boolean;
  49487. /**
  49488. * Specifies the ground mirror size ratio.
  49489. * 0.3 by default as the default kernel is 64.
  49490. */
  49491. groundMirrorSizeRatio: number;
  49492. /**
  49493. * Specifies the ground mirror blur kernel size.
  49494. * 64 by default.
  49495. */
  49496. groundMirrorBlurKernel: number;
  49497. /**
  49498. * Specifies the ground mirror visibility amount.
  49499. * 1 by default
  49500. */
  49501. groundMirrorAmount: number;
  49502. /**
  49503. * Specifies the ground mirror reflectance weight.
  49504. * This uses the standard weight of the background material to setup the fresnel effect
  49505. * of the mirror.
  49506. * 1 by default.
  49507. */
  49508. groundMirrorFresnelWeight: number;
  49509. /**
  49510. * Specifies the ground mirror Falloff distance.
  49511. * This can helps reducing the size of the reflection.
  49512. * 0 by Default.
  49513. */
  49514. groundMirrorFallOffDistance: number;
  49515. /**
  49516. * Specifies the ground mirror texture type.
  49517. * Unsigned Int by Default.
  49518. */
  49519. groundMirrorTextureType: number;
  49520. /**
  49521. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49522. * the shown objects.
  49523. */
  49524. groundYBias: number;
  49525. /**
  49526. * Specifies whether or not to create a skybox.
  49527. * True by default.
  49528. */
  49529. createSkybox: boolean;
  49530. /**
  49531. * Specifies the skybox size.
  49532. * 20 by default.
  49533. */
  49534. skyboxSize: number;
  49535. /**
  49536. * The texture used on the skybox for the main color.
  49537. * Comes from the BabylonJS CDN by default.
  49538. *
  49539. * Remarks: Can be either a texture or a url.
  49540. */
  49541. skyboxTexture: string | BaseTexture;
  49542. /**
  49543. * The color mixed in the skybox texture by default.
  49544. * BabylonJS clearColor by default.
  49545. */
  49546. skyboxColor: Color3;
  49547. /**
  49548. * The background rotation around the Y axis of the scene.
  49549. * This helps aligning the key lights of your scene with the background.
  49550. * 0 by default.
  49551. */
  49552. backgroundYRotation: number;
  49553. /**
  49554. * Compute automatically the size of the elements to best fit with the scene.
  49555. */
  49556. sizeAuto: boolean;
  49557. /**
  49558. * Default position of the rootMesh if autoSize is not true.
  49559. */
  49560. rootPosition: Vector3;
  49561. /**
  49562. * Sets up the image processing in the scene.
  49563. * true by default.
  49564. */
  49565. setupImageProcessing: boolean;
  49566. /**
  49567. * The texture used as your environment texture in the scene.
  49568. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49569. *
  49570. * Remarks: Can be either a texture or a url.
  49571. */
  49572. environmentTexture: string | BaseTexture;
  49573. /**
  49574. * The value of the exposure to apply to the scene.
  49575. * 0.6 by default if setupImageProcessing is true.
  49576. */
  49577. cameraExposure: number;
  49578. /**
  49579. * The value of the contrast to apply to the scene.
  49580. * 1.6 by default if setupImageProcessing is true.
  49581. */
  49582. cameraContrast: number;
  49583. /**
  49584. * Specifies whether or not tonemapping should be enabled in the scene.
  49585. * true by default if setupImageProcessing is true.
  49586. */
  49587. toneMappingEnabled: boolean;
  49588. }
  49589. /**
  49590. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49591. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49592. * It also helps with the default setup of your imageProcessing configuration.
  49593. */
  49594. export class EnvironmentHelper {
  49595. /**
  49596. * Default ground texture URL.
  49597. */
  49598. private static _groundTextureCDNUrl;
  49599. /**
  49600. * Default skybox texture URL.
  49601. */
  49602. private static _skyboxTextureCDNUrl;
  49603. /**
  49604. * Default environment texture URL.
  49605. */
  49606. private static _environmentTextureCDNUrl;
  49607. /**
  49608. * Creates the default options for the helper.
  49609. */
  49610. private static _getDefaultOptions;
  49611. private _rootMesh;
  49612. /**
  49613. * Gets the root mesh created by the helper.
  49614. */
  49615. get rootMesh(): Mesh;
  49616. private _skybox;
  49617. /**
  49618. * Gets the skybox created by the helper.
  49619. */
  49620. get skybox(): Nullable<Mesh>;
  49621. private _skyboxTexture;
  49622. /**
  49623. * Gets the skybox texture created by the helper.
  49624. */
  49625. get skyboxTexture(): Nullable<BaseTexture>;
  49626. private _skyboxMaterial;
  49627. /**
  49628. * Gets the skybox material created by the helper.
  49629. */
  49630. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49631. private _ground;
  49632. /**
  49633. * Gets the ground mesh created by the helper.
  49634. */
  49635. get ground(): Nullable<Mesh>;
  49636. private _groundTexture;
  49637. /**
  49638. * Gets the ground texture created by the helper.
  49639. */
  49640. get groundTexture(): Nullable<BaseTexture>;
  49641. private _groundMirror;
  49642. /**
  49643. * Gets the ground mirror created by the helper.
  49644. */
  49645. get groundMirror(): Nullable<MirrorTexture>;
  49646. /**
  49647. * Gets the ground mirror render list to helps pushing the meshes
  49648. * you wish in the ground reflection.
  49649. */
  49650. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49651. private _groundMaterial;
  49652. /**
  49653. * Gets the ground material created by the helper.
  49654. */
  49655. get groundMaterial(): Nullable<BackgroundMaterial>;
  49656. /**
  49657. * Stores the creation options.
  49658. */
  49659. private readonly _scene;
  49660. private _options;
  49661. /**
  49662. * This observable will be notified with any error during the creation of the environment,
  49663. * mainly texture creation errors.
  49664. */
  49665. onErrorObservable: Observable<{
  49666. message?: string;
  49667. exception?: any;
  49668. }>;
  49669. /**
  49670. * constructor
  49671. * @param options Defines the options we want to customize the helper
  49672. * @param scene The scene to add the material to
  49673. */
  49674. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49675. /**
  49676. * Updates the background according to the new options
  49677. * @param options
  49678. */
  49679. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49680. /**
  49681. * Sets the primary color of all the available elements.
  49682. * @param color the main color to affect to the ground and the background
  49683. */
  49684. setMainColor(color: Color3): void;
  49685. /**
  49686. * Setup the image processing according to the specified options.
  49687. */
  49688. private _setupImageProcessing;
  49689. /**
  49690. * Setup the environment texture according to the specified options.
  49691. */
  49692. private _setupEnvironmentTexture;
  49693. /**
  49694. * Setup the background according to the specified options.
  49695. */
  49696. private _setupBackground;
  49697. /**
  49698. * Get the scene sizes according to the setup.
  49699. */
  49700. private _getSceneSize;
  49701. /**
  49702. * Setup the ground according to the specified options.
  49703. */
  49704. private _setupGround;
  49705. /**
  49706. * Setup the ground material according to the specified options.
  49707. */
  49708. private _setupGroundMaterial;
  49709. /**
  49710. * Setup the ground diffuse texture according to the specified options.
  49711. */
  49712. private _setupGroundDiffuseTexture;
  49713. /**
  49714. * Setup the ground mirror texture according to the specified options.
  49715. */
  49716. private _setupGroundMirrorTexture;
  49717. /**
  49718. * Setup the ground to receive the mirror texture.
  49719. */
  49720. private _setupMirrorInGroundMaterial;
  49721. /**
  49722. * Setup the skybox according to the specified options.
  49723. */
  49724. private _setupSkybox;
  49725. /**
  49726. * Setup the skybox material according to the specified options.
  49727. */
  49728. private _setupSkyboxMaterial;
  49729. /**
  49730. * Setup the skybox reflection texture according to the specified options.
  49731. */
  49732. private _setupSkyboxReflectionTexture;
  49733. private _errorHandler;
  49734. /**
  49735. * Dispose all the elements created by the Helper.
  49736. */
  49737. dispose(): void;
  49738. }
  49739. }
  49740. declare module BABYLON {
  49741. /**
  49742. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49743. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49744. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49745. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49746. */
  49747. export class PhotoDome extends TransformNode {
  49748. /**
  49749. * Define the image as a Monoscopic panoramic 360 image.
  49750. */
  49751. static readonly MODE_MONOSCOPIC: number;
  49752. /**
  49753. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49754. */
  49755. static readonly MODE_TOPBOTTOM: number;
  49756. /**
  49757. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49758. */
  49759. static readonly MODE_SIDEBYSIDE: number;
  49760. private _useDirectMapping;
  49761. /**
  49762. * The texture being displayed on the sphere
  49763. */
  49764. protected _photoTexture: Texture;
  49765. /**
  49766. * Gets or sets the texture being displayed on the sphere
  49767. */
  49768. get photoTexture(): Texture;
  49769. set photoTexture(value: Texture);
  49770. /**
  49771. * Observable raised when an error occured while loading the 360 image
  49772. */
  49773. onLoadErrorObservable: Observable<string>;
  49774. /**
  49775. * The skybox material
  49776. */
  49777. protected _material: BackgroundMaterial;
  49778. /**
  49779. * The surface used for the skybox
  49780. */
  49781. protected _mesh: Mesh;
  49782. /**
  49783. * Gets the mesh used for the skybox.
  49784. */
  49785. get mesh(): Mesh;
  49786. /**
  49787. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49788. * Also see the options.resolution property.
  49789. */
  49790. get fovMultiplier(): number;
  49791. set fovMultiplier(value: number);
  49792. private _imageMode;
  49793. /**
  49794. * Gets or set the current video mode for the video. It can be:
  49795. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49796. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49797. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49798. */
  49799. get imageMode(): number;
  49800. set imageMode(value: number);
  49801. /**
  49802. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49803. * @param name Element's name, child elements will append suffixes for their own names.
  49804. * @param urlsOfPhoto defines the url of the photo to display
  49805. * @param options defines an object containing optional or exposed sub element properties
  49806. * @param onError defines a callback called when an error occured while loading the texture
  49807. */
  49808. constructor(name: string, urlOfPhoto: string, options: {
  49809. resolution?: number;
  49810. size?: number;
  49811. useDirectMapping?: boolean;
  49812. faceForward?: boolean;
  49813. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49814. private _onBeforeCameraRenderObserver;
  49815. private _changeImageMode;
  49816. /**
  49817. * Releases resources associated with this node.
  49818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49820. */
  49821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49822. }
  49823. }
  49824. declare module BABYLON {
  49825. /**
  49826. * Class used to host RGBD texture specific utilities
  49827. */
  49828. export class RGBDTextureTools {
  49829. /**
  49830. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49831. * @param texture the texture to expand.
  49832. */
  49833. static ExpandRGBDTexture(texture: Texture): void;
  49834. }
  49835. }
  49836. declare module BABYLON {
  49837. /**
  49838. * Class used to host texture specific utilities
  49839. */
  49840. export class BRDFTextureTools {
  49841. /**
  49842. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49843. * @param scene defines the hosting scene
  49844. * @returns the environment BRDF texture
  49845. */
  49846. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49847. private static _environmentBRDFBase64Texture;
  49848. }
  49849. }
  49850. declare module BABYLON {
  49851. /**
  49852. * @hidden
  49853. */
  49854. export interface IMaterialClearCoatDefines {
  49855. CLEARCOAT: boolean;
  49856. CLEARCOAT_DEFAULTIOR: boolean;
  49857. CLEARCOAT_TEXTURE: boolean;
  49858. CLEARCOAT_TEXTUREDIRECTUV: number;
  49859. CLEARCOAT_BUMP: boolean;
  49860. CLEARCOAT_BUMPDIRECTUV: number;
  49861. CLEARCOAT_TINT: boolean;
  49862. CLEARCOAT_TINT_TEXTURE: boolean;
  49863. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49864. /** @hidden */
  49865. _areTexturesDirty: boolean;
  49866. }
  49867. /**
  49868. * Define the code related to the clear coat parameters of the pbr material.
  49869. */
  49870. export class PBRClearCoatConfiguration {
  49871. /**
  49872. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49873. * The default fits with a polyurethane material.
  49874. */
  49875. private static readonly _DefaultIndexOfRefraction;
  49876. private _isEnabled;
  49877. /**
  49878. * Defines if the clear coat is enabled in the material.
  49879. */
  49880. isEnabled: boolean;
  49881. /**
  49882. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49883. */
  49884. intensity: number;
  49885. /**
  49886. * Defines the clear coat layer roughness.
  49887. */
  49888. roughness: number;
  49889. private _indexOfRefraction;
  49890. /**
  49891. * Defines the index of refraction of the clear coat.
  49892. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49893. * The default fits with a polyurethane material.
  49894. * Changing the default value is more performance intensive.
  49895. */
  49896. indexOfRefraction: number;
  49897. private _texture;
  49898. /**
  49899. * Stores the clear coat values in a texture.
  49900. */
  49901. texture: Nullable<BaseTexture>;
  49902. private _bumpTexture;
  49903. /**
  49904. * Define the clear coat specific bump texture.
  49905. */
  49906. bumpTexture: Nullable<BaseTexture>;
  49907. private _isTintEnabled;
  49908. /**
  49909. * Defines if the clear coat tint is enabled in the material.
  49910. */
  49911. isTintEnabled: boolean;
  49912. /**
  49913. * Defines the clear coat tint of the material.
  49914. * This is only use if tint is enabled
  49915. */
  49916. tintColor: Color3;
  49917. /**
  49918. * Defines the distance at which the tint color should be found in the
  49919. * clear coat media.
  49920. * This is only use if tint is enabled
  49921. */
  49922. tintColorAtDistance: number;
  49923. /**
  49924. * Defines the clear coat layer thickness.
  49925. * This is only use if tint is enabled
  49926. */
  49927. tintThickness: number;
  49928. private _tintTexture;
  49929. /**
  49930. * Stores the clear tint values in a texture.
  49931. * rgb is tint
  49932. * a is a thickness factor
  49933. */
  49934. tintTexture: Nullable<BaseTexture>;
  49935. /** @hidden */
  49936. private _internalMarkAllSubMeshesAsTexturesDirty;
  49937. /** @hidden */
  49938. _markAllSubMeshesAsTexturesDirty(): void;
  49939. /**
  49940. * Instantiate a new istance of clear coat configuration.
  49941. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49942. */
  49943. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49944. /**
  49945. * Gets wehter the submesh is ready to be used or not.
  49946. * @param defines the list of "defines" to update.
  49947. * @param scene defines the scene the material belongs to.
  49948. * @param engine defines the engine the material belongs to.
  49949. * @param disableBumpMap defines wether the material disables bump or not.
  49950. * @returns - boolean indicating that the submesh is ready or not.
  49951. */
  49952. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49953. /**
  49954. * Checks to see if a texture is used in the material.
  49955. * @param defines the list of "defines" to update.
  49956. * @param scene defines the scene to the material belongs to.
  49957. */
  49958. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49959. /**
  49960. * Binds the material data.
  49961. * @param uniformBuffer defines the Uniform buffer to fill in.
  49962. * @param scene defines the scene the material belongs to.
  49963. * @param engine defines the engine the material belongs to.
  49964. * @param disableBumpMap defines wether the material disables bump or not.
  49965. * @param isFrozen defines wether the material is frozen or not.
  49966. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49967. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49968. */
  49969. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49970. /**
  49971. * Checks to see if a texture is used in the material.
  49972. * @param texture - Base texture to use.
  49973. * @returns - Boolean specifying if a texture is used in the material.
  49974. */
  49975. hasTexture(texture: BaseTexture): boolean;
  49976. /**
  49977. * Returns an array of the actively used textures.
  49978. * @param activeTextures Array of BaseTextures
  49979. */
  49980. getActiveTextures(activeTextures: BaseTexture[]): void;
  49981. /**
  49982. * Returns the animatable textures.
  49983. * @param animatables Array of animatable textures.
  49984. */
  49985. getAnimatables(animatables: IAnimatable[]): void;
  49986. /**
  49987. * Disposes the resources of the material.
  49988. * @param forceDisposeTextures - Forces the disposal of all textures.
  49989. */
  49990. dispose(forceDisposeTextures?: boolean): void;
  49991. /**
  49992. * Get the current class name of the texture useful for serialization or dynamic coding.
  49993. * @returns "PBRClearCoatConfiguration"
  49994. */
  49995. getClassName(): string;
  49996. /**
  49997. * Add fallbacks to the effect fallbacks list.
  49998. * @param defines defines the Base texture to use.
  49999. * @param fallbacks defines the current fallback list.
  50000. * @param currentRank defines the current fallback rank.
  50001. * @returns the new fallback rank.
  50002. */
  50003. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50004. /**
  50005. * Add the required uniforms to the current list.
  50006. * @param uniforms defines the current uniform list.
  50007. */
  50008. static AddUniforms(uniforms: string[]): void;
  50009. /**
  50010. * Add the required samplers to the current list.
  50011. * @param samplers defines the current sampler list.
  50012. */
  50013. static AddSamplers(samplers: string[]): void;
  50014. /**
  50015. * Add the required uniforms to the current buffer.
  50016. * @param uniformBuffer defines the current uniform buffer.
  50017. */
  50018. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50019. /**
  50020. * Makes a duplicate of the current configuration into another one.
  50021. * @param clearCoatConfiguration define the config where to copy the info
  50022. */
  50023. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50024. /**
  50025. * Serializes this clear coat configuration.
  50026. * @returns - An object with the serialized config.
  50027. */
  50028. serialize(): any;
  50029. /**
  50030. * Parses a anisotropy Configuration from a serialized object.
  50031. * @param source - Serialized object.
  50032. * @param scene Defines the scene we are parsing for
  50033. * @param rootUrl Defines the rootUrl to load from
  50034. */
  50035. parse(source: any, scene: Scene, rootUrl: string): void;
  50036. }
  50037. }
  50038. declare module BABYLON {
  50039. /**
  50040. * @hidden
  50041. */
  50042. export interface IMaterialAnisotropicDefines {
  50043. ANISOTROPIC: boolean;
  50044. ANISOTROPIC_TEXTURE: boolean;
  50045. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50046. MAINUV1: boolean;
  50047. _areTexturesDirty: boolean;
  50048. _needUVs: boolean;
  50049. }
  50050. /**
  50051. * Define the code related to the anisotropic parameters of the pbr material.
  50052. */
  50053. export class PBRAnisotropicConfiguration {
  50054. private _isEnabled;
  50055. /**
  50056. * Defines if the anisotropy is enabled in the material.
  50057. */
  50058. isEnabled: boolean;
  50059. /**
  50060. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50061. */
  50062. intensity: number;
  50063. /**
  50064. * Defines if the effect is along the tangents, bitangents or in between.
  50065. * By default, the effect is "strectching" the highlights along the tangents.
  50066. */
  50067. direction: Vector2;
  50068. private _texture;
  50069. /**
  50070. * Stores the anisotropy values in a texture.
  50071. * rg is direction (like normal from -1 to 1)
  50072. * b is a intensity
  50073. */
  50074. texture: Nullable<BaseTexture>;
  50075. /** @hidden */
  50076. private _internalMarkAllSubMeshesAsTexturesDirty;
  50077. /** @hidden */
  50078. _markAllSubMeshesAsTexturesDirty(): void;
  50079. /**
  50080. * Instantiate a new istance of anisotropy configuration.
  50081. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50082. */
  50083. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50084. /**
  50085. * Specifies that the submesh is ready to be used.
  50086. * @param defines the list of "defines" to update.
  50087. * @param scene defines the scene the material belongs to.
  50088. * @returns - boolean indicating that the submesh is ready or not.
  50089. */
  50090. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50091. /**
  50092. * Checks to see if a texture is used in the material.
  50093. * @param defines the list of "defines" to update.
  50094. * @param mesh the mesh we are preparing the defines for.
  50095. * @param scene defines the scene the material belongs to.
  50096. */
  50097. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50098. /**
  50099. * Binds the material data.
  50100. * @param uniformBuffer defines the Uniform buffer to fill in.
  50101. * @param scene defines the scene the material belongs to.
  50102. * @param isFrozen defines wether the material is frozen or not.
  50103. */
  50104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50105. /**
  50106. * Checks to see if a texture is used in the material.
  50107. * @param texture - Base texture to use.
  50108. * @returns - Boolean specifying if a texture is used in the material.
  50109. */
  50110. hasTexture(texture: BaseTexture): boolean;
  50111. /**
  50112. * Returns an array of the actively used textures.
  50113. * @param activeTextures Array of BaseTextures
  50114. */
  50115. getActiveTextures(activeTextures: BaseTexture[]): void;
  50116. /**
  50117. * Returns the animatable textures.
  50118. * @param animatables Array of animatable textures.
  50119. */
  50120. getAnimatables(animatables: IAnimatable[]): void;
  50121. /**
  50122. * Disposes the resources of the material.
  50123. * @param forceDisposeTextures - Forces the disposal of all textures.
  50124. */
  50125. dispose(forceDisposeTextures?: boolean): void;
  50126. /**
  50127. * Get the current class name of the texture useful for serialization or dynamic coding.
  50128. * @returns "PBRAnisotropicConfiguration"
  50129. */
  50130. getClassName(): string;
  50131. /**
  50132. * Add fallbacks to the effect fallbacks list.
  50133. * @param defines defines the Base texture to use.
  50134. * @param fallbacks defines the current fallback list.
  50135. * @param currentRank defines the current fallback rank.
  50136. * @returns the new fallback rank.
  50137. */
  50138. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50139. /**
  50140. * Add the required uniforms to the current list.
  50141. * @param uniforms defines the current uniform list.
  50142. */
  50143. static AddUniforms(uniforms: string[]): void;
  50144. /**
  50145. * Add the required uniforms to the current buffer.
  50146. * @param uniformBuffer defines the current uniform buffer.
  50147. */
  50148. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50149. /**
  50150. * Add the required samplers to the current list.
  50151. * @param samplers defines the current sampler list.
  50152. */
  50153. static AddSamplers(samplers: string[]): void;
  50154. /**
  50155. * Makes a duplicate of the current configuration into another one.
  50156. * @param anisotropicConfiguration define the config where to copy the info
  50157. */
  50158. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50159. /**
  50160. * Serializes this anisotropy configuration.
  50161. * @returns - An object with the serialized config.
  50162. */
  50163. serialize(): any;
  50164. /**
  50165. * Parses a anisotropy Configuration from a serialized object.
  50166. * @param source - Serialized object.
  50167. * @param scene Defines the scene we are parsing for
  50168. * @param rootUrl Defines the rootUrl to load from
  50169. */
  50170. parse(source: any, scene: Scene, rootUrl: string): void;
  50171. }
  50172. }
  50173. declare module BABYLON {
  50174. /**
  50175. * @hidden
  50176. */
  50177. export interface IMaterialBRDFDefines {
  50178. BRDF_V_HEIGHT_CORRELATED: boolean;
  50179. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50180. SPHERICAL_HARMONICS: boolean;
  50181. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50182. /** @hidden */
  50183. _areMiscDirty: boolean;
  50184. }
  50185. /**
  50186. * Define the code related to the BRDF parameters of the pbr material.
  50187. */
  50188. export class PBRBRDFConfiguration {
  50189. /**
  50190. * Default value used for the energy conservation.
  50191. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50192. */
  50193. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50194. /**
  50195. * Default value used for the Smith Visibility Height Correlated mode.
  50196. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50197. */
  50198. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50199. /**
  50200. * Default value used for the IBL diffuse part.
  50201. * This can help switching back to the polynomials mode globally which is a tiny bit
  50202. * less GPU intensive at the drawback of a lower quality.
  50203. */
  50204. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50205. /**
  50206. * Default value used for activating energy conservation for the specular workflow.
  50207. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50208. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50209. */
  50210. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50211. private _useEnergyConservation;
  50212. /**
  50213. * Defines if the material uses energy conservation.
  50214. */
  50215. useEnergyConservation: boolean;
  50216. private _useSmithVisibilityHeightCorrelated;
  50217. /**
  50218. * LEGACY Mode set to false
  50219. * Defines if the material uses height smith correlated visibility term.
  50220. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50221. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50222. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50223. * Not relying on height correlated will also disable energy conservation.
  50224. */
  50225. useSmithVisibilityHeightCorrelated: boolean;
  50226. private _useSphericalHarmonics;
  50227. /**
  50228. * LEGACY Mode set to false
  50229. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50230. * diffuse part of the IBL.
  50231. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50232. * to the ground truth.
  50233. */
  50234. useSphericalHarmonics: boolean;
  50235. private _useSpecularGlossinessInputEnergyConservation;
  50236. /**
  50237. * Defines if the material uses energy conservation, when the specular workflow is active.
  50238. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50239. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50240. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50241. */
  50242. useSpecularGlossinessInputEnergyConservation: boolean;
  50243. /** @hidden */
  50244. private _internalMarkAllSubMeshesAsMiscDirty;
  50245. /** @hidden */
  50246. _markAllSubMeshesAsMiscDirty(): void;
  50247. /**
  50248. * Instantiate a new istance of clear coat configuration.
  50249. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50250. */
  50251. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50252. /**
  50253. * Checks to see if a texture is used in the material.
  50254. * @param defines the list of "defines" to update.
  50255. */
  50256. prepareDefines(defines: IMaterialBRDFDefines): void;
  50257. /**
  50258. * Get the current class name of the texture useful for serialization or dynamic coding.
  50259. * @returns "PBRClearCoatConfiguration"
  50260. */
  50261. getClassName(): string;
  50262. /**
  50263. * Makes a duplicate of the current configuration into another one.
  50264. * @param brdfConfiguration define the config where to copy the info
  50265. */
  50266. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50267. /**
  50268. * Serializes this BRDF configuration.
  50269. * @returns - An object with the serialized config.
  50270. */
  50271. serialize(): any;
  50272. /**
  50273. * Parses a anisotropy Configuration from a serialized object.
  50274. * @param source - Serialized object.
  50275. * @param scene Defines the scene we are parsing for
  50276. * @param rootUrl Defines the rootUrl to load from
  50277. */
  50278. parse(source: any, scene: Scene, rootUrl: string): void;
  50279. }
  50280. }
  50281. declare module BABYLON {
  50282. /**
  50283. * @hidden
  50284. */
  50285. export interface IMaterialSheenDefines {
  50286. SHEEN: boolean;
  50287. SHEEN_TEXTURE: boolean;
  50288. SHEEN_TEXTUREDIRECTUV: number;
  50289. SHEEN_LINKWITHALBEDO: boolean;
  50290. /** @hidden */
  50291. _areTexturesDirty: boolean;
  50292. }
  50293. /**
  50294. * Define the code related to the Sheen parameters of the pbr material.
  50295. */
  50296. export class PBRSheenConfiguration {
  50297. private _isEnabled;
  50298. /**
  50299. * Defines if the material uses sheen.
  50300. */
  50301. isEnabled: boolean;
  50302. private _linkSheenWithAlbedo;
  50303. /**
  50304. * Defines if the sheen is linked to the sheen color.
  50305. */
  50306. linkSheenWithAlbedo: boolean;
  50307. /**
  50308. * Defines the sheen intensity.
  50309. */
  50310. intensity: number;
  50311. /**
  50312. * Defines the sheen color.
  50313. */
  50314. color: Color3;
  50315. private _texture;
  50316. /**
  50317. * Stores the sheen tint values in a texture.
  50318. * rgb is tint
  50319. * a is a intensity
  50320. */
  50321. texture: Nullable<BaseTexture>;
  50322. /** @hidden */
  50323. private _internalMarkAllSubMeshesAsTexturesDirty;
  50324. /** @hidden */
  50325. _markAllSubMeshesAsTexturesDirty(): void;
  50326. /**
  50327. * Instantiate a new istance of clear coat configuration.
  50328. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50329. */
  50330. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50331. /**
  50332. * Specifies that the submesh is ready to be used.
  50333. * @param defines the list of "defines" to update.
  50334. * @param scene defines the scene the material belongs to.
  50335. * @returns - boolean indicating that the submesh is ready or not.
  50336. */
  50337. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50338. /**
  50339. * Checks to see if a texture is used in the material.
  50340. * @param defines the list of "defines" to update.
  50341. * @param scene defines the scene the material belongs to.
  50342. */
  50343. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50344. /**
  50345. * Binds the material data.
  50346. * @param uniformBuffer defines the Uniform buffer to fill in.
  50347. * @param scene defines the scene the material belongs to.
  50348. * @param isFrozen defines wether the material is frozen or not.
  50349. */
  50350. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50351. /**
  50352. * Checks to see if a texture is used in the material.
  50353. * @param texture - Base texture to use.
  50354. * @returns - Boolean specifying if a texture is used in the material.
  50355. */
  50356. hasTexture(texture: BaseTexture): boolean;
  50357. /**
  50358. * Returns an array of the actively used textures.
  50359. * @param activeTextures Array of BaseTextures
  50360. */
  50361. getActiveTextures(activeTextures: BaseTexture[]): void;
  50362. /**
  50363. * Returns the animatable textures.
  50364. * @param animatables Array of animatable textures.
  50365. */
  50366. getAnimatables(animatables: IAnimatable[]): void;
  50367. /**
  50368. * Disposes the resources of the material.
  50369. * @param forceDisposeTextures - Forces the disposal of all textures.
  50370. */
  50371. dispose(forceDisposeTextures?: boolean): void;
  50372. /**
  50373. * Get the current class name of the texture useful for serialization or dynamic coding.
  50374. * @returns "PBRSheenConfiguration"
  50375. */
  50376. getClassName(): string;
  50377. /**
  50378. * Add fallbacks to the effect fallbacks list.
  50379. * @param defines defines the Base texture to use.
  50380. * @param fallbacks defines the current fallback list.
  50381. * @param currentRank defines the current fallback rank.
  50382. * @returns the new fallback rank.
  50383. */
  50384. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50385. /**
  50386. * Add the required uniforms to the current list.
  50387. * @param uniforms defines the current uniform list.
  50388. */
  50389. static AddUniforms(uniforms: string[]): void;
  50390. /**
  50391. * Add the required uniforms to the current buffer.
  50392. * @param uniformBuffer defines the current uniform buffer.
  50393. */
  50394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50395. /**
  50396. * Add the required samplers to the current list.
  50397. * @param samplers defines the current sampler list.
  50398. */
  50399. static AddSamplers(samplers: string[]): void;
  50400. /**
  50401. * Makes a duplicate of the current configuration into another one.
  50402. * @param sheenConfiguration define the config where to copy the info
  50403. */
  50404. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50405. /**
  50406. * Serializes this BRDF configuration.
  50407. * @returns - An object with the serialized config.
  50408. */
  50409. serialize(): any;
  50410. /**
  50411. * Parses a anisotropy Configuration from a serialized object.
  50412. * @param source - Serialized object.
  50413. * @param scene Defines the scene we are parsing for
  50414. * @param rootUrl Defines the rootUrl to load from
  50415. */
  50416. parse(source: any, scene: Scene, rootUrl: string): void;
  50417. }
  50418. }
  50419. declare module BABYLON {
  50420. /**
  50421. * @hidden
  50422. */
  50423. export interface IMaterialSubSurfaceDefines {
  50424. SUBSURFACE: boolean;
  50425. SS_REFRACTION: boolean;
  50426. SS_TRANSLUCENCY: boolean;
  50427. SS_SCATERRING: boolean;
  50428. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50429. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50430. SS_REFRACTIONMAP_3D: boolean;
  50431. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50432. SS_LODINREFRACTIONALPHA: boolean;
  50433. SS_GAMMAREFRACTION: boolean;
  50434. SS_RGBDREFRACTION: boolean;
  50435. SS_LINEARSPECULARREFRACTION: boolean;
  50436. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50437. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50438. /** @hidden */
  50439. _areTexturesDirty: boolean;
  50440. }
  50441. /**
  50442. * Define the code related to the sub surface parameters of the pbr material.
  50443. */
  50444. export class PBRSubSurfaceConfiguration {
  50445. private _isRefractionEnabled;
  50446. /**
  50447. * Defines if the refraction is enabled in the material.
  50448. */
  50449. isRefractionEnabled: boolean;
  50450. private _isTranslucencyEnabled;
  50451. /**
  50452. * Defines if the translucency is enabled in the material.
  50453. */
  50454. isTranslucencyEnabled: boolean;
  50455. private _isScatteringEnabled;
  50456. /**
  50457. * Defines the refraction intensity of the material.
  50458. * The refraction when enabled replaces the Diffuse part of the material.
  50459. * The intensity helps transitionning between diffuse and refraction.
  50460. */
  50461. refractionIntensity: number;
  50462. /**
  50463. * Defines the translucency intensity of the material.
  50464. * When translucency has been enabled, this defines how much of the "translucency"
  50465. * is addded to the diffuse part of the material.
  50466. */
  50467. translucencyIntensity: number;
  50468. /**
  50469. * Defines the scattering intensity of the material.
  50470. * When scattering has been enabled, this defines how much of the "scattered light"
  50471. * is addded to the diffuse part of the material.
  50472. */
  50473. scatteringIntensity: number;
  50474. private _thicknessTexture;
  50475. /**
  50476. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50477. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50478. * 0 would mean minimumThickness
  50479. * 1 would mean maximumThickness
  50480. * The other channels might be use as a mask to vary the different effects intensity.
  50481. */
  50482. thicknessTexture: Nullable<BaseTexture>;
  50483. private _refractionTexture;
  50484. /**
  50485. * Defines the texture to use for refraction.
  50486. */
  50487. refractionTexture: Nullable<BaseTexture>;
  50488. private _indexOfRefraction;
  50489. /**
  50490. * Defines the index of refraction used in the material.
  50491. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50492. */
  50493. indexOfRefraction: number;
  50494. private _invertRefractionY;
  50495. /**
  50496. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50497. */
  50498. invertRefractionY: boolean;
  50499. private _linkRefractionWithTransparency;
  50500. /**
  50501. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50502. * Materials half opaque for instance using refraction could benefit from this control.
  50503. */
  50504. linkRefractionWithTransparency: boolean;
  50505. /**
  50506. * Defines the minimum thickness stored in the thickness map.
  50507. * If no thickness map is defined, this value will be used to simulate thickness.
  50508. */
  50509. minimumThickness: number;
  50510. /**
  50511. * Defines the maximum thickness stored in the thickness map.
  50512. */
  50513. maximumThickness: number;
  50514. /**
  50515. * Defines the volume tint of the material.
  50516. * This is used for both translucency and scattering.
  50517. */
  50518. tintColor: Color3;
  50519. /**
  50520. * Defines the distance at which the tint color should be found in the media.
  50521. * This is used for refraction only.
  50522. */
  50523. tintColorAtDistance: number;
  50524. /**
  50525. * Defines how far each channel transmit through the media.
  50526. * It is defined as a color to simplify it selection.
  50527. */
  50528. diffusionDistance: Color3;
  50529. private _useMaskFromThicknessTexture;
  50530. /**
  50531. * Stores the intensity of the different subsurface effects in the thickness texture.
  50532. * * the green channel is the translucency intensity.
  50533. * * the blue channel is the scattering intensity.
  50534. * * the alpha channel is the refraction intensity.
  50535. */
  50536. useMaskFromThicknessTexture: boolean;
  50537. /** @hidden */
  50538. private _internalMarkAllSubMeshesAsTexturesDirty;
  50539. /** @hidden */
  50540. _markAllSubMeshesAsTexturesDirty(): void;
  50541. /**
  50542. * Instantiate a new istance of sub surface configuration.
  50543. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50544. */
  50545. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50546. /**
  50547. * Gets wehter the submesh is ready to be used or not.
  50548. * @param defines the list of "defines" to update.
  50549. * @param scene defines the scene the material belongs to.
  50550. * @returns - boolean indicating that the submesh is ready or not.
  50551. */
  50552. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50553. /**
  50554. * Checks to see if a texture is used in the material.
  50555. * @param defines the list of "defines" to update.
  50556. * @param scene defines the scene to the material belongs to.
  50557. */
  50558. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50559. /**
  50560. * Binds the material data.
  50561. * @param uniformBuffer defines the Uniform buffer to fill in.
  50562. * @param scene defines the scene the material belongs to.
  50563. * @param engine defines the engine the material belongs to.
  50564. * @param isFrozen defines wether the material is frozen or not.
  50565. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50566. */
  50567. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50568. /**
  50569. * Unbinds the material from the mesh.
  50570. * @param activeEffect defines the effect that should be unbound from.
  50571. * @returns true if unbound, otherwise false
  50572. */
  50573. unbind(activeEffect: Effect): boolean;
  50574. /**
  50575. * Returns the texture used for refraction or null if none is used.
  50576. * @param scene defines the scene the material belongs to.
  50577. * @returns - Refraction texture if present. If no refraction texture and refraction
  50578. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50579. */
  50580. private _getRefractionTexture;
  50581. /**
  50582. * Returns true if alpha blending should be disabled.
  50583. */
  50584. get disableAlphaBlending(): boolean;
  50585. /**
  50586. * Fills the list of render target textures.
  50587. * @param renderTargets the list of render targets to update
  50588. */
  50589. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50590. /**
  50591. * Checks to see if a texture is used in the material.
  50592. * @param texture - Base texture to use.
  50593. * @returns - Boolean specifying if a texture is used in the material.
  50594. */
  50595. hasTexture(texture: BaseTexture): boolean;
  50596. /**
  50597. * Gets a boolean indicating that current material needs to register RTT
  50598. * @returns true if this uses a render target otherwise false.
  50599. */
  50600. hasRenderTargetTextures(): boolean;
  50601. /**
  50602. * Returns an array of the actively used textures.
  50603. * @param activeTextures Array of BaseTextures
  50604. */
  50605. getActiveTextures(activeTextures: BaseTexture[]): void;
  50606. /**
  50607. * Returns the animatable textures.
  50608. * @param animatables Array of animatable textures.
  50609. */
  50610. getAnimatables(animatables: IAnimatable[]): void;
  50611. /**
  50612. * Disposes the resources of the material.
  50613. * @param forceDisposeTextures - Forces the disposal of all textures.
  50614. */
  50615. dispose(forceDisposeTextures?: boolean): void;
  50616. /**
  50617. * Get the current class name of the texture useful for serialization or dynamic coding.
  50618. * @returns "PBRSubSurfaceConfiguration"
  50619. */
  50620. getClassName(): string;
  50621. /**
  50622. * Add fallbacks to the effect fallbacks list.
  50623. * @param defines defines the Base texture to use.
  50624. * @param fallbacks defines the current fallback list.
  50625. * @param currentRank defines the current fallback rank.
  50626. * @returns the new fallback rank.
  50627. */
  50628. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50629. /**
  50630. * Add the required uniforms to the current list.
  50631. * @param uniforms defines the current uniform list.
  50632. */
  50633. static AddUniforms(uniforms: string[]): void;
  50634. /**
  50635. * Add the required samplers to the current list.
  50636. * @param samplers defines the current sampler list.
  50637. */
  50638. static AddSamplers(samplers: string[]): void;
  50639. /**
  50640. * Add the required uniforms to the current buffer.
  50641. * @param uniformBuffer defines the current uniform buffer.
  50642. */
  50643. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50644. /**
  50645. * Makes a duplicate of the current configuration into another one.
  50646. * @param configuration define the config where to copy the info
  50647. */
  50648. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50649. /**
  50650. * Serializes this Sub Surface configuration.
  50651. * @returns - An object with the serialized config.
  50652. */
  50653. serialize(): any;
  50654. /**
  50655. * Parses a anisotropy Configuration from a serialized object.
  50656. * @param source - Serialized object.
  50657. * @param scene Defines the scene we are parsing for
  50658. * @param rootUrl Defines the rootUrl to load from
  50659. */
  50660. parse(source: any, scene: Scene, rootUrl: string): void;
  50661. }
  50662. }
  50663. declare module BABYLON {
  50664. /** @hidden */
  50665. export var pbrFragmentDeclaration: {
  50666. name: string;
  50667. shader: string;
  50668. };
  50669. }
  50670. declare module BABYLON {
  50671. /** @hidden */
  50672. export var pbrUboDeclaration: {
  50673. name: string;
  50674. shader: string;
  50675. };
  50676. }
  50677. declare module BABYLON {
  50678. /** @hidden */
  50679. export var pbrFragmentExtraDeclaration: {
  50680. name: string;
  50681. shader: string;
  50682. };
  50683. }
  50684. declare module BABYLON {
  50685. /** @hidden */
  50686. export var pbrFragmentSamplersDeclaration: {
  50687. name: string;
  50688. shader: string;
  50689. };
  50690. }
  50691. declare module BABYLON {
  50692. /** @hidden */
  50693. export var pbrHelperFunctions: {
  50694. name: string;
  50695. shader: string;
  50696. };
  50697. }
  50698. declare module BABYLON {
  50699. /** @hidden */
  50700. export var harmonicsFunctions: {
  50701. name: string;
  50702. shader: string;
  50703. };
  50704. }
  50705. declare module BABYLON {
  50706. /** @hidden */
  50707. export var pbrDirectLightingSetupFunctions: {
  50708. name: string;
  50709. shader: string;
  50710. };
  50711. }
  50712. declare module BABYLON {
  50713. /** @hidden */
  50714. export var pbrDirectLightingFalloffFunctions: {
  50715. name: string;
  50716. shader: string;
  50717. };
  50718. }
  50719. declare module BABYLON {
  50720. /** @hidden */
  50721. export var pbrBRDFFunctions: {
  50722. name: string;
  50723. shader: string;
  50724. };
  50725. }
  50726. declare module BABYLON {
  50727. /** @hidden */
  50728. export var pbrDirectLightingFunctions: {
  50729. name: string;
  50730. shader: string;
  50731. };
  50732. }
  50733. declare module BABYLON {
  50734. /** @hidden */
  50735. export var pbrIBLFunctions: {
  50736. name: string;
  50737. shader: string;
  50738. };
  50739. }
  50740. declare module BABYLON {
  50741. /** @hidden */
  50742. export var pbrDebug: {
  50743. name: string;
  50744. shader: string;
  50745. };
  50746. }
  50747. declare module BABYLON {
  50748. /** @hidden */
  50749. export var pbrPixelShader: {
  50750. name: string;
  50751. shader: string;
  50752. };
  50753. }
  50754. declare module BABYLON {
  50755. /** @hidden */
  50756. export var pbrVertexDeclaration: {
  50757. name: string;
  50758. shader: string;
  50759. };
  50760. }
  50761. declare module BABYLON {
  50762. /** @hidden */
  50763. export var pbrVertexShader: {
  50764. name: string;
  50765. shader: string;
  50766. };
  50767. }
  50768. declare module BABYLON {
  50769. /**
  50770. * Manages the defines for the PBR Material.
  50771. * @hidden
  50772. */
  50773. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50774. PBR: boolean;
  50775. MAINUV1: boolean;
  50776. MAINUV2: boolean;
  50777. UV1: boolean;
  50778. UV2: boolean;
  50779. ALBEDO: boolean;
  50780. GAMMAALBEDO: boolean;
  50781. ALBEDODIRECTUV: number;
  50782. VERTEXCOLOR: boolean;
  50783. AMBIENT: boolean;
  50784. AMBIENTDIRECTUV: number;
  50785. AMBIENTINGRAYSCALE: boolean;
  50786. OPACITY: boolean;
  50787. VERTEXALPHA: boolean;
  50788. OPACITYDIRECTUV: number;
  50789. OPACITYRGB: boolean;
  50790. ALPHATEST: boolean;
  50791. DEPTHPREPASS: boolean;
  50792. ALPHABLEND: boolean;
  50793. ALPHAFROMALBEDO: boolean;
  50794. ALPHATESTVALUE: string;
  50795. SPECULAROVERALPHA: boolean;
  50796. RADIANCEOVERALPHA: boolean;
  50797. ALPHAFRESNEL: boolean;
  50798. LINEARALPHAFRESNEL: boolean;
  50799. PREMULTIPLYALPHA: boolean;
  50800. EMISSIVE: boolean;
  50801. EMISSIVEDIRECTUV: number;
  50802. REFLECTIVITY: boolean;
  50803. REFLECTIVITYDIRECTUV: number;
  50804. SPECULARTERM: boolean;
  50805. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50806. MICROSURFACEAUTOMATIC: boolean;
  50807. LODBASEDMICROSFURACE: boolean;
  50808. MICROSURFACEMAP: boolean;
  50809. MICROSURFACEMAPDIRECTUV: number;
  50810. METALLICWORKFLOW: boolean;
  50811. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50812. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50813. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50814. AOSTOREINMETALMAPRED: boolean;
  50815. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50816. ENVIRONMENTBRDF: boolean;
  50817. ENVIRONMENTBRDF_RGBD: boolean;
  50818. NORMAL: boolean;
  50819. TANGENT: boolean;
  50820. BUMP: boolean;
  50821. BUMPDIRECTUV: number;
  50822. OBJECTSPACE_NORMALMAP: boolean;
  50823. PARALLAX: boolean;
  50824. PARALLAXOCCLUSION: boolean;
  50825. NORMALXYSCALE: boolean;
  50826. LIGHTMAP: boolean;
  50827. LIGHTMAPDIRECTUV: number;
  50828. USELIGHTMAPASSHADOWMAP: boolean;
  50829. GAMMALIGHTMAP: boolean;
  50830. RGBDLIGHTMAP: boolean;
  50831. REFLECTION: boolean;
  50832. REFLECTIONMAP_3D: boolean;
  50833. REFLECTIONMAP_SPHERICAL: boolean;
  50834. REFLECTIONMAP_PLANAR: boolean;
  50835. REFLECTIONMAP_CUBIC: boolean;
  50836. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50837. REFLECTIONMAP_PROJECTION: boolean;
  50838. REFLECTIONMAP_SKYBOX: boolean;
  50839. REFLECTIONMAP_EXPLICIT: boolean;
  50840. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50841. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50842. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50843. INVERTCUBICMAP: boolean;
  50844. USESPHERICALFROMREFLECTIONMAP: boolean;
  50845. USEIRRADIANCEMAP: boolean;
  50846. SPHERICAL_HARMONICS: boolean;
  50847. USESPHERICALINVERTEX: boolean;
  50848. REFLECTIONMAP_OPPOSITEZ: boolean;
  50849. LODINREFLECTIONALPHA: boolean;
  50850. GAMMAREFLECTION: boolean;
  50851. RGBDREFLECTION: boolean;
  50852. LINEARSPECULARREFLECTION: boolean;
  50853. RADIANCEOCCLUSION: boolean;
  50854. HORIZONOCCLUSION: boolean;
  50855. INSTANCES: boolean;
  50856. NUM_BONE_INFLUENCERS: number;
  50857. BonesPerMesh: number;
  50858. BONETEXTURE: boolean;
  50859. NONUNIFORMSCALING: boolean;
  50860. MORPHTARGETS: boolean;
  50861. MORPHTARGETS_NORMAL: boolean;
  50862. MORPHTARGETS_TANGENT: boolean;
  50863. MORPHTARGETS_UV: boolean;
  50864. NUM_MORPH_INFLUENCERS: number;
  50865. IMAGEPROCESSING: boolean;
  50866. VIGNETTE: boolean;
  50867. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50868. VIGNETTEBLENDMODEOPAQUE: boolean;
  50869. TONEMAPPING: boolean;
  50870. TONEMAPPING_ACES: boolean;
  50871. CONTRAST: boolean;
  50872. COLORCURVES: boolean;
  50873. COLORGRADING: boolean;
  50874. COLORGRADING3D: boolean;
  50875. SAMPLER3DGREENDEPTH: boolean;
  50876. SAMPLER3DBGRMAP: boolean;
  50877. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50878. EXPOSURE: boolean;
  50879. MULTIVIEW: boolean;
  50880. USEPHYSICALLIGHTFALLOFF: boolean;
  50881. USEGLTFLIGHTFALLOFF: boolean;
  50882. TWOSIDEDLIGHTING: boolean;
  50883. SHADOWFLOAT: boolean;
  50884. CLIPPLANE: boolean;
  50885. CLIPPLANE2: boolean;
  50886. CLIPPLANE3: boolean;
  50887. CLIPPLANE4: boolean;
  50888. CLIPPLANE5: boolean;
  50889. CLIPPLANE6: boolean;
  50890. POINTSIZE: boolean;
  50891. FOG: boolean;
  50892. LOGARITHMICDEPTH: boolean;
  50893. FORCENORMALFORWARD: boolean;
  50894. SPECULARAA: boolean;
  50895. CLEARCOAT: boolean;
  50896. CLEARCOAT_DEFAULTIOR: boolean;
  50897. CLEARCOAT_TEXTURE: boolean;
  50898. CLEARCOAT_TEXTUREDIRECTUV: number;
  50899. CLEARCOAT_BUMP: boolean;
  50900. CLEARCOAT_BUMPDIRECTUV: number;
  50901. CLEARCOAT_TINT: boolean;
  50902. CLEARCOAT_TINT_TEXTURE: boolean;
  50903. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50904. ANISOTROPIC: boolean;
  50905. ANISOTROPIC_TEXTURE: boolean;
  50906. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50907. BRDF_V_HEIGHT_CORRELATED: boolean;
  50908. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50909. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50910. SHEEN: boolean;
  50911. SHEEN_TEXTURE: boolean;
  50912. SHEEN_TEXTUREDIRECTUV: number;
  50913. SHEEN_LINKWITHALBEDO: boolean;
  50914. SUBSURFACE: boolean;
  50915. SS_REFRACTION: boolean;
  50916. SS_TRANSLUCENCY: boolean;
  50917. SS_SCATERRING: boolean;
  50918. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50919. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50920. SS_REFRACTIONMAP_3D: boolean;
  50921. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50922. SS_LODINREFRACTIONALPHA: boolean;
  50923. SS_GAMMAREFRACTION: boolean;
  50924. SS_RGBDREFRACTION: boolean;
  50925. SS_LINEARSPECULARREFRACTION: boolean;
  50926. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50927. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50928. UNLIT: boolean;
  50929. DEBUGMODE: number;
  50930. /**
  50931. * Initializes the PBR Material defines.
  50932. */
  50933. constructor();
  50934. /**
  50935. * Resets the PBR Material defines.
  50936. */
  50937. reset(): void;
  50938. }
  50939. /**
  50940. * The Physically based material base class of BJS.
  50941. *
  50942. * This offers the main features of a standard PBR material.
  50943. * For more information, please refer to the documentation :
  50944. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50945. */
  50946. export abstract class PBRBaseMaterial extends PushMaterial {
  50947. /**
  50948. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50949. */
  50950. static readonly PBRMATERIAL_OPAQUE: number;
  50951. /**
  50952. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50953. */
  50954. static readonly PBRMATERIAL_ALPHATEST: number;
  50955. /**
  50956. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50957. */
  50958. static readonly PBRMATERIAL_ALPHABLEND: number;
  50959. /**
  50960. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50961. * They are also discarded below the alpha cutoff threshold to improve performances.
  50962. */
  50963. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50964. /**
  50965. * Defines the default value of how much AO map is occluding the analytical lights
  50966. * (point spot...).
  50967. */
  50968. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50969. /**
  50970. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50971. */
  50972. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50973. /**
  50974. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50975. * to enhance interoperability with other engines.
  50976. */
  50977. static readonly LIGHTFALLOFF_GLTF: number;
  50978. /**
  50979. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50980. * to enhance interoperability with other materials.
  50981. */
  50982. static readonly LIGHTFALLOFF_STANDARD: number;
  50983. /**
  50984. * Intensity of the direct lights e.g. the four lights available in your scene.
  50985. * This impacts both the direct diffuse and specular highlights.
  50986. */
  50987. protected _directIntensity: number;
  50988. /**
  50989. * Intensity of the emissive part of the material.
  50990. * This helps controlling the emissive effect without modifying the emissive color.
  50991. */
  50992. protected _emissiveIntensity: number;
  50993. /**
  50994. * Intensity of the environment e.g. how much the environment will light the object
  50995. * either through harmonics for rough material or through the refelction for shiny ones.
  50996. */
  50997. protected _environmentIntensity: number;
  50998. /**
  50999. * This is a special control allowing the reduction of the specular highlights coming from the
  51000. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51001. */
  51002. protected _specularIntensity: number;
  51003. /**
  51004. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51005. */
  51006. private _lightingInfos;
  51007. /**
  51008. * Debug Control allowing disabling the bump map on this material.
  51009. */
  51010. protected _disableBumpMap: boolean;
  51011. /**
  51012. * AKA Diffuse Texture in standard nomenclature.
  51013. */
  51014. protected _albedoTexture: Nullable<BaseTexture>;
  51015. /**
  51016. * AKA Occlusion Texture in other nomenclature.
  51017. */
  51018. protected _ambientTexture: Nullable<BaseTexture>;
  51019. /**
  51020. * AKA Occlusion Texture Intensity in other nomenclature.
  51021. */
  51022. protected _ambientTextureStrength: number;
  51023. /**
  51024. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51025. * 1 means it completely occludes it
  51026. * 0 mean it has no impact
  51027. */
  51028. protected _ambientTextureImpactOnAnalyticalLights: number;
  51029. /**
  51030. * Stores the alpha values in a texture.
  51031. */
  51032. protected _opacityTexture: Nullable<BaseTexture>;
  51033. /**
  51034. * Stores the reflection values in a texture.
  51035. */
  51036. protected _reflectionTexture: Nullable<BaseTexture>;
  51037. /**
  51038. * Stores the emissive values in a texture.
  51039. */
  51040. protected _emissiveTexture: Nullable<BaseTexture>;
  51041. /**
  51042. * AKA Specular texture in other nomenclature.
  51043. */
  51044. protected _reflectivityTexture: Nullable<BaseTexture>;
  51045. /**
  51046. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51047. */
  51048. protected _metallicTexture: Nullable<BaseTexture>;
  51049. /**
  51050. * Specifies the metallic scalar of the metallic/roughness workflow.
  51051. * Can also be used to scale the metalness values of the metallic texture.
  51052. */
  51053. protected _metallic: Nullable<number>;
  51054. /**
  51055. * Specifies the roughness scalar of the metallic/roughness workflow.
  51056. * Can also be used to scale the roughness values of the metallic texture.
  51057. */
  51058. protected _roughness: Nullable<number>;
  51059. /**
  51060. * Specifies the an F0 factor to help configuring the material F0.
  51061. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51062. * to 0.5 the previously hard coded value stays the same.
  51063. * Can also be used to scale the F0 values of the metallic texture.
  51064. */
  51065. protected _metallicF0Factor: number;
  51066. /**
  51067. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51068. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51069. * your expectation as it multiplies with the texture data.
  51070. */
  51071. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51072. /**
  51073. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51074. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51075. */
  51076. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51077. /**
  51078. * Stores surface normal data used to displace a mesh in a texture.
  51079. */
  51080. protected _bumpTexture: Nullable<BaseTexture>;
  51081. /**
  51082. * Stores the pre-calculated light information of a mesh in a texture.
  51083. */
  51084. protected _lightmapTexture: Nullable<BaseTexture>;
  51085. /**
  51086. * The color of a material in ambient lighting.
  51087. */
  51088. protected _ambientColor: Color3;
  51089. /**
  51090. * AKA Diffuse Color in other nomenclature.
  51091. */
  51092. protected _albedoColor: Color3;
  51093. /**
  51094. * AKA Specular Color in other nomenclature.
  51095. */
  51096. protected _reflectivityColor: Color3;
  51097. /**
  51098. * The color applied when light is reflected from a material.
  51099. */
  51100. protected _reflectionColor: Color3;
  51101. /**
  51102. * The color applied when light is emitted from a material.
  51103. */
  51104. protected _emissiveColor: Color3;
  51105. /**
  51106. * AKA Glossiness in other nomenclature.
  51107. */
  51108. protected _microSurface: number;
  51109. /**
  51110. * Specifies that the material will use the light map as a show map.
  51111. */
  51112. protected _useLightmapAsShadowmap: boolean;
  51113. /**
  51114. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51115. * makes the reflect vector face the model (under horizon).
  51116. */
  51117. protected _useHorizonOcclusion: boolean;
  51118. /**
  51119. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51120. * too much the area relying on ambient texture to define their ambient occlusion.
  51121. */
  51122. protected _useRadianceOcclusion: boolean;
  51123. /**
  51124. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51125. */
  51126. protected _useAlphaFromAlbedoTexture: boolean;
  51127. /**
  51128. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51129. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51130. */
  51131. protected _useSpecularOverAlpha: boolean;
  51132. /**
  51133. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51134. */
  51135. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51136. /**
  51137. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51138. */
  51139. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51140. /**
  51141. * Specifies if the metallic texture contains the roughness information in its green channel.
  51142. */
  51143. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51144. /**
  51145. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51146. */
  51147. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51148. /**
  51149. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51150. */
  51151. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51152. /**
  51153. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51154. */
  51155. protected _useAmbientInGrayScale: boolean;
  51156. /**
  51157. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51158. * The material will try to infer what glossiness each pixel should be.
  51159. */
  51160. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51161. /**
  51162. * Defines the falloff type used in this material.
  51163. * It by default is Physical.
  51164. */
  51165. protected _lightFalloff: number;
  51166. /**
  51167. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51168. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51169. */
  51170. protected _useRadianceOverAlpha: boolean;
  51171. /**
  51172. * Allows using an object space normal map (instead of tangent space).
  51173. */
  51174. protected _useObjectSpaceNormalMap: boolean;
  51175. /**
  51176. * Allows using the bump map in parallax mode.
  51177. */
  51178. protected _useParallax: boolean;
  51179. /**
  51180. * Allows using the bump map in parallax occlusion mode.
  51181. */
  51182. protected _useParallaxOcclusion: boolean;
  51183. /**
  51184. * Controls the scale bias of the parallax mode.
  51185. */
  51186. protected _parallaxScaleBias: number;
  51187. /**
  51188. * If sets to true, disables all the lights affecting the material.
  51189. */
  51190. protected _disableLighting: boolean;
  51191. /**
  51192. * Number of Simultaneous lights allowed on the material.
  51193. */
  51194. protected _maxSimultaneousLights: number;
  51195. /**
  51196. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51197. */
  51198. protected _invertNormalMapX: boolean;
  51199. /**
  51200. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51201. */
  51202. protected _invertNormalMapY: boolean;
  51203. /**
  51204. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51205. */
  51206. protected _twoSidedLighting: boolean;
  51207. /**
  51208. * Defines the alpha limits in alpha test mode.
  51209. */
  51210. protected _alphaCutOff: number;
  51211. /**
  51212. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51213. */
  51214. protected _forceAlphaTest: boolean;
  51215. /**
  51216. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51217. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51218. */
  51219. protected _useAlphaFresnel: boolean;
  51220. /**
  51221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51222. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51223. */
  51224. protected _useLinearAlphaFresnel: boolean;
  51225. /**
  51226. * The transparency mode of the material.
  51227. */
  51228. protected _transparencyMode: Nullable<number>;
  51229. /**
  51230. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51231. * from cos thetav and roughness:
  51232. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51233. */
  51234. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51235. /**
  51236. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51237. */
  51238. protected _forceIrradianceInFragment: boolean;
  51239. /**
  51240. * Force normal to face away from face.
  51241. */
  51242. protected _forceNormalForward: boolean;
  51243. /**
  51244. * Enables specular anti aliasing in the PBR shader.
  51245. * It will both interacts on the Geometry for analytical and IBL lighting.
  51246. * It also prefilter the roughness map based on the bump values.
  51247. */
  51248. protected _enableSpecularAntiAliasing: boolean;
  51249. /**
  51250. * Default configuration related to image processing available in the PBR Material.
  51251. */
  51252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51253. /**
  51254. * Keep track of the image processing observer to allow dispose and replace.
  51255. */
  51256. private _imageProcessingObserver;
  51257. /**
  51258. * Attaches a new image processing configuration to the PBR Material.
  51259. * @param configuration
  51260. */
  51261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51262. /**
  51263. * Stores the available render targets.
  51264. */
  51265. private _renderTargets;
  51266. /**
  51267. * Sets the global ambient color for the material used in lighting calculations.
  51268. */
  51269. private _globalAmbientColor;
  51270. /**
  51271. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51272. */
  51273. private _useLogarithmicDepth;
  51274. /**
  51275. * If set to true, no lighting calculations will be applied.
  51276. */
  51277. private _unlit;
  51278. private _debugMode;
  51279. /**
  51280. * @hidden
  51281. * This is reserved for the inspector.
  51282. * Defines the material debug mode.
  51283. * It helps seeing only some components of the material while troubleshooting.
  51284. */
  51285. debugMode: number;
  51286. /**
  51287. * @hidden
  51288. * This is reserved for the inspector.
  51289. * Specify from where on screen the debug mode should start.
  51290. * The value goes from -1 (full screen) to 1 (not visible)
  51291. * It helps with side by side comparison against the final render
  51292. * This defaults to -1
  51293. */
  51294. private debugLimit;
  51295. /**
  51296. * @hidden
  51297. * This is reserved for the inspector.
  51298. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51299. * You can use the factor to better multiply the final value.
  51300. */
  51301. private debugFactor;
  51302. /**
  51303. * Defines the clear coat layer parameters for the material.
  51304. */
  51305. readonly clearCoat: PBRClearCoatConfiguration;
  51306. /**
  51307. * Defines the anisotropic parameters for the material.
  51308. */
  51309. readonly anisotropy: PBRAnisotropicConfiguration;
  51310. /**
  51311. * Defines the BRDF parameters for the material.
  51312. */
  51313. readonly brdf: PBRBRDFConfiguration;
  51314. /**
  51315. * Defines the Sheen parameters for the material.
  51316. */
  51317. readonly sheen: PBRSheenConfiguration;
  51318. /**
  51319. * Defines the SubSurface parameters for the material.
  51320. */
  51321. readonly subSurface: PBRSubSurfaceConfiguration;
  51322. /**
  51323. * Custom callback helping to override the default shader used in the material.
  51324. */
  51325. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51326. protected _rebuildInParallel: boolean;
  51327. /**
  51328. * Instantiates a new PBRMaterial instance.
  51329. *
  51330. * @param name The material name
  51331. * @param scene The scene the material will be use in.
  51332. */
  51333. constructor(name: string, scene: Scene);
  51334. /**
  51335. * Gets a boolean indicating that current material needs to register RTT
  51336. */
  51337. get hasRenderTargetTextures(): boolean;
  51338. /**
  51339. * Gets the name of the material class.
  51340. */
  51341. getClassName(): string;
  51342. /**
  51343. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51344. */
  51345. get useLogarithmicDepth(): boolean;
  51346. /**
  51347. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51348. */
  51349. set useLogarithmicDepth(value: boolean);
  51350. /**
  51351. * Gets the current transparency mode.
  51352. */
  51353. get transparencyMode(): Nullable<number>;
  51354. /**
  51355. * Sets the transparency mode of the material.
  51356. *
  51357. * | Value | Type | Description |
  51358. * | ----- | ----------------------------------- | ----------- |
  51359. * | 0 | OPAQUE | |
  51360. * | 1 | ALPHATEST | |
  51361. * | 2 | ALPHABLEND | |
  51362. * | 3 | ALPHATESTANDBLEND | |
  51363. *
  51364. */
  51365. set transparencyMode(value: Nullable<number>);
  51366. /**
  51367. * Returns true if alpha blending should be disabled.
  51368. */
  51369. private get _disableAlphaBlending();
  51370. /**
  51371. * Specifies whether or not this material should be rendered in alpha blend mode.
  51372. */
  51373. needAlphaBlending(): boolean;
  51374. /**
  51375. * Specifies if the mesh will require alpha blending.
  51376. * @param mesh - BJS mesh.
  51377. */
  51378. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51379. /**
  51380. * Specifies whether or not this material should be rendered in alpha test mode.
  51381. */
  51382. needAlphaTesting(): boolean;
  51383. /**
  51384. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51385. */
  51386. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51387. /**
  51388. * Gets the texture used for the alpha test.
  51389. */
  51390. getAlphaTestTexture(): Nullable<BaseTexture>;
  51391. /**
  51392. * Specifies that the submesh is ready to be used.
  51393. * @param mesh - BJS mesh.
  51394. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51395. * @param useInstances - Specifies that instances should be used.
  51396. * @returns - boolean indicating that the submesh is ready or not.
  51397. */
  51398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51399. /**
  51400. * Specifies if the material uses metallic roughness workflow.
  51401. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51402. */
  51403. isMetallicWorkflow(): boolean;
  51404. private _prepareEffect;
  51405. private _prepareDefines;
  51406. /**
  51407. * Force shader compilation
  51408. */
  51409. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51410. /**
  51411. * Initializes the uniform buffer layout for the shader.
  51412. */
  51413. buildUniformLayout(): void;
  51414. /**
  51415. * Unbinds the material from the mesh
  51416. */
  51417. unbind(): void;
  51418. /**
  51419. * Binds the submesh data.
  51420. * @param world - The world matrix.
  51421. * @param mesh - The BJS mesh.
  51422. * @param subMesh - A submesh of the BJS mesh.
  51423. */
  51424. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51425. /**
  51426. * Returns the animatable textures.
  51427. * @returns - Array of animatable textures.
  51428. */
  51429. getAnimatables(): IAnimatable[];
  51430. /**
  51431. * Returns the texture used for reflections.
  51432. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51433. */
  51434. private _getReflectionTexture;
  51435. /**
  51436. * Returns an array of the actively used textures.
  51437. * @returns - Array of BaseTextures
  51438. */
  51439. getActiveTextures(): BaseTexture[];
  51440. /**
  51441. * Checks to see if a texture is used in the material.
  51442. * @param texture - Base texture to use.
  51443. * @returns - Boolean specifying if a texture is used in the material.
  51444. */
  51445. hasTexture(texture: BaseTexture): boolean;
  51446. /**
  51447. * Disposes the resources of the material.
  51448. * @param forceDisposeEffect - Forces the disposal of effects.
  51449. * @param forceDisposeTextures - Forces the disposal of all textures.
  51450. */
  51451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51452. }
  51453. }
  51454. declare module BABYLON {
  51455. /**
  51456. * The Physically based material of BJS.
  51457. *
  51458. * This offers the main features of a standard PBR material.
  51459. * For more information, please refer to the documentation :
  51460. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51461. */
  51462. export class PBRMaterial extends PBRBaseMaterial {
  51463. /**
  51464. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51465. */
  51466. static readonly PBRMATERIAL_OPAQUE: number;
  51467. /**
  51468. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51469. */
  51470. static readonly PBRMATERIAL_ALPHATEST: number;
  51471. /**
  51472. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51473. */
  51474. static readonly PBRMATERIAL_ALPHABLEND: number;
  51475. /**
  51476. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51477. * They are also discarded below the alpha cutoff threshold to improve performances.
  51478. */
  51479. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51480. /**
  51481. * Defines the default value of how much AO map is occluding the analytical lights
  51482. * (point spot...).
  51483. */
  51484. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51485. /**
  51486. * Intensity of the direct lights e.g. the four lights available in your scene.
  51487. * This impacts both the direct diffuse and specular highlights.
  51488. */
  51489. directIntensity: number;
  51490. /**
  51491. * Intensity of the emissive part of the material.
  51492. * This helps controlling the emissive effect without modifying the emissive color.
  51493. */
  51494. emissiveIntensity: number;
  51495. /**
  51496. * Intensity of the environment e.g. how much the environment will light the object
  51497. * either through harmonics for rough material or through the refelction for shiny ones.
  51498. */
  51499. environmentIntensity: number;
  51500. /**
  51501. * This is a special control allowing the reduction of the specular highlights coming from the
  51502. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51503. */
  51504. specularIntensity: number;
  51505. /**
  51506. * Debug Control allowing disabling the bump map on this material.
  51507. */
  51508. disableBumpMap: boolean;
  51509. /**
  51510. * AKA Diffuse Texture in standard nomenclature.
  51511. */
  51512. albedoTexture: BaseTexture;
  51513. /**
  51514. * AKA Occlusion Texture in other nomenclature.
  51515. */
  51516. ambientTexture: BaseTexture;
  51517. /**
  51518. * AKA Occlusion Texture Intensity in other nomenclature.
  51519. */
  51520. ambientTextureStrength: number;
  51521. /**
  51522. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51523. * 1 means it completely occludes it
  51524. * 0 mean it has no impact
  51525. */
  51526. ambientTextureImpactOnAnalyticalLights: number;
  51527. /**
  51528. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51529. */
  51530. opacityTexture: BaseTexture;
  51531. /**
  51532. * Stores the reflection values in a texture.
  51533. */
  51534. reflectionTexture: Nullable<BaseTexture>;
  51535. /**
  51536. * Stores the emissive values in a texture.
  51537. */
  51538. emissiveTexture: BaseTexture;
  51539. /**
  51540. * AKA Specular texture in other nomenclature.
  51541. */
  51542. reflectivityTexture: BaseTexture;
  51543. /**
  51544. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51545. */
  51546. metallicTexture: BaseTexture;
  51547. /**
  51548. * Specifies the metallic scalar of the metallic/roughness workflow.
  51549. * Can also be used to scale the metalness values of the metallic texture.
  51550. */
  51551. metallic: Nullable<number>;
  51552. /**
  51553. * Specifies the roughness scalar of the metallic/roughness workflow.
  51554. * Can also be used to scale the roughness values of the metallic texture.
  51555. */
  51556. roughness: Nullable<number>;
  51557. /**
  51558. * Specifies the an F0 factor to help configuring the material F0.
  51559. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51560. * to 0.5 the previously hard coded value stays the same.
  51561. * Can also be used to scale the F0 values of the metallic texture.
  51562. */
  51563. metallicF0Factor: number;
  51564. /**
  51565. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51566. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51567. * your expectation as it multiplies with the texture data.
  51568. */
  51569. useMetallicF0FactorFromMetallicTexture: boolean;
  51570. /**
  51571. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51572. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51573. */
  51574. microSurfaceTexture: BaseTexture;
  51575. /**
  51576. * Stores surface normal data used to displace a mesh in a texture.
  51577. */
  51578. bumpTexture: BaseTexture;
  51579. /**
  51580. * Stores the pre-calculated light information of a mesh in a texture.
  51581. */
  51582. lightmapTexture: BaseTexture;
  51583. /**
  51584. * Stores the refracted light information in a texture.
  51585. */
  51586. get refractionTexture(): Nullable<BaseTexture>;
  51587. set refractionTexture(value: Nullable<BaseTexture>);
  51588. /**
  51589. * The color of a material in ambient lighting.
  51590. */
  51591. ambientColor: Color3;
  51592. /**
  51593. * AKA Diffuse Color in other nomenclature.
  51594. */
  51595. albedoColor: Color3;
  51596. /**
  51597. * AKA Specular Color in other nomenclature.
  51598. */
  51599. reflectivityColor: Color3;
  51600. /**
  51601. * The color reflected from the material.
  51602. */
  51603. reflectionColor: Color3;
  51604. /**
  51605. * The color emitted from the material.
  51606. */
  51607. emissiveColor: Color3;
  51608. /**
  51609. * AKA Glossiness in other nomenclature.
  51610. */
  51611. microSurface: number;
  51612. /**
  51613. * source material index of refraction (IOR)' / 'destination material IOR.
  51614. */
  51615. get indexOfRefraction(): number;
  51616. set indexOfRefraction(value: number);
  51617. /**
  51618. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51619. */
  51620. get invertRefractionY(): boolean;
  51621. set invertRefractionY(value: boolean);
  51622. /**
  51623. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51624. * Materials half opaque for instance using refraction could benefit from this control.
  51625. */
  51626. get linkRefractionWithTransparency(): boolean;
  51627. set linkRefractionWithTransparency(value: boolean);
  51628. /**
  51629. * If true, the light map contains occlusion information instead of lighting info.
  51630. */
  51631. useLightmapAsShadowmap: boolean;
  51632. /**
  51633. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51634. */
  51635. useAlphaFromAlbedoTexture: boolean;
  51636. /**
  51637. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51638. */
  51639. forceAlphaTest: boolean;
  51640. /**
  51641. * Defines the alpha limits in alpha test mode.
  51642. */
  51643. alphaCutOff: number;
  51644. /**
  51645. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51646. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51647. */
  51648. useSpecularOverAlpha: boolean;
  51649. /**
  51650. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51651. */
  51652. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51653. /**
  51654. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51655. */
  51656. useRoughnessFromMetallicTextureAlpha: boolean;
  51657. /**
  51658. * Specifies if the metallic texture contains the roughness information in its green channel.
  51659. */
  51660. useRoughnessFromMetallicTextureGreen: boolean;
  51661. /**
  51662. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51663. */
  51664. useMetallnessFromMetallicTextureBlue: boolean;
  51665. /**
  51666. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51667. */
  51668. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51669. /**
  51670. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51671. */
  51672. useAmbientInGrayScale: boolean;
  51673. /**
  51674. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51675. * The material will try to infer what glossiness each pixel should be.
  51676. */
  51677. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51678. /**
  51679. * BJS is using an harcoded light falloff based on a manually sets up range.
  51680. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51681. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51682. */
  51683. get usePhysicalLightFalloff(): boolean;
  51684. /**
  51685. * BJS is using an harcoded light falloff based on a manually sets up range.
  51686. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51687. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51688. */
  51689. set usePhysicalLightFalloff(value: boolean);
  51690. /**
  51691. * In order to support the falloff compatibility with gltf, a special mode has been added
  51692. * to reproduce the gltf light falloff.
  51693. */
  51694. get useGLTFLightFalloff(): boolean;
  51695. /**
  51696. * In order to support the falloff compatibility with gltf, a special mode has been added
  51697. * to reproduce the gltf light falloff.
  51698. */
  51699. set useGLTFLightFalloff(value: boolean);
  51700. /**
  51701. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51702. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51703. */
  51704. useRadianceOverAlpha: boolean;
  51705. /**
  51706. * Allows using an object space normal map (instead of tangent space).
  51707. */
  51708. useObjectSpaceNormalMap: boolean;
  51709. /**
  51710. * Allows using the bump map in parallax mode.
  51711. */
  51712. useParallax: boolean;
  51713. /**
  51714. * Allows using the bump map in parallax occlusion mode.
  51715. */
  51716. useParallaxOcclusion: boolean;
  51717. /**
  51718. * Controls the scale bias of the parallax mode.
  51719. */
  51720. parallaxScaleBias: number;
  51721. /**
  51722. * If sets to true, disables all the lights affecting the material.
  51723. */
  51724. disableLighting: boolean;
  51725. /**
  51726. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51727. */
  51728. forceIrradianceInFragment: boolean;
  51729. /**
  51730. * Number of Simultaneous lights allowed on the material.
  51731. */
  51732. maxSimultaneousLights: number;
  51733. /**
  51734. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51735. */
  51736. invertNormalMapX: boolean;
  51737. /**
  51738. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51739. */
  51740. invertNormalMapY: boolean;
  51741. /**
  51742. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51743. */
  51744. twoSidedLighting: boolean;
  51745. /**
  51746. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51747. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51748. */
  51749. useAlphaFresnel: boolean;
  51750. /**
  51751. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51752. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51753. */
  51754. useLinearAlphaFresnel: boolean;
  51755. /**
  51756. * Let user defines the brdf lookup texture used for IBL.
  51757. * A default 8bit version is embedded but you could point at :
  51758. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51759. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51760. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51761. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51762. */
  51763. environmentBRDFTexture: Nullable<BaseTexture>;
  51764. /**
  51765. * Force normal to face away from face.
  51766. */
  51767. forceNormalForward: boolean;
  51768. /**
  51769. * Enables specular anti aliasing in the PBR shader.
  51770. * It will both interacts on the Geometry for analytical and IBL lighting.
  51771. * It also prefilter the roughness map based on the bump values.
  51772. */
  51773. enableSpecularAntiAliasing: boolean;
  51774. /**
  51775. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51776. * makes the reflect vector face the model (under horizon).
  51777. */
  51778. useHorizonOcclusion: boolean;
  51779. /**
  51780. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51781. * too much the area relying on ambient texture to define their ambient occlusion.
  51782. */
  51783. useRadianceOcclusion: boolean;
  51784. /**
  51785. * If set to true, no lighting calculations will be applied.
  51786. */
  51787. unlit: boolean;
  51788. /**
  51789. * Gets the image processing configuration used either in this material.
  51790. */
  51791. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51792. /**
  51793. * Sets the Default image processing configuration used either in the this material.
  51794. *
  51795. * If sets to null, the scene one is in use.
  51796. */
  51797. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51798. /**
  51799. * Gets wether the color curves effect is enabled.
  51800. */
  51801. get cameraColorCurvesEnabled(): boolean;
  51802. /**
  51803. * Sets wether the color curves effect is enabled.
  51804. */
  51805. set cameraColorCurvesEnabled(value: boolean);
  51806. /**
  51807. * Gets wether the color grading effect is enabled.
  51808. */
  51809. get cameraColorGradingEnabled(): boolean;
  51810. /**
  51811. * Gets wether the color grading effect is enabled.
  51812. */
  51813. set cameraColorGradingEnabled(value: boolean);
  51814. /**
  51815. * Gets wether tonemapping is enabled or not.
  51816. */
  51817. get cameraToneMappingEnabled(): boolean;
  51818. /**
  51819. * Sets wether tonemapping is enabled or not
  51820. */
  51821. set cameraToneMappingEnabled(value: boolean);
  51822. /**
  51823. * The camera exposure used on this material.
  51824. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51825. * This corresponds to a photographic exposure.
  51826. */
  51827. get cameraExposure(): number;
  51828. /**
  51829. * The camera exposure used on this material.
  51830. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51831. * This corresponds to a photographic exposure.
  51832. */
  51833. set cameraExposure(value: number);
  51834. /**
  51835. * Gets The camera contrast used on this material.
  51836. */
  51837. get cameraContrast(): number;
  51838. /**
  51839. * Sets The camera contrast used on this material.
  51840. */
  51841. set cameraContrast(value: number);
  51842. /**
  51843. * Gets the Color Grading 2D Lookup Texture.
  51844. */
  51845. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51846. /**
  51847. * Sets the Color Grading 2D Lookup Texture.
  51848. */
  51849. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51850. /**
  51851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51853. * 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;
  51854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51855. */
  51856. get cameraColorCurves(): Nullable<ColorCurves>;
  51857. /**
  51858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51860. * 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;
  51861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51862. */
  51863. set cameraColorCurves(value: Nullable<ColorCurves>);
  51864. /**
  51865. * Instantiates a new PBRMaterial instance.
  51866. *
  51867. * @param name The material name
  51868. * @param scene The scene the material will be use in.
  51869. */
  51870. constructor(name: string, scene: Scene);
  51871. /**
  51872. * Returns the name of this material class.
  51873. */
  51874. getClassName(): string;
  51875. /**
  51876. * Makes a duplicate of the current material.
  51877. * @param name - name to use for the new material.
  51878. */
  51879. clone(name: string): PBRMaterial;
  51880. /**
  51881. * Serializes this PBR Material.
  51882. * @returns - An object with the serialized material.
  51883. */
  51884. serialize(): any;
  51885. /**
  51886. * Parses a PBR Material from a serialized object.
  51887. * @param source - Serialized object.
  51888. * @param scene - BJS scene instance.
  51889. * @param rootUrl - url for the scene object
  51890. * @returns - PBRMaterial
  51891. */
  51892. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51893. }
  51894. }
  51895. declare module BABYLON {
  51896. /**
  51897. * Direct draw surface info
  51898. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51899. */
  51900. export interface DDSInfo {
  51901. /**
  51902. * Width of the texture
  51903. */
  51904. width: number;
  51905. /**
  51906. * Width of the texture
  51907. */
  51908. height: number;
  51909. /**
  51910. * Number of Mipmaps for the texture
  51911. * @see https://en.wikipedia.org/wiki/Mipmap
  51912. */
  51913. mipmapCount: number;
  51914. /**
  51915. * If the textures format is a known fourCC format
  51916. * @see https://www.fourcc.org/
  51917. */
  51918. isFourCC: boolean;
  51919. /**
  51920. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51921. */
  51922. isRGB: boolean;
  51923. /**
  51924. * If the texture is a lumincance format
  51925. */
  51926. isLuminance: boolean;
  51927. /**
  51928. * If this is a cube texture
  51929. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51930. */
  51931. isCube: boolean;
  51932. /**
  51933. * If the texture is a compressed format eg. FOURCC_DXT1
  51934. */
  51935. isCompressed: boolean;
  51936. /**
  51937. * The dxgiFormat of the texture
  51938. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51939. */
  51940. dxgiFormat: number;
  51941. /**
  51942. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51943. */
  51944. textureType: number;
  51945. /**
  51946. * Sphericle polynomial created for the dds texture
  51947. */
  51948. sphericalPolynomial?: SphericalPolynomial;
  51949. }
  51950. /**
  51951. * Class used to provide DDS decompression tools
  51952. */
  51953. export class DDSTools {
  51954. /**
  51955. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51956. */
  51957. static StoreLODInAlphaChannel: boolean;
  51958. /**
  51959. * Gets DDS information from an array buffer
  51960. * @param data defines the array buffer view to read data from
  51961. * @returns the DDS information
  51962. */
  51963. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51964. private static _FloatView;
  51965. private static _Int32View;
  51966. private static _ToHalfFloat;
  51967. private static _FromHalfFloat;
  51968. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51969. private static _GetHalfFloatRGBAArrayBuffer;
  51970. private static _GetFloatRGBAArrayBuffer;
  51971. private static _GetFloatAsUIntRGBAArrayBuffer;
  51972. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51973. private static _GetRGBAArrayBuffer;
  51974. private static _ExtractLongWordOrder;
  51975. private static _GetRGBArrayBuffer;
  51976. private static _GetLuminanceArrayBuffer;
  51977. /**
  51978. * Uploads DDS Levels to a Babylon Texture
  51979. * @hidden
  51980. */
  51981. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51982. }
  51983. interface ThinEngine {
  51984. /**
  51985. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51986. * @param rootUrl defines the url where the file to load is located
  51987. * @param scene defines the current scene
  51988. * @param lodScale defines scale to apply to the mip map selection
  51989. * @param lodOffset defines offset to apply to the mip map selection
  51990. * @param onLoad defines an optional callback raised when the texture is loaded
  51991. * @param onError defines an optional callback raised if there is an issue to load the texture
  51992. * @param format defines the format of the data
  51993. * @param forcedExtension defines the extension to use to pick the right loader
  51994. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51995. * @returns the cube texture as an InternalTexture
  51996. */
  51997. 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;
  51998. }
  51999. }
  52000. declare module BABYLON {
  52001. /**
  52002. * Implementation of the DDS Texture Loader.
  52003. * @hidden
  52004. */
  52005. export class _DDSTextureLoader implements IInternalTextureLoader {
  52006. /**
  52007. * Defines wether the loader supports cascade loading the different faces.
  52008. */
  52009. readonly supportCascades: boolean;
  52010. /**
  52011. * This returns if the loader support the current file information.
  52012. * @param extension defines the file extension of the file being loaded
  52013. * @returns true if the loader can load the specified file
  52014. */
  52015. canLoad(extension: string): boolean;
  52016. /**
  52017. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52018. * @param data contains the texture data
  52019. * @param texture defines the BabylonJS internal texture
  52020. * @param createPolynomials will be true if polynomials have been requested
  52021. * @param onLoad defines the callback to trigger once the texture is ready
  52022. * @param onError defines the callback to trigger in case of error
  52023. */
  52024. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52025. /**
  52026. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52027. * @param data contains the texture data
  52028. * @param texture defines the BabylonJS internal texture
  52029. * @param callback defines the method to call once ready to upload
  52030. */
  52031. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52032. }
  52033. }
  52034. declare module BABYLON {
  52035. /**
  52036. * Implementation of the ENV Texture Loader.
  52037. * @hidden
  52038. */
  52039. export class _ENVTextureLoader implements IInternalTextureLoader {
  52040. /**
  52041. * Defines wether the loader supports cascade loading the different faces.
  52042. */
  52043. readonly supportCascades: boolean;
  52044. /**
  52045. * This returns if the loader support the current file information.
  52046. * @param extension defines the file extension of the file being loaded
  52047. * @returns true if the loader can load the specified file
  52048. */
  52049. canLoad(extension: string): boolean;
  52050. /**
  52051. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52052. * @param data contains the texture data
  52053. * @param texture defines the BabylonJS internal texture
  52054. * @param createPolynomials will be true if polynomials have been requested
  52055. * @param onLoad defines the callback to trigger once the texture is ready
  52056. * @param onError defines the callback to trigger in case of error
  52057. */
  52058. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52059. /**
  52060. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52061. * @param data contains the texture data
  52062. * @param texture defines the BabylonJS internal texture
  52063. * @param callback defines the method to call once ready to upload
  52064. */
  52065. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52066. }
  52067. }
  52068. declare module BABYLON {
  52069. /**
  52070. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52071. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52072. */
  52073. export class KhronosTextureContainer {
  52074. /** contents of the KTX container file */
  52075. data: ArrayBufferView;
  52076. private static HEADER_LEN;
  52077. private static COMPRESSED_2D;
  52078. private static COMPRESSED_3D;
  52079. private static TEX_2D;
  52080. private static TEX_3D;
  52081. /**
  52082. * Gets the openGL type
  52083. */
  52084. glType: number;
  52085. /**
  52086. * Gets the openGL type size
  52087. */
  52088. glTypeSize: number;
  52089. /**
  52090. * Gets the openGL format
  52091. */
  52092. glFormat: number;
  52093. /**
  52094. * Gets the openGL internal format
  52095. */
  52096. glInternalFormat: number;
  52097. /**
  52098. * Gets the base internal format
  52099. */
  52100. glBaseInternalFormat: number;
  52101. /**
  52102. * Gets image width in pixel
  52103. */
  52104. pixelWidth: number;
  52105. /**
  52106. * Gets image height in pixel
  52107. */
  52108. pixelHeight: number;
  52109. /**
  52110. * Gets image depth in pixels
  52111. */
  52112. pixelDepth: number;
  52113. /**
  52114. * Gets the number of array elements
  52115. */
  52116. numberOfArrayElements: number;
  52117. /**
  52118. * Gets the number of faces
  52119. */
  52120. numberOfFaces: number;
  52121. /**
  52122. * Gets the number of mipmap levels
  52123. */
  52124. numberOfMipmapLevels: number;
  52125. /**
  52126. * Gets the bytes of key value data
  52127. */
  52128. bytesOfKeyValueData: number;
  52129. /**
  52130. * Gets the load type
  52131. */
  52132. loadType: number;
  52133. /**
  52134. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52135. */
  52136. isInvalid: boolean;
  52137. /**
  52138. * Creates a new KhronosTextureContainer
  52139. * @param data contents of the KTX container file
  52140. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52141. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52142. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52143. */
  52144. constructor(
  52145. /** contents of the KTX container file */
  52146. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52147. /**
  52148. * Uploads KTX content to a Babylon Texture.
  52149. * It is assumed that the texture has already been created & is currently bound
  52150. * @hidden
  52151. */
  52152. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52153. private _upload2DCompressedLevels;
  52154. /**
  52155. * Checks if the given data starts with a KTX file identifier.
  52156. * @param data the data to check
  52157. * @returns true if the data is a KTX file or false otherwise
  52158. */
  52159. static IsValid(data: ArrayBufferView): boolean;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. /**
  52164. * Class for loading KTX2 files
  52165. * !!! Experimental Extension Subject to Changes !!!
  52166. * @hidden
  52167. */
  52168. export class KhronosTextureContainer2 {
  52169. private static _ModulePromise;
  52170. private static _TranscodeFormat;
  52171. constructor(engine: ThinEngine);
  52172. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52173. private _determineTranscodeFormat;
  52174. /**
  52175. * Checks if the given data starts with a KTX2 file identifier.
  52176. * @param data the data to check
  52177. * @returns true if the data is a KTX2 file or false otherwise
  52178. */
  52179. static IsValid(data: ArrayBufferView): boolean;
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /**
  52184. * Implementation of the KTX Texture Loader.
  52185. * @hidden
  52186. */
  52187. export class _KTXTextureLoader implements IInternalTextureLoader {
  52188. /**
  52189. * Defines wether the loader supports cascade loading the different faces.
  52190. */
  52191. readonly supportCascades: boolean;
  52192. /**
  52193. * This returns if the loader support the current file information.
  52194. * @param extension defines the file extension of the file being loaded
  52195. * @returns true if the loader can load the specified file
  52196. */
  52197. canLoad(extension: string): boolean;
  52198. /**
  52199. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52200. * @param data contains the texture data
  52201. * @param texture defines the BabylonJS internal texture
  52202. * @param createPolynomials will be true if polynomials have been requested
  52203. * @param onLoad defines the callback to trigger once the texture is ready
  52204. * @param onError defines the callback to trigger in case of error
  52205. */
  52206. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52207. /**
  52208. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52209. * @param data contains the texture data
  52210. * @param texture defines the BabylonJS internal texture
  52211. * @param callback defines the method to call once ready to upload
  52212. */
  52213. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52214. }
  52215. }
  52216. declare module BABYLON {
  52217. /** @hidden */
  52218. export var _forceSceneHelpersToBundle: boolean;
  52219. interface Scene {
  52220. /**
  52221. * Creates a default light for the scene.
  52222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52223. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52224. */
  52225. createDefaultLight(replace?: boolean): void;
  52226. /**
  52227. * Creates a default camera for the scene.
  52228. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52229. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52230. * @param replace has default false, when true replaces the active camera in the scene
  52231. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52232. */
  52233. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52234. /**
  52235. * Creates a default camera and a default light.
  52236. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52237. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52238. * @param replace has the default false, when true replaces the active camera/light in the scene
  52239. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52240. */
  52241. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52242. /**
  52243. * Creates a new sky box
  52244. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52245. * @param environmentTexture defines the texture to use as environment texture
  52246. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52247. * @param scale defines the overall scale of the skybox
  52248. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52249. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52250. * @returns a new mesh holding the sky box
  52251. */
  52252. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52253. /**
  52254. * Creates a new environment
  52255. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52256. * @param options defines the options you can use to configure the environment
  52257. * @returns the new EnvironmentHelper
  52258. */
  52259. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52260. /**
  52261. * Creates a new VREXperienceHelper
  52262. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52263. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52264. * @returns a new VREXperienceHelper
  52265. */
  52266. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52267. /**
  52268. * Creates a new WebXRDefaultExperience
  52269. * @see http://doc.babylonjs.com/how_to/webxr
  52270. * @param options experience options
  52271. * @returns a promise for a new WebXRDefaultExperience
  52272. */
  52273. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52274. }
  52275. }
  52276. declare module BABYLON {
  52277. /**
  52278. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52279. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52280. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52282. */
  52283. export class VideoDome extends TransformNode {
  52284. /**
  52285. * Define the video source as a Monoscopic panoramic 360 video.
  52286. */
  52287. static readonly MODE_MONOSCOPIC: number;
  52288. /**
  52289. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52290. */
  52291. static readonly MODE_TOPBOTTOM: number;
  52292. /**
  52293. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52294. */
  52295. static readonly MODE_SIDEBYSIDE: number;
  52296. private _halfDome;
  52297. private _useDirectMapping;
  52298. /**
  52299. * The video texture being displayed on the sphere
  52300. */
  52301. protected _videoTexture: VideoTexture;
  52302. /**
  52303. * Gets the video texture being displayed on the sphere
  52304. */
  52305. get videoTexture(): VideoTexture;
  52306. /**
  52307. * The skybox material
  52308. */
  52309. protected _material: BackgroundMaterial;
  52310. /**
  52311. * The surface used for the skybox
  52312. */
  52313. protected _mesh: Mesh;
  52314. /**
  52315. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52316. */
  52317. private _halfDomeMask;
  52318. /**
  52319. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52320. * Also see the options.resolution property.
  52321. */
  52322. get fovMultiplier(): number;
  52323. set fovMultiplier(value: number);
  52324. private _videoMode;
  52325. /**
  52326. * Gets or set the current video mode for the video. It can be:
  52327. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52328. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52329. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52330. */
  52331. get videoMode(): number;
  52332. set videoMode(value: number);
  52333. /**
  52334. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52335. *
  52336. */
  52337. get halfDome(): boolean;
  52338. /**
  52339. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52340. */
  52341. set halfDome(enabled: boolean);
  52342. /**
  52343. * Oberserver used in Stereoscopic VR Mode.
  52344. */
  52345. private _onBeforeCameraRenderObserver;
  52346. /**
  52347. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52348. * @param name Element's name, child elements will append suffixes for their own names.
  52349. * @param urlsOrVideo defines the url(s) or the video element to use
  52350. * @param options An object containing optional or exposed sub element properties
  52351. */
  52352. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52353. resolution?: number;
  52354. clickToPlay?: boolean;
  52355. autoPlay?: boolean;
  52356. loop?: boolean;
  52357. size?: number;
  52358. poster?: string;
  52359. faceForward?: boolean;
  52360. useDirectMapping?: boolean;
  52361. halfDomeMode?: boolean;
  52362. }, scene: Scene);
  52363. private _changeVideoMode;
  52364. /**
  52365. * Releases resources associated with this node.
  52366. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52367. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52368. */
  52369. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * This class can be used to get instrumentation data from a Babylon engine
  52375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52376. */
  52377. export class EngineInstrumentation implements IDisposable {
  52378. /**
  52379. * Define the instrumented engine.
  52380. */
  52381. engine: Engine;
  52382. private _captureGPUFrameTime;
  52383. private _gpuFrameTimeToken;
  52384. private _gpuFrameTime;
  52385. private _captureShaderCompilationTime;
  52386. private _shaderCompilationTime;
  52387. private _onBeginFrameObserver;
  52388. private _onEndFrameObserver;
  52389. private _onBeforeShaderCompilationObserver;
  52390. private _onAfterShaderCompilationObserver;
  52391. /**
  52392. * Gets the perf counter used for GPU frame time
  52393. */
  52394. get gpuFrameTimeCounter(): PerfCounter;
  52395. /**
  52396. * Gets the GPU frame time capture status
  52397. */
  52398. get captureGPUFrameTime(): boolean;
  52399. /**
  52400. * Enable or disable the GPU frame time capture
  52401. */
  52402. set captureGPUFrameTime(value: boolean);
  52403. /**
  52404. * Gets the perf counter used for shader compilation time
  52405. */
  52406. get shaderCompilationTimeCounter(): PerfCounter;
  52407. /**
  52408. * Gets the shader compilation time capture status
  52409. */
  52410. get captureShaderCompilationTime(): boolean;
  52411. /**
  52412. * Enable or disable the shader compilation time capture
  52413. */
  52414. set captureShaderCompilationTime(value: boolean);
  52415. /**
  52416. * Instantiates a new engine instrumentation.
  52417. * This class can be used to get instrumentation data from a Babylon engine
  52418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52419. * @param engine Defines the engine to instrument
  52420. */
  52421. constructor(
  52422. /**
  52423. * Define the instrumented engine.
  52424. */
  52425. engine: Engine);
  52426. /**
  52427. * Dispose and release associated resources.
  52428. */
  52429. dispose(): void;
  52430. }
  52431. }
  52432. declare module BABYLON {
  52433. /**
  52434. * This class can be used to get instrumentation data from a Babylon engine
  52435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52436. */
  52437. export class SceneInstrumentation implements IDisposable {
  52438. /**
  52439. * Defines the scene to instrument
  52440. */
  52441. scene: Scene;
  52442. private _captureActiveMeshesEvaluationTime;
  52443. private _activeMeshesEvaluationTime;
  52444. private _captureRenderTargetsRenderTime;
  52445. private _renderTargetsRenderTime;
  52446. private _captureFrameTime;
  52447. private _frameTime;
  52448. private _captureRenderTime;
  52449. private _renderTime;
  52450. private _captureInterFrameTime;
  52451. private _interFrameTime;
  52452. private _captureParticlesRenderTime;
  52453. private _particlesRenderTime;
  52454. private _captureSpritesRenderTime;
  52455. private _spritesRenderTime;
  52456. private _capturePhysicsTime;
  52457. private _physicsTime;
  52458. private _captureAnimationsTime;
  52459. private _animationsTime;
  52460. private _captureCameraRenderTime;
  52461. private _cameraRenderTime;
  52462. private _onBeforeActiveMeshesEvaluationObserver;
  52463. private _onAfterActiveMeshesEvaluationObserver;
  52464. private _onBeforeRenderTargetsRenderObserver;
  52465. private _onAfterRenderTargetsRenderObserver;
  52466. private _onAfterRenderObserver;
  52467. private _onBeforeDrawPhaseObserver;
  52468. private _onAfterDrawPhaseObserver;
  52469. private _onBeforeAnimationsObserver;
  52470. private _onBeforeParticlesRenderingObserver;
  52471. private _onAfterParticlesRenderingObserver;
  52472. private _onBeforeSpritesRenderingObserver;
  52473. private _onAfterSpritesRenderingObserver;
  52474. private _onBeforePhysicsObserver;
  52475. private _onAfterPhysicsObserver;
  52476. private _onAfterAnimationsObserver;
  52477. private _onBeforeCameraRenderObserver;
  52478. private _onAfterCameraRenderObserver;
  52479. /**
  52480. * Gets the perf counter used for active meshes evaluation time
  52481. */
  52482. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52483. /**
  52484. * Gets the active meshes evaluation time capture status
  52485. */
  52486. get captureActiveMeshesEvaluationTime(): boolean;
  52487. /**
  52488. * Enable or disable the active meshes evaluation time capture
  52489. */
  52490. set captureActiveMeshesEvaluationTime(value: boolean);
  52491. /**
  52492. * Gets the perf counter used for render targets render time
  52493. */
  52494. get renderTargetsRenderTimeCounter(): PerfCounter;
  52495. /**
  52496. * Gets the render targets render time capture status
  52497. */
  52498. get captureRenderTargetsRenderTime(): boolean;
  52499. /**
  52500. * Enable or disable the render targets render time capture
  52501. */
  52502. set captureRenderTargetsRenderTime(value: boolean);
  52503. /**
  52504. * Gets the perf counter used for particles render time
  52505. */
  52506. get particlesRenderTimeCounter(): PerfCounter;
  52507. /**
  52508. * Gets the particles render time capture status
  52509. */
  52510. get captureParticlesRenderTime(): boolean;
  52511. /**
  52512. * Enable or disable the particles render time capture
  52513. */
  52514. set captureParticlesRenderTime(value: boolean);
  52515. /**
  52516. * Gets the perf counter used for sprites render time
  52517. */
  52518. get spritesRenderTimeCounter(): PerfCounter;
  52519. /**
  52520. * Gets the sprites render time capture status
  52521. */
  52522. get captureSpritesRenderTime(): boolean;
  52523. /**
  52524. * Enable or disable the sprites render time capture
  52525. */
  52526. set captureSpritesRenderTime(value: boolean);
  52527. /**
  52528. * Gets the perf counter used for physics time
  52529. */
  52530. get physicsTimeCounter(): PerfCounter;
  52531. /**
  52532. * Gets the physics time capture status
  52533. */
  52534. get capturePhysicsTime(): boolean;
  52535. /**
  52536. * Enable or disable the physics time capture
  52537. */
  52538. set capturePhysicsTime(value: boolean);
  52539. /**
  52540. * Gets the perf counter used for animations time
  52541. */
  52542. get animationsTimeCounter(): PerfCounter;
  52543. /**
  52544. * Gets the animations time capture status
  52545. */
  52546. get captureAnimationsTime(): boolean;
  52547. /**
  52548. * Enable or disable the animations time capture
  52549. */
  52550. set captureAnimationsTime(value: boolean);
  52551. /**
  52552. * Gets the perf counter used for frame time capture
  52553. */
  52554. get frameTimeCounter(): PerfCounter;
  52555. /**
  52556. * Gets the frame time capture status
  52557. */
  52558. get captureFrameTime(): boolean;
  52559. /**
  52560. * Enable or disable the frame time capture
  52561. */
  52562. set captureFrameTime(value: boolean);
  52563. /**
  52564. * Gets the perf counter used for inter-frames time capture
  52565. */
  52566. get interFrameTimeCounter(): PerfCounter;
  52567. /**
  52568. * Gets the inter-frames time capture status
  52569. */
  52570. get captureInterFrameTime(): boolean;
  52571. /**
  52572. * Enable or disable the inter-frames time capture
  52573. */
  52574. set captureInterFrameTime(value: boolean);
  52575. /**
  52576. * Gets the perf counter used for render time capture
  52577. */
  52578. get renderTimeCounter(): PerfCounter;
  52579. /**
  52580. * Gets the render time capture status
  52581. */
  52582. get captureRenderTime(): boolean;
  52583. /**
  52584. * Enable or disable the render time capture
  52585. */
  52586. set captureRenderTime(value: boolean);
  52587. /**
  52588. * Gets the perf counter used for camera render time capture
  52589. */
  52590. get cameraRenderTimeCounter(): PerfCounter;
  52591. /**
  52592. * Gets the camera render time capture status
  52593. */
  52594. get captureCameraRenderTime(): boolean;
  52595. /**
  52596. * Enable or disable the camera render time capture
  52597. */
  52598. set captureCameraRenderTime(value: boolean);
  52599. /**
  52600. * Gets the perf counter used for draw calls
  52601. */
  52602. get drawCallsCounter(): PerfCounter;
  52603. /**
  52604. * Instantiates a new scene instrumentation.
  52605. * This class can be used to get instrumentation data from a Babylon engine
  52606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52607. * @param scene Defines the scene to instrument
  52608. */
  52609. constructor(
  52610. /**
  52611. * Defines the scene to instrument
  52612. */
  52613. scene: Scene);
  52614. /**
  52615. * Dispose and release associated resources.
  52616. */
  52617. dispose(): void;
  52618. }
  52619. }
  52620. declare module BABYLON {
  52621. /** @hidden */
  52622. export var glowMapGenerationPixelShader: {
  52623. name: string;
  52624. shader: string;
  52625. };
  52626. }
  52627. declare module BABYLON {
  52628. /** @hidden */
  52629. export var glowMapGenerationVertexShader: {
  52630. name: string;
  52631. shader: string;
  52632. };
  52633. }
  52634. declare module BABYLON {
  52635. /**
  52636. * Effect layer options. This helps customizing the behaviour
  52637. * of the effect layer.
  52638. */
  52639. export interface IEffectLayerOptions {
  52640. /**
  52641. * Multiplication factor apply to the canvas size to compute the render target size
  52642. * used to generated the objects (the smaller the faster).
  52643. */
  52644. mainTextureRatio: number;
  52645. /**
  52646. * Enforces a fixed size texture to ensure effect stability across devices.
  52647. */
  52648. mainTextureFixedSize?: number;
  52649. /**
  52650. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52651. */
  52652. alphaBlendingMode: number;
  52653. /**
  52654. * The camera attached to the layer.
  52655. */
  52656. camera: Nullable<Camera>;
  52657. /**
  52658. * The rendering group to draw the layer in.
  52659. */
  52660. renderingGroupId: number;
  52661. }
  52662. /**
  52663. * The effect layer Helps adding post process effect blended with the main pass.
  52664. *
  52665. * This can be for instance use to generate glow or higlight effects on the scene.
  52666. *
  52667. * The effect layer class can not be used directly and is intented to inherited from to be
  52668. * customized per effects.
  52669. */
  52670. export abstract class EffectLayer {
  52671. private _vertexBuffers;
  52672. private _indexBuffer;
  52673. private _cachedDefines;
  52674. private _effectLayerMapGenerationEffect;
  52675. private _effectLayerOptions;
  52676. private _mergeEffect;
  52677. protected _scene: Scene;
  52678. protected _engine: Engine;
  52679. protected _maxSize: number;
  52680. protected _mainTextureDesiredSize: ISize;
  52681. protected _mainTexture: RenderTargetTexture;
  52682. protected _shouldRender: boolean;
  52683. protected _postProcesses: PostProcess[];
  52684. protected _textures: BaseTexture[];
  52685. protected _emissiveTextureAndColor: {
  52686. texture: Nullable<BaseTexture>;
  52687. color: Color4;
  52688. };
  52689. /**
  52690. * The name of the layer
  52691. */
  52692. name: string;
  52693. /**
  52694. * The clear color of the texture used to generate the glow map.
  52695. */
  52696. neutralColor: Color4;
  52697. /**
  52698. * Specifies whether the highlight layer is enabled or not.
  52699. */
  52700. isEnabled: boolean;
  52701. /**
  52702. * Gets the camera attached to the layer.
  52703. */
  52704. get camera(): Nullable<Camera>;
  52705. /**
  52706. * Gets the rendering group id the layer should render in.
  52707. */
  52708. get renderingGroupId(): number;
  52709. set renderingGroupId(renderingGroupId: number);
  52710. /**
  52711. * An event triggered when the effect layer has been disposed.
  52712. */
  52713. onDisposeObservable: Observable<EffectLayer>;
  52714. /**
  52715. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52716. */
  52717. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52718. /**
  52719. * An event triggered when the generated texture is being merged in the scene.
  52720. */
  52721. onBeforeComposeObservable: Observable<EffectLayer>;
  52722. /**
  52723. * An event triggered when the mesh is rendered into the effect render target.
  52724. */
  52725. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52726. /**
  52727. * An event triggered after the mesh has been rendered into the effect render target.
  52728. */
  52729. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52730. /**
  52731. * An event triggered when the generated texture has been merged in the scene.
  52732. */
  52733. onAfterComposeObservable: Observable<EffectLayer>;
  52734. /**
  52735. * An event triggered when the efffect layer changes its size.
  52736. */
  52737. onSizeChangedObservable: Observable<EffectLayer>;
  52738. /** @hidden */
  52739. static _SceneComponentInitialization: (scene: Scene) => void;
  52740. /**
  52741. * Instantiates a new effect Layer and references it in the scene.
  52742. * @param name The name of the layer
  52743. * @param scene The scene to use the layer in
  52744. */
  52745. constructor(
  52746. /** The Friendly of the effect in the scene */
  52747. name: string, scene: Scene);
  52748. /**
  52749. * Get the effect name of the layer.
  52750. * @return The effect name
  52751. */
  52752. abstract getEffectName(): string;
  52753. /**
  52754. * Checks for the readiness of the element composing the layer.
  52755. * @param subMesh the mesh to check for
  52756. * @param useInstances specify whether or not to use instances to render the mesh
  52757. * @return true if ready otherwise, false
  52758. */
  52759. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52760. /**
  52761. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52762. * @returns true if the effect requires stencil during the main canvas render pass.
  52763. */
  52764. abstract needStencil(): boolean;
  52765. /**
  52766. * Create the merge effect. This is the shader use to blit the information back
  52767. * to the main canvas at the end of the scene rendering.
  52768. * @returns The effect containing the shader used to merge the effect on the main canvas
  52769. */
  52770. protected abstract _createMergeEffect(): Effect;
  52771. /**
  52772. * Creates the render target textures and post processes used in the effect layer.
  52773. */
  52774. protected abstract _createTextureAndPostProcesses(): void;
  52775. /**
  52776. * Implementation specific of rendering the generating effect on the main canvas.
  52777. * @param effect The effect used to render through
  52778. */
  52779. protected abstract _internalRender(effect: Effect): void;
  52780. /**
  52781. * Sets the required values for both the emissive texture and and the main color.
  52782. */
  52783. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52784. /**
  52785. * Free any resources and references associated to a mesh.
  52786. * Internal use
  52787. * @param mesh The mesh to free.
  52788. */
  52789. abstract _disposeMesh(mesh: Mesh): void;
  52790. /**
  52791. * Serializes this layer (Glow or Highlight for example)
  52792. * @returns a serialized layer object
  52793. */
  52794. abstract serialize?(): any;
  52795. /**
  52796. * Initializes the effect layer with the required options.
  52797. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52798. */
  52799. protected _init(options: Partial<IEffectLayerOptions>): void;
  52800. /**
  52801. * Generates the index buffer of the full screen quad blending to the main canvas.
  52802. */
  52803. private _generateIndexBuffer;
  52804. /**
  52805. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52806. */
  52807. private _generateVertexBuffer;
  52808. /**
  52809. * Sets the main texture desired size which is the closest power of two
  52810. * of the engine canvas size.
  52811. */
  52812. private _setMainTextureSize;
  52813. /**
  52814. * Creates the main texture for the effect layer.
  52815. */
  52816. protected _createMainTexture(): void;
  52817. /**
  52818. * Adds specific effects defines.
  52819. * @param defines The defines to add specifics to.
  52820. */
  52821. protected _addCustomEffectDefines(defines: string[]): void;
  52822. /**
  52823. * Checks for the readiness of the element composing the layer.
  52824. * @param subMesh the mesh to check for
  52825. * @param useInstances specify whether or not to use instances to render the mesh
  52826. * @param emissiveTexture the associated emissive texture used to generate the glow
  52827. * @return true if ready otherwise, false
  52828. */
  52829. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52830. /**
  52831. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52832. */
  52833. render(): void;
  52834. /**
  52835. * Determine if a given mesh will be used in the current effect.
  52836. * @param mesh mesh to test
  52837. * @returns true if the mesh will be used
  52838. */
  52839. hasMesh(mesh: AbstractMesh): boolean;
  52840. /**
  52841. * Returns true if the layer contains information to display, otherwise false.
  52842. * @returns true if the glow layer should be rendered
  52843. */
  52844. shouldRender(): boolean;
  52845. /**
  52846. * Returns true if the mesh should render, otherwise false.
  52847. * @param mesh The mesh to render
  52848. * @returns true if it should render otherwise false
  52849. */
  52850. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52851. /**
  52852. * Returns true if the mesh can be rendered, otherwise false.
  52853. * @param mesh The mesh to render
  52854. * @param material The material used on the mesh
  52855. * @returns true if it can be rendered otherwise false
  52856. */
  52857. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52858. /**
  52859. * Returns true if the mesh should render, otherwise false.
  52860. * @param mesh The mesh to render
  52861. * @returns true if it should render otherwise false
  52862. */
  52863. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52864. /**
  52865. * Renders the submesh passed in parameter to the generation map.
  52866. */
  52867. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52868. /**
  52869. * Defines whether the current material of the mesh should be use to render the effect.
  52870. * @param mesh defines the current mesh to render
  52871. */
  52872. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52873. /**
  52874. * Rebuild the required buffers.
  52875. * @hidden Internal use only.
  52876. */
  52877. _rebuild(): void;
  52878. /**
  52879. * Dispose only the render target textures and post process.
  52880. */
  52881. private _disposeTextureAndPostProcesses;
  52882. /**
  52883. * Dispose the highlight layer and free resources.
  52884. */
  52885. dispose(): void;
  52886. /**
  52887. * Gets the class name of the effect layer
  52888. * @returns the string with the class name of the effect layer
  52889. */
  52890. getClassName(): string;
  52891. /**
  52892. * Creates an effect layer from parsed effect layer data
  52893. * @param parsedEffectLayer defines effect layer data
  52894. * @param scene defines the current scene
  52895. * @param rootUrl defines the root URL containing the effect layer information
  52896. * @returns a parsed effect Layer
  52897. */
  52898. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52899. }
  52900. }
  52901. declare module BABYLON {
  52902. interface AbstractScene {
  52903. /**
  52904. * The list of effect layers (highlights/glow) added to the scene
  52905. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52906. * @see http://doc.babylonjs.com/how_to/glow_layer
  52907. */
  52908. effectLayers: Array<EffectLayer>;
  52909. /**
  52910. * Removes the given effect layer from this scene.
  52911. * @param toRemove defines the effect layer to remove
  52912. * @returns the index of the removed effect layer
  52913. */
  52914. removeEffectLayer(toRemove: EffectLayer): number;
  52915. /**
  52916. * Adds the given effect layer to this scene
  52917. * @param newEffectLayer defines the effect layer to add
  52918. */
  52919. addEffectLayer(newEffectLayer: EffectLayer): void;
  52920. }
  52921. /**
  52922. * Defines the layer scene component responsible to manage any effect layers
  52923. * in a given scene.
  52924. */
  52925. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52926. /**
  52927. * The component name helpfull to identify the component in the list of scene components.
  52928. */
  52929. readonly name: string;
  52930. /**
  52931. * The scene the component belongs to.
  52932. */
  52933. scene: Scene;
  52934. private _engine;
  52935. private _renderEffects;
  52936. private _needStencil;
  52937. private _previousStencilState;
  52938. /**
  52939. * Creates a new instance of the component for the given scene
  52940. * @param scene Defines the scene to register the component in
  52941. */
  52942. constructor(scene: Scene);
  52943. /**
  52944. * Registers the component in a given scene
  52945. */
  52946. register(): void;
  52947. /**
  52948. * Rebuilds the elements related to this component in case of
  52949. * context lost for instance.
  52950. */
  52951. rebuild(): void;
  52952. /**
  52953. * Serializes the component data to the specified json object
  52954. * @param serializationObject The object to serialize to
  52955. */
  52956. serialize(serializationObject: any): void;
  52957. /**
  52958. * Adds all the elements from the container to the scene
  52959. * @param container the container holding the elements
  52960. */
  52961. addFromContainer(container: AbstractScene): void;
  52962. /**
  52963. * Removes all the elements in the container from the scene
  52964. * @param container contains the elements to remove
  52965. * @param dispose if the removed element should be disposed (default: false)
  52966. */
  52967. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52968. /**
  52969. * Disposes the component and the associated ressources.
  52970. */
  52971. dispose(): void;
  52972. private _isReadyForMesh;
  52973. private _renderMainTexture;
  52974. private _setStencil;
  52975. private _setStencilBack;
  52976. private _draw;
  52977. private _drawCamera;
  52978. private _drawRenderingGroup;
  52979. }
  52980. }
  52981. declare module BABYLON {
  52982. /** @hidden */
  52983. export var glowMapMergePixelShader: {
  52984. name: string;
  52985. shader: string;
  52986. };
  52987. }
  52988. declare module BABYLON {
  52989. /** @hidden */
  52990. export var glowMapMergeVertexShader: {
  52991. name: string;
  52992. shader: string;
  52993. };
  52994. }
  52995. declare module BABYLON {
  52996. interface AbstractScene {
  52997. /**
  52998. * Return a the first highlight layer of the scene with a given name.
  52999. * @param name The name of the highlight layer to look for.
  53000. * @return The highlight layer if found otherwise null.
  53001. */
  53002. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53003. }
  53004. /**
  53005. * Glow layer options. This helps customizing the behaviour
  53006. * of the glow layer.
  53007. */
  53008. export interface IGlowLayerOptions {
  53009. /**
  53010. * Multiplication factor apply to the canvas size to compute the render target size
  53011. * used to generated the glowing objects (the smaller the faster).
  53012. */
  53013. mainTextureRatio: number;
  53014. /**
  53015. * Enforces a fixed size texture to ensure resize independant blur.
  53016. */
  53017. mainTextureFixedSize?: number;
  53018. /**
  53019. * How big is the kernel of the blur texture.
  53020. */
  53021. blurKernelSize: number;
  53022. /**
  53023. * The camera attached to the layer.
  53024. */
  53025. camera: Nullable<Camera>;
  53026. /**
  53027. * Enable MSAA by chosing the number of samples.
  53028. */
  53029. mainTextureSamples?: number;
  53030. /**
  53031. * The rendering group to draw the layer in.
  53032. */
  53033. renderingGroupId: number;
  53034. }
  53035. /**
  53036. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53037. *
  53038. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53039. *
  53040. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53041. */
  53042. export class GlowLayer extends EffectLayer {
  53043. /**
  53044. * Effect Name of the layer.
  53045. */
  53046. static readonly EffectName: string;
  53047. /**
  53048. * The default blur kernel size used for the glow.
  53049. */
  53050. static DefaultBlurKernelSize: number;
  53051. /**
  53052. * The default texture size ratio used for the glow.
  53053. */
  53054. static DefaultTextureRatio: number;
  53055. /**
  53056. * Sets the kernel size of the blur.
  53057. */
  53058. set blurKernelSize(value: number);
  53059. /**
  53060. * Gets the kernel size of the blur.
  53061. */
  53062. get blurKernelSize(): number;
  53063. /**
  53064. * Sets the glow intensity.
  53065. */
  53066. set intensity(value: number);
  53067. /**
  53068. * Gets the glow intensity.
  53069. */
  53070. get intensity(): number;
  53071. private _options;
  53072. private _intensity;
  53073. private _horizontalBlurPostprocess1;
  53074. private _verticalBlurPostprocess1;
  53075. private _horizontalBlurPostprocess2;
  53076. private _verticalBlurPostprocess2;
  53077. private _blurTexture1;
  53078. private _blurTexture2;
  53079. private _postProcesses1;
  53080. private _postProcesses2;
  53081. private _includedOnlyMeshes;
  53082. private _excludedMeshes;
  53083. private _meshesUsingTheirOwnMaterials;
  53084. /**
  53085. * Callback used to let the user override the color selection on a per mesh basis
  53086. */
  53087. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53088. /**
  53089. * Callback used to let the user override the texture selection on a per mesh basis
  53090. */
  53091. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53092. /**
  53093. * Instantiates a new glow Layer and references it to the scene.
  53094. * @param name The name of the layer
  53095. * @param scene The scene to use the layer in
  53096. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53097. */
  53098. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53099. /**
  53100. * Get the effect name of the layer.
  53101. * @return The effect name
  53102. */
  53103. getEffectName(): string;
  53104. /**
  53105. * Create the merge effect. This is the shader use to blit the information back
  53106. * to the main canvas at the end of the scene rendering.
  53107. */
  53108. protected _createMergeEffect(): Effect;
  53109. /**
  53110. * Creates the render target textures and post processes used in the glow layer.
  53111. */
  53112. protected _createTextureAndPostProcesses(): void;
  53113. /**
  53114. * Checks for the readiness of the element composing the layer.
  53115. * @param subMesh the mesh to check for
  53116. * @param useInstances specify wether or not to use instances to render the mesh
  53117. * @param emissiveTexture the associated emissive texture used to generate the glow
  53118. * @return true if ready otherwise, false
  53119. */
  53120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53121. /**
  53122. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53123. */
  53124. needStencil(): boolean;
  53125. /**
  53126. * Returns true if the mesh can be rendered, otherwise false.
  53127. * @param mesh The mesh to render
  53128. * @param material The material used on the mesh
  53129. * @returns true if it can be rendered otherwise false
  53130. */
  53131. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53132. /**
  53133. * Implementation specific of rendering the generating effect on the main canvas.
  53134. * @param effect The effect used to render through
  53135. */
  53136. protected _internalRender(effect: Effect): void;
  53137. /**
  53138. * Sets the required values for both the emissive texture and and the main color.
  53139. */
  53140. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53141. /**
  53142. * Returns true if the mesh should render, otherwise false.
  53143. * @param mesh The mesh to render
  53144. * @returns true if it should render otherwise false
  53145. */
  53146. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53147. /**
  53148. * Adds specific effects defines.
  53149. * @param defines The defines to add specifics to.
  53150. */
  53151. protected _addCustomEffectDefines(defines: string[]): void;
  53152. /**
  53153. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53154. * @param mesh The mesh to exclude from the glow layer
  53155. */
  53156. addExcludedMesh(mesh: Mesh): void;
  53157. /**
  53158. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53159. * @param mesh The mesh to remove
  53160. */
  53161. removeExcludedMesh(mesh: Mesh): void;
  53162. /**
  53163. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53164. * @param mesh The mesh to include in the glow layer
  53165. */
  53166. addIncludedOnlyMesh(mesh: Mesh): void;
  53167. /**
  53168. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53169. * @param mesh The mesh to remove
  53170. */
  53171. removeIncludedOnlyMesh(mesh: Mesh): void;
  53172. /**
  53173. * Determine if a given mesh will be used in the glow layer
  53174. * @param mesh The mesh to test
  53175. * @returns true if the mesh will be highlighted by the current glow layer
  53176. */
  53177. hasMesh(mesh: AbstractMesh): boolean;
  53178. /**
  53179. * Defines whether the current material of the mesh should be use to render the effect.
  53180. * @param mesh defines the current mesh to render
  53181. */
  53182. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53183. /**
  53184. * Add a mesh to be rendered through its own material and not with emissive only.
  53185. * @param mesh The mesh for which we need to use its material
  53186. */
  53187. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53188. /**
  53189. * Remove a mesh from being rendered through its own material and not with emissive only.
  53190. * @param mesh The mesh for which we need to not use its material
  53191. */
  53192. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53193. /**
  53194. * Free any resources and references associated to a mesh.
  53195. * Internal use
  53196. * @param mesh The mesh to free.
  53197. * @hidden
  53198. */
  53199. _disposeMesh(mesh: Mesh): void;
  53200. /**
  53201. * Gets the class name of the effect layer
  53202. * @returns the string with the class name of the effect layer
  53203. */
  53204. getClassName(): string;
  53205. /**
  53206. * Serializes this glow layer
  53207. * @returns a serialized glow layer object
  53208. */
  53209. serialize(): any;
  53210. /**
  53211. * Creates a Glow Layer from parsed glow layer data
  53212. * @param parsedGlowLayer defines glow layer data
  53213. * @param scene defines the current scene
  53214. * @param rootUrl defines the root URL containing the glow layer information
  53215. * @returns a parsed Glow Layer
  53216. */
  53217. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53218. }
  53219. }
  53220. declare module BABYLON {
  53221. /** @hidden */
  53222. export var glowBlurPostProcessPixelShader: {
  53223. name: string;
  53224. shader: string;
  53225. };
  53226. }
  53227. declare module BABYLON {
  53228. interface AbstractScene {
  53229. /**
  53230. * Return a the first highlight layer of the scene with a given name.
  53231. * @param name The name of the highlight layer to look for.
  53232. * @return The highlight layer if found otherwise null.
  53233. */
  53234. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53235. }
  53236. /**
  53237. * Highlight layer options. This helps customizing the behaviour
  53238. * of the highlight layer.
  53239. */
  53240. export interface IHighlightLayerOptions {
  53241. /**
  53242. * Multiplication factor apply to the canvas size to compute the render target size
  53243. * used to generated the glowing objects (the smaller the faster).
  53244. */
  53245. mainTextureRatio: number;
  53246. /**
  53247. * Enforces a fixed size texture to ensure resize independant blur.
  53248. */
  53249. mainTextureFixedSize?: number;
  53250. /**
  53251. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53252. * of the picture to blur (the smaller the faster).
  53253. */
  53254. blurTextureSizeRatio: number;
  53255. /**
  53256. * How big in texel of the blur texture is the vertical blur.
  53257. */
  53258. blurVerticalSize: number;
  53259. /**
  53260. * How big in texel of the blur texture is the horizontal blur.
  53261. */
  53262. blurHorizontalSize: number;
  53263. /**
  53264. * Alpha blending mode used to apply the blur. Default is combine.
  53265. */
  53266. alphaBlendingMode: number;
  53267. /**
  53268. * The camera attached to the layer.
  53269. */
  53270. camera: Nullable<Camera>;
  53271. /**
  53272. * Should we display highlight as a solid stroke?
  53273. */
  53274. isStroke?: boolean;
  53275. /**
  53276. * The rendering group to draw the layer in.
  53277. */
  53278. renderingGroupId: number;
  53279. }
  53280. /**
  53281. * The highlight layer Helps adding a glow effect around a mesh.
  53282. *
  53283. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53284. * glowy meshes to your scene.
  53285. *
  53286. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53287. */
  53288. export class HighlightLayer extends EffectLayer {
  53289. name: string;
  53290. /**
  53291. * Effect Name of the highlight layer.
  53292. */
  53293. static readonly EffectName: string;
  53294. /**
  53295. * The neutral color used during the preparation of the glow effect.
  53296. * This is black by default as the blend operation is a blend operation.
  53297. */
  53298. static NeutralColor: Color4;
  53299. /**
  53300. * Stencil value used for glowing meshes.
  53301. */
  53302. static GlowingMeshStencilReference: number;
  53303. /**
  53304. * Stencil value used for the other meshes in the scene.
  53305. */
  53306. static NormalMeshStencilReference: number;
  53307. /**
  53308. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53309. */
  53310. innerGlow: boolean;
  53311. /**
  53312. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53313. */
  53314. outerGlow: boolean;
  53315. /**
  53316. * Specifies the horizontal size of the blur.
  53317. */
  53318. set blurHorizontalSize(value: number);
  53319. /**
  53320. * Specifies the vertical size of the blur.
  53321. */
  53322. set blurVerticalSize(value: number);
  53323. /**
  53324. * Gets the horizontal size of the blur.
  53325. */
  53326. get blurHorizontalSize(): number;
  53327. /**
  53328. * Gets the vertical size of the blur.
  53329. */
  53330. get blurVerticalSize(): number;
  53331. /**
  53332. * An event triggered when the highlight layer is being blurred.
  53333. */
  53334. onBeforeBlurObservable: Observable<HighlightLayer>;
  53335. /**
  53336. * An event triggered when the highlight layer has been blurred.
  53337. */
  53338. onAfterBlurObservable: Observable<HighlightLayer>;
  53339. private _instanceGlowingMeshStencilReference;
  53340. private _options;
  53341. private _downSamplePostprocess;
  53342. private _horizontalBlurPostprocess;
  53343. private _verticalBlurPostprocess;
  53344. private _blurTexture;
  53345. private _meshes;
  53346. private _excludedMeshes;
  53347. /**
  53348. * Instantiates a new highlight Layer and references it to the scene..
  53349. * @param name The name of the layer
  53350. * @param scene The scene to use the layer in
  53351. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53352. */
  53353. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53354. /**
  53355. * Get the effect name of the layer.
  53356. * @return The effect name
  53357. */
  53358. getEffectName(): string;
  53359. /**
  53360. * Create the merge effect. This is the shader use to blit the information back
  53361. * to the main canvas at the end of the scene rendering.
  53362. */
  53363. protected _createMergeEffect(): Effect;
  53364. /**
  53365. * Creates the render target textures and post processes used in the highlight layer.
  53366. */
  53367. protected _createTextureAndPostProcesses(): void;
  53368. /**
  53369. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53370. */
  53371. needStencil(): boolean;
  53372. /**
  53373. * Checks for the readiness of the element composing the layer.
  53374. * @param subMesh the mesh to check for
  53375. * @param useInstances specify wether or not to use instances to render the mesh
  53376. * @param emissiveTexture the associated emissive texture used to generate the glow
  53377. * @return true if ready otherwise, false
  53378. */
  53379. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53380. /**
  53381. * Implementation specific of rendering the generating effect on the main canvas.
  53382. * @param effect The effect used to render through
  53383. */
  53384. protected _internalRender(effect: Effect): void;
  53385. /**
  53386. * Returns true if the layer contains information to display, otherwise false.
  53387. */
  53388. shouldRender(): boolean;
  53389. /**
  53390. * Returns true if the mesh should render, otherwise false.
  53391. * @param mesh The mesh to render
  53392. * @returns true if it should render otherwise false
  53393. */
  53394. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53395. /**
  53396. * Sets the required values for both the emissive texture and and the main color.
  53397. */
  53398. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53399. /**
  53400. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53401. * @param mesh The mesh to exclude from the highlight layer
  53402. */
  53403. addExcludedMesh(mesh: Mesh): void;
  53404. /**
  53405. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53406. * @param mesh The mesh to highlight
  53407. */
  53408. removeExcludedMesh(mesh: Mesh): void;
  53409. /**
  53410. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53411. * @param mesh mesh to test
  53412. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53413. */
  53414. hasMesh(mesh: AbstractMesh): boolean;
  53415. /**
  53416. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53417. * @param mesh The mesh to highlight
  53418. * @param color The color of the highlight
  53419. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53420. */
  53421. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53422. /**
  53423. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53424. * @param mesh The mesh to highlight
  53425. */
  53426. removeMesh(mesh: Mesh): void;
  53427. /**
  53428. * Remove all the meshes currently referenced in the highlight layer
  53429. */
  53430. removeAllMeshes(): void;
  53431. /**
  53432. * Force the stencil to the normal expected value for none glowing parts
  53433. */
  53434. private _defaultStencilReference;
  53435. /**
  53436. * Free any resources and references associated to a mesh.
  53437. * Internal use
  53438. * @param mesh The mesh to free.
  53439. * @hidden
  53440. */
  53441. _disposeMesh(mesh: Mesh): void;
  53442. /**
  53443. * Dispose the highlight layer and free resources.
  53444. */
  53445. dispose(): void;
  53446. /**
  53447. * Gets the class name of the effect layer
  53448. * @returns the string with the class name of the effect layer
  53449. */
  53450. getClassName(): string;
  53451. /**
  53452. * Serializes this Highlight layer
  53453. * @returns a serialized Highlight layer object
  53454. */
  53455. serialize(): any;
  53456. /**
  53457. * Creates a Highlight layer from parsed Highlight layer data
  53458. * @param parsedHightlightLayer defines the Highlight layer data
  53459. * @param scene defines the current scene
  53460. * @param rootUrl defines the root URL containing the Highlight layer information
  53461. * @returns a parsed Highlight layer
  53462. */
  53463. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53464. }
  53465. }
  53466. declare module BABYLON {
  53467. interface AbstractScene {
  53468. /**
  53469. * The list of layers (background and foreground) of the scene
  53470. */
  53471. layers: Array<Layer>;
  53472. }
  53473. /**
  53474. * Defines the layer scene component responsible to manage any layers
  53475. * in a given scene.
  53476. */
  53477. export class LayerSceneComponent implements ISceneComponent {
  53478. /**
  53479. * The component name helpfull to identify the component in the list of scene components.
  53480. */
  53481. readonly name: string;
  53482. /**
  53483. * The scene the component belongs to.
  53484. */
  53485. scene: Scene;
  53486. private _engine;
  53487. /**
  53488. * Creates a new instance of the component for the given scene
  53489. * @param scene Defines the scene to register the component in
  53490. */
  53491. constructor(scene: Scene);
  53492. /**
  53493. * Registers the component in a given scene
  53494. */
  53495. register(): void;
  53496. /**
  53497. * Rebuilds the elements related to this component in case of
  53498. * context lost for instance.
  53499. */
  53500. rebuild(): void;
  53501. /**
  53502. * Disposes the component and the associated ressources.
  53503. */
  53504. dispose(): void;
  53505. private _draw;
  53506. private _drawCameraPredicate;
  53507. private _drawCameraBackground;
  53508. private _drawCameraForeground;
  53509. private _drawRenderTargetPredicate;
  53510. private _drawRenderTargetBackground;
  53511. private _drawRenderTargetForeground;
  53512. /**
  53513. * Adds all the elements from the container to the scene
  53514. * @param container the container holding the elements
  53515. */
  53516. addFromContainer(container: AbstractScene): void;
  53517. /**
  53518. * Removes all the elements in the container from the scene
  53519. * @param container contains the elements to remove
  53520. * @param dispose if the removed element should be disposed (default: false)
  53521. */
  53522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53523. }
  53524. }
  53525. declare module BABYLON {
  53526. /** @hidden */
  53527. export var layerPixelShader: {
  53528. name: string;
  53529. shader: string;
  53530. };
  53531. }
  53532. declare module BABYLON {
  53533. /** @hidden */
  53534. export var layerVertexShader: {
  53535. name: string;
  53536. shader: string;
  53537. };
  53538. }
  53539. declare module BABYLON {
  53540. /**
  53541. * This represents a full screen 2d layer.
  53542. * This can be useful to display a picture in the background of your scene for instance.
  53543. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53544. */
  53545. export class Layer {
  53546. /**
  53547. * Define the name of the layer.
  53548. */
  53549. name: string;
  53550. /**
  53551. * Define the texture the layer should display.
  53552. */
  53553. texture: Nullable<Texture>;
  53554. /**
  53555. * Is the layer in background or foreground.
  53556. */
  53557. isBackground: boolean;
  53558. /**
  53559. * Define the color of the layer (instead of texture).
  53560. */
  53561. color: Color4;
  53562. /**
  53563. * Define the scale of the layer in order to zoom in out of the texture.
  53564. */
  53565. scale: Vector2;
  53566. /**
  53567. * Define an offset for the layer in order to shift the texture.
  53568. */
  53569. offset: Vector2;
  53570. /**
  53571. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53572. */
  53573. alphaBlendingMode: number;
  53574. /**
  53575. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53576. * Alpha test will not mix with the background color in case of transparency.
  53577. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53578. */
  53579. alphaTest: boolean;
  53580. /**
  53581. * Define a mask to restrict the layer to only some of the scene cameras.
  53582. */
  53583. layerMask: number;
  53584. /**
  53585. * Define the list of render target the layer is visible into.
  53586. */
  53587. renderTargetTextures: RenderTargetTexture[];
  53588. /**
  53589. * Define if the layer is only used in renderTarget or if it also
  53590. * renders in the main frame buffer of the canvas.
  53591. */
  53592. renderOnlyInRenderTargetTextures: boolean;
  53593. private _scene;
  53594. private _vertexBuffers;
  53595. private _indexBuffer;
  53596. private _effect;
  53597. private _previousDefines;
  53598. /**
  53599. * An event triggered when the layer is disposed.
  53600. */
  53601. onDisposeObservable: Observable<Layer>;
  53602. private _onDisposeObserver;
  53603. /**
  53604. * Back compatibility with callback before the onDisposeObservable existed.
  53605. * The set callback will be triggered when the layer has been disposed.
  53606. */
  53607. set onDispose(callback: () => void);
  53608. /**
  53609. * An event triggered before rendering the scene
  53610. */
  53611. onBeforeRenderObservable: Observable<Layer>;
  53612. private _onBeforeRenderObserver;
  53613. /**
  53614. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53615. * The set callback will be triggered just before rendering the layer.
  53616. */
  53617. set onBeforeRender(callback: () => void);
  53618. /**
  53619. * An event triggered after rendering the scene
  53620. */
  53621. onAfterRenderObservable: Observable<Layer>;
  53622. private _onAfterRenderObserver;
  53623. /**
  53624. * Back compatibility with callback before the onAfterRenderObservable existed.
  53625. * The set callback will be triggered just after rendering the layer.
  53626. */
  53627. set onAfterRender(callback: () => void);
  53628. /**
  53629. * Instantiates a new layer.
  53630. * This represents a full screen 2d layer.
  53631. * This can be useful to display a picture in the background of your scene for instance.
  53632. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53633. * @param name Define the name of the layer in the scene
  53634. * @param imgUrl Define the url of the texture to display in the layer
  53635. * @param scene Define the scene the layer belongs to
  53636. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53637. * @param color Defines a color for the layer
  53638. */
  53639. constructor(
  53640. /**
  53641. * Define the name of the layer.
  53642. */
  53643. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53644. private _createIndexBuffer;
  53645. /** @hidden */
  53646. _rebuild(): void;
  53647. /**
  53648. * Renders the layer in the scene.
  53649. */
  53650. render(): void;
  53651. /**
  53652. * Disposes and releases the associated ressources.
  53653. */
  53654. dispose(): void;
  53655. }
  53656. }
  53657. declare module BABYLON {
  53658. /** @hidden */
  53659. export var lensFlarePixelShader: {
  53660. name: string;
  53661. shader: string;
  53662. };
  53663. }
  53664. declare module BABYLON {
  53665. /** @hidden */
  53666. export var lensFlareVertexShader: {
  53667. name: string;
  53668. shader: string;
  53669. };
  53670. }
  53671. declare module BABYLON {
  53672. /**
  53673. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53674. * It is usually composed of several `lensFlare`.
  53675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53676. */
  53677. export class LensFlareSystem {
  53678. /**
  53679. * Define the name of the lens flare system
  53680. */
  53681. name: string;
  53682. /**
  53683. * List of lens flares used in this system.
  53684. */
  53685. lensFlares: LensFlare[];
  53686. /**
  53687. * Define a limit from the border the lens flare can be visible.
  53688. */
  53689. borderLimit: number;
  53690. /**
  53691. * Define a viewport border we do not want to see the lens flare in.
  53692. */
  53693. viewportBorder: number;
  53694. /**
  53695. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53696. */
  53697. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53698. /**
  53699. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53700. */
  53701. layerMask: number;
  53702. /**
  53703. * Define the id of the lens flare system in the scene.
  53704. * (equal to name by default)
  53705. */
  53706. id: string;
  53707. private _scene;
  53708. private _emitter;
  53709. private _vertexBuffers;
  53710. private _indexBuffer;
  53711. private _effect;
  53712. private _positionX;
  53713. private _positionY;
  53714. private _isEnabled;
  53715. /** @hidden */
  53716. static _SceneComponentInitialization: (scene: Scene) => void;
  53717. /**
  53718. * Instantiates a lens flare system.
  53719. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53720. * It is usually composed of several `lensFlare`.
  53721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53722. * @param name Define the name of the lens flare system in the scene
  53723. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53724. * @param scene Define the scene the lens flare system belongs to
  53725. */
  53726. constructor(
  53727. /**
  53728. * Define the name of the lens flare system
  53729. */
  53730. name: string, emitter: any, scene: Scene);
  53731. /**
  53732. * Define if the lens flare system is enabled.
  53733. */
  53734. get isEnabled(): boolean;
  53735. set isEnabled(value: boolean);
  53736. /**
  53737. * Get the scene the effects belongs to.
  53738. * @returns the scene holding the lens flare system
  53739. */
  53740. getScene(): Scene;
  53741. /**
  53742. * Get 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. * @returns the emitter of the lens flare system
  53745. */
  53746. getEmitter(): any;
  53747. /**
  53748. * Set the emitter of the lens flare system.
  53749. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53750. * @param newEmitter Define the new emitter of the system
  53751. */
  53752. setEmitter(newEmitter: any): void;
  53753. /**
  53754. * Get the lens flare system emitter position.
  53755. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53756. * @returns the position
  53757. */
  53758. getEmitterPosition(): Vector3;
  53759. /**
  53760. * @hidden
  53761. */
  53762. computeEffectivePosition(globalViewport: Viewport): boolean;
  53763. /** @hidden */
  53764. _isVisible(): boolean;
  53765. /**
  53766. * @hidden
  53767. */
  53768. render(): boolean;
  53769. /**
  53770. * Dispose and release the lens flare with its associated resources.
  53771. */
  53772. dispose(): void;
  53773. /**
  53774. * Parse a lens flare system from a JSON repressentation
  53775. * @param parsedLensFlareSystem Define the JSON to parse
  53776. * @param scene Define the scene the parsed system should be instantiated in
  53777. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53778. * @returns the parsed system
  53779. */
  53780. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53781. /**
  53782. * Serialize the current Lens Flare System into a JSON representation.
  53783. * @returns the serialized JSON
  53784. */
  53785. serialize(): any;
  53786. }
  53787. }
  53788. declare module BABYLON {
  53789. /**
  53790. * This represents one of the lens effect in a `lensFlareSystem`.
  53791. * It controls one of the indiviual texture used in the effect.
  53792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53793. */
  53794. export class LensFlare {
  53795. /**
  53796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53797. */
  53798. size: number;
  53799. /**
  53800. * 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.
  53801. */
  53802. position: number;
  53803. /**
  53804. * Define the lens color.
  53805. */
  53806. color: Color3;
  53807. /**
  53808. * Define the lens texture.
  53809. */
  53810. texture: Nullable<Texture>;
  53811. /**
  53812. * Define the alpha mode to render this particular lens.
  53813. */
  53814. alphaMode: number;
  53815. private _system;
  53816. /**
  53817. * Creates a new Lens Flare.
  53818. * This represents one of the lens effect in a `lensFlareSystem`.
  53819. * It controls one of the indiviual texture used in the effect.
  53820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53821. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53822. * @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.
  53823. * @param color Define the lens color
  53824. * @param imgUrl Define the lens texture url
  53825. * @param system Define the `lensFlareSystem` this flare is part of
  53826. * @returns The newly created Lens Flare
  53827. */
  53828. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53829. /**
  53830. * Instantiates a new Lens Flare.
  53831. * This represents one of the lens effect in a `lensFlareSystem`.
  53832. * It controls one of the indiviual texture used in the effect.
  53833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53834. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53835. * @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.
  53836. * @param color Define the lens color
  53837. * @param imgUrl Define the lens texture url
  53838. * @param system Define the `lensFlareSystem` this flare is part of
  53839. */
  53840. constructor(
  53841. /**
  53842. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53843. */
  53844. size: number,
  53845. /**
  53846. * 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.
  53847. */
  53848. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53849. /**
  53850. * Dispose and release the lens flare with its associated resources.
  53851. */
  53852. dispose(): void;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. interface AbstractScene {
  53857. /**
  53858. * The list of lens flare system added to the scene
  53859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53860. */
  53861. lensFlareSystems: Array<LensFlareSystem>;
  53862. /**
  53863. * Removes the given lens flare system from this scene.
  53864. * @param toRemove The lens flare system to remove
  53865. * @returns The index of the removed lens flare system
  53866. */
  53867. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53868. /**
  53869. * Adds the given lens flare system to this scene
  53870. * @param newLensFlareSystem The lens flare system to add
  53871. */
  53872. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53873. /**
  53874. * Gets a lens flare system using its name
  53875. * @param name defines the name to look for
  53876. * @returns the lens flare system or null if not found
  53877. */
  53878. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53879. /**
  53880. * Gets a lens flare system using its id
  53881. * @param id defines the id to look for
  53882. * @returns the lens flare system or null if not found
  53883. */
  53884. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53885. }
  53886. /**
  53887. * Defines the lens flare scene component responsible to manage any lens flares
  53888. * in a given scene.
  53889. */
  53890. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53891. /**
  53892. * The component name helpfull to identify the component in the list of scene components.
  53893. */
  53894. readonly name: string;
  53895. /**
  53896. * The scene the component belongs to.
  53897. */
  53898. scene: Scene;
  53899. /**
  53900. * Creates a new instance of the component for the given scene
  53901. * @param scene Defines the scene to register the component in
  53902. */
  53903. constructor(scene: Scene);
  53904. /**
  53905. * Registers the component in a given scene
  53906. */
  53907. register(): void;
  53908. /**
  53909. * Rebuilds the elements related to this component in case of
  53910. * context lost for instance.
  53911. */
  53912. rebuild(): void;
  53913. /**
  53914. * Adds all the elements from the container to the scene
  53915. * @param container the container holding the elements
  53916. */
  53917. addFromContainer(container: AbstractScene): void;
  53918. /**
  53919. * Removes all the elements in the container from the scene
  53920. * @param container contains the elements to remove
  53921. * @param dispose if the removed element should be disposed (default: false)
  53922. */
  53923. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53924. /**
  53925. * Serializes the component data to the specified json object
  53926. * @param serializationObject The object to serialize to
  53927. */
  53928. serialize(serializationObject: any): void;
  53929. /**
  53930. * Disposes the component and the associated ressources.
  53931. */
  53932. dispose(): void;
  53933. private _draw;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /** @hidden */
  53938. export var depthPixelShader: {
  53939. name: string;
  53940. shader: string;
  53941. };
  53942. }
  53943. declare module BABYLON {
  53944. /** @hidden */
  53945. export var depthVertexShader: {
  53946. name: string;
  53947. shader: string;
  53948. };
  53949. }
  53950. declare module BABYLON {
  53951. /**
  53952. * This represents a depth renderer in Babylon.
  53953. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53954. */
  53955. export class DepthRenderer {
  53956. private _scene;
  53957. private _depthMap;
  53958. private _effect;
  53959. private readonly _storeNonLinearDepth;
  53960. private readonly _clearColor;
  53961. /** Get if the depth renderer is using packed depth or not */
  53962. readonly isPacked: boolean;
  53963. private _cachedDefines;
  53964. private _camera;
  53965. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53966. enabled: boolean;
  53967. /**
  53968. * Specifiess that the depth renderer will only be used within
  53969. * the camera it is created for.
  53970. * This can help forcing its rendering during the camera processing.
  53971. */
  53972. useOnlyInActiveCamera: boolean;
  53973. /** @hidden */
  53974. static _SceneComponentInitialization: (scene: Scene) => void;
  53975. /**
  53976. * Instantiates a depth renderer
  53977. * @param scene The scene the renderer belongs to
  53978. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53979. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53980. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53981. */
  53982. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53983. /**
  53984. * Creates the depth rendering effect and checks if the effect is ready.
  53985. * @param subMesh The submesh to be used to render the depth map of
  53986. * @param useInstances If multiple world instances should be used
  53987. * @returns if the depth renderer is ready to render the depth map
  53988. */
  53989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53990. /**
  53991. * Gets the texture which the depth map will be written to.
  53992. * @returns The depth map texture
  53993. */
  53994. getDepthMap(): RenderTargetTexture;
  53995. /**
  53996. * Disposes of the depth renderer.
  53997. */
  53998. dispose(): void;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /** @hidden */
  54003. export var minmaxReduxPixelShader: {
  54004. name: string;
  54005. shader: string;
  54006. };
  54007. }
  54008. declare module BABYLON {
  54009. /**
  54010. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54011. * and maximum values from all values of the texture.
  54012. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54013. * The source values are read from the red channel of the texture.
  54014. */
  54015. export class MinMaxReducer {
  54016. /**
  54017. * Observable triggered when the computation has been performed
  54018. */
  54019. onAfterReductionPerformed: Observable<{
  54020. min: number;
  54021. max: number;
  54022. }>;
  54023. protected _camera: Camera;
  54024. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54025. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54026. protected _postProcessManager: PostProcessManager;
  54027. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54028. protected _forceFullscreenViewport: boolean;
  54029. /**
  54030. * Creates a min/max reducer
  54031. * @param camera The camera to use for the post processes
  54032. */
  54033. constructor(camera: Camera);
  54034. /**
  54035. * Gets the texture used to read the values from.
  54036. */
  54037. get sourceTexture(): Nullable<RenderTargetTexture>;
  54038. /**
  54039. * Sets the source texture to read the values from.
  54040. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54041. * because in such textures '1' value must not be taken into account to compute the maximum
  54042. * as this value is used to clear the texture.
  54043. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54044. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54045. * @param depthRedux Indicates if the texture is a depth texture or not
  54046. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54047. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54048. */
  54049. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54050. /**
  54051. * Defines the refresh rate of the computation.
  54052. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54053. */
  54054. get refreshRate(): number;
  54055. set refreshRate(value: number);
  54056. protected _activated: boolean;
  54057. /**
  54058. * Gets the activation status of the reducer
  54059. */
  54060. get activated(): boolean;
  54061. /**
  54062. * Activates the reduction computation.
  54063. * When activated, the observers registered in onAfterReductionPerformed are
  54064. * called after the compuation is performed
  54065. */
  54066. activate(): void;
  54067. /**
  54068. * Deactivates the reduction computation.
  54069. */
  54070. deactivate(): void;
  54071. /**
  54072. * Disposes the min/max reducer
  54073. * @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.
  54074. */
  54075. dispose(disposeAll?: boolean): void;
  54076. }
  54077. }
  54078. declare module BABYLON {
  54079. /**
  54080. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54081. */
  54082. export class DepthReducer extends MinMaxReducer {
  54083. private _depthRenderer;
  54084. private _depthRendererId;
  54085. /**
  54086. * Gets the depth renderer used for the computation.
  54087. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54088. */
  54089. get depthRenderer(): Nullable<DepthRenderer>;
  54090. /**
  54091. * Creates a depth reducer
  54092. * @param camera The camera used to render the depth texture
  54093. */
  54094. constructor(camera: Camera);
  54095. /**
  54096. * Sets the depth renderer to use to generate the depth map
  54097. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54098. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54099. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54100. */
  54101. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54102. /** @hidden */
  54103. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54104. /**
  54105. * Activates the reduction computation.
  54106. * When activated, the observers registered in onAfterReductionPerformed are
  54107. * called after the compuation is performed
  54108. */
  54109. activate(): void;
  54110. /**
  54111. * Deactivates the reduction computation.
  54112. */
  54113. deactivate(): void;
  54114. /**
  54115. * Disposes the depth reducer
  54116. * @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.
  54117. */
  54118. dispose(disposeAll?: boolean): void;
  54119. }
  54120. }
  54121. declare module BABYLON {
  54122. /**
  54123. * A CSM implementation allowing casting shadows on large scenes.
  54124. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54125. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54126. */
  54127. export class CascadedShadowGenerator extends ShadowGenerator {
  54128. private static readonly frustumCornersNDCSpace;
  54129. /**
  54130. * Name of the CSM class
  54131. */
  54132. static CLASSNAME: string;
  54133. /**
  54134. * Defines the default number of cascades used by the CSM.
  54135. */
  54136. static readonly DEFAULT_CASCADES_COUNT: number;
  54137. /**
  54138. * Defines the minimum number of cascades used by the CSM.
  54139. */
  54140. static readonly MIN_CASCADES_COUNT: number;
  54141. /**
  54142. * Defines the maximum number of cascades used by the CSM.
  54143. */
  54144. static readonly MAX_CASCADES_COUNT: number;
  54145. protected _validateFilter(filter: number): number;
  54146. /**
  54147. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54148. */
  54149. penumbraDarkness: number;
  54150. private _numCascades;
  54151. /**
  54152. * Gets or set the number of cascades used by the CSM.
  54153. */
  54154. get numCascades(): number;
  54155. set numCascades(value: number);
  54156. /**
  54157. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54158. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54159. */
  54160. stabilizeCascades: boolean;
  54161. private _freezeShadowCastersBoundingInfo;
  54162. private _freezeShadowCastersBoundingInfoObservable;
  54163. /**
  54164. * Enables or disables the shadow casters bounding info computation.
  54165. * If your shadow casters don't move, you can disable this feature.
  54166. * If it is enabled, the bounding box computation is done every frame.
  54167. */
  54168. get freezeShadowCastersBoundingInfo(): boolean;
  54169. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54170. private _scbiMin;
  54171. private _scbiMax;
  54172. protected _computeShadowCastersBoundingInfo(): void;
  54173. protected _shadowCastersBoundingInfo: BoundingInfo;
  54174. /**
  54175. * Gets or sets the shadow casters bounding info.
  54176. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54177. * so that the system won't overwrite the bounds you provide
  54178. */
  54179. get shadowCastersBoundingInfo(): BoundingInfo;
  54180. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54181. protected _breaksAreDirty: boolean;
  54182. protected _minDistance: number;
  54183. protected _maxDistance: number;
  54184. /**
  54185. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54186. *
  54187. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54188. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54189. * @param min minimal distance for the breaks (default to 0.)
  54190. * @param max maximal distance for the breaks (default to 1.)
  54191. */
  54192. setMinMaxDistance(min: number, max: number): void;
  54193. /** Gets the minimal distance used in the cascade break computation */
  54194. get minDistance(): number;
  54195. /** Gets the maximal distance used in the cascade break computation */
  54196. get maxDistance(): number;
  54197. /**
  54198. * Gets the class name of that object
  54199. * @returns "CascadedShadowGenerator"
  54200. */
  54201. getClassName(): string;
  54202. private _cascadeMinExtents;
  54203. private _cascadeMaxExtents;
  54204. /**
  54205. * Gets a cascade minimum extents
  54206. * @param cascadeIndex index of the cascade
  54207. * @returns the minimum cascade extents
  54208. */
  54209. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54210. /**
  54211. * Gets a cascade maximum extents
  54212. * @param cascadeIndex index of the cascade
  54213. * @returns the maximum cascade extents
  54214. */
  54215. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54216. private _cascades;
  54217. private _currentLayer;
  54218. private _viewSpaceFrustumsZ;
  54219. private _viewMatrices;
  54220. private _projectionMatrices;
  54221. private _transformMatrices;
  54222. private _transformMatricesAsArray;
  54223. private _frustumLengths;
  54224. private _lightSizeUVCorrection;
  54225. private _depthCorrection;
  54226. private _frustumCornersWorldSpace;
  54227. private _frustumCenter;
  54228. private _shadowCameraPos;
  54229. private _shadowMaxZ;
  54230. /**
  54231. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54232. * It defaults to camera.maxZ
  54233. */
  54234. get shadowMaxZ(): number;
  54235. /**
  54236. * Sets the shadow max z distance.
  54237. */
  54238. set shadowMaxZ(value: number);
  54239. protected _debug: boolean;
  54240. /**
  54241. * Gets or sets the debug flag.
  54242. * When enabled, the cascades are materialized by different colors on the screen.
  54243. */
  54244. get debug(): boolean;
  54245. set debug(dbg: boolean);
  54246. private _depthClamp;
  54247. /**
  54248. * Gets or sets the depth clamping value.
  54249. *
  54250. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54251. * to account for the shadow casters far away.
  54252. *
  54253. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54254. */
  54255. get depthClamp(): boolean;
  54256. set depthClamp(value: boolean);
  54257. private _cascadeBlendPercentage;
  54258. /**
  54259. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54260. * It defaults to 0.1 (10% blending).
  54261. */
  54262. get cascadeBlendPercentage(): number;
  54263. set cascadeBlendPercentage(value: number);
  54264. private _lambda;
  54265. /**
  54266. * Gets or set the lambda parameter.
  54267. * This parameter is used to split the camera frustum and create the cascades.
  54268. * 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.
  54269. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54270. */
  54271. get lambda(): number;
  54272. set lambda(value: number);
  54273. /**
  54274. * Gets the view matrix corresponding to a given cascade
  54275. * @param cascadeNum cascade to retrieve the view matrix from
  54276. * @returns the cascade view matrix
  54277. */
  54278. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54279. /**
  54280. * Gets the projection matrix corresponding to a given cascade
  54281. * @param cascadeNum cascade to retrieve the projection matrix from
  54282. * @returns the cascade projection matrix
  54283. */
  54284. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54285. /**
  54286. * Gets the transformation matrix corresponding to a given cascade
  54287. * @param cascadeNum cascade to retrieve the transformation matrix from
  54288. * @returns the cascade transformation matrix
  54289. */
  54290. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54291. private _depthRenderer;
  54292. /**
  54293. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54294. *
  54295. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54296. *
  54297. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54298. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54299. * @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
  54300. */
  54301. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54302. private _depthReducer;
  54303. private _autoCalcDepthBounds;
  54304. /**
  54305. * Gets or sets the autoCalcDepthBounds property.
  54306. *
  54307. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54308. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54309. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54310. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54311. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54312. */
  54313. get autoCalcDepthBounds(): boolean;
  54314. set autoCalcDepthBounds(value: boolean);
  54315. /**
  54316. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54317. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54318. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54319. * for setting the refresh rate on the renderer yourself!
  54320. */
  54321. get autoCalcDepthBoundsRefreshRate(): number;
  54322. set autoCalcDepthBoundsRefreshRate(value: number);
  54323. /**
  54324. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54325. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54326. * you change the camera near/far planes!
  54327. */
  54328. splitFrustum(): void;
  54329. private _splitFrustum;
  54330. private _computeMatrices;
  54331. private _computeFrustumInWorldSpace;
  54332. private _computeCascadeFrustum;
  54333. /** @hidden */
  54334. static _SceneComponentInitialization: (scene: Scene) => void;
  54335. /**
  54336. * Creates a Cascaded Shadow Generator object.
  54337. * A ShadowGenerator is the required tool to use the shadows.
  54338. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54339. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54340. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54341. * @param light The directional light object generating the shadows.
  54342. * @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.
  54343. */
  54344. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54345. protected _initializeGenerator(): void;
  54346. protected _createTargetRenderTexture(): void;
  54347. protected _initializeShadowMap(): void;
  54348. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54349. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54350. /**
  54351. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54352. * @param defines Defines of the material we want to update
  54353. * @param lightIndex Index of the light in the enabled light list of the material
  54354. */
  54355. prepareDefines(defines: any, lightIndex: number): void;
  54356. /**
  54357. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54358. * defined in the generator but impacting the effect).
  54359. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54360. * @param effect The effect we are binfing the information for
  54361. */
  54362. bindShadowLight(lightIndex: string, effect: Effect): void;
  54363. /**
  54364. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54365. * (eq to view projection * shadow projection matrices)
  54366. * @returns The transform matrix used to create the shadow map
  54367. */
  54368. getTransformMatrix(): Matrix;
  54369. /**
  54370. * Disposes the ShadowGenerator.
  54371. * Returns nothing.
  54372. */
  54373. dispose(): void;
  54374. /**
  54375. * Serializes the shadow generator setup to a json object.
  54376. * @returns The serialized JSON object
  54377. */
  54378. serialize(): any;
  54379. /**
  54380. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54381. * @param parsedShadowGenerator The JSON object to parse
  54382. * @param scene The scene to create the shadow map for
  54383. * @returns The parsed shadow generator
  54384. */
  54385. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54386. }
  54387. }
  54388. declare module BABYLON {
  54389. /**
  54390. * Defines the shadow generator component responsible to manage any shadow generators
  54391. * in a given scene.
  54392. */
  54393. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54394. /**
  54395. * The component name helpfull to identify the component in the list of scene components.
  54396. */
  54397. readonly name: string;
  54398. /**
  54399. * The scene the component belongs to.
  54400. */
  54401. scene: Scene;
  54402. /**
  54403. * Creates a new instance of the component for the given scene
  54404. * @param scene Defines the scene to register the component in
  54405. */
  54406. constructor(scene: Scene);
  54407. /**
  54408. * Registers the component in a given scene
  54409. */
  54410. register(): void;
  54411. /**
  54412. * Rebuilds the elements related to this component in case of
  54413. * context lost for instance.
  54414. */
  54415. rebuild(): void;
  54416. /**
  54417. * Serializes the component data to the specified json object
  54418. * @param serializationObject The object to serialize to
  54419. */
  54420. serialize(serializationObject: any): void;
  54421. /**
  54422. * Adds all the elements from the container to the scene
  54423. * @param container the container holding the elements
  54424. */
  54425. addFromContainer(container: AbstractScene): void;
  54426. /**
  54427. * Removes all the elements in the container from the scene
  54428. * @param container contains the elements to remove
  54429. * @param dispose if the removed element should be disposed (default: false)
  54430. */
  54431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54432. /**
  54433. * Rebuilds the elements related to this component in case of
  54434. * context lost for instance.
  54435. */
  54436. dispose(): void;
  54437. private _gatherRenderTargets;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. /**
  54442. * A point light is a light defined by an unique point in world space.
  54443. * The light is emitted in every direction from this point.
  54444. * A good example of a point light is a standard light bulb.
  54445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54446. */
  54447. export class PointLight extends ShadowLight {
  54448. private _shadowAngle;
  54449. /**
  54450. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54451. * This specifies what angle the shadow will use to be created.
  54452. *
  54453. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54454. */
  54455. get shadowAngle(): number;
  54456. /**
  54457. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54458. * This specifies what angle the shadow will use to be created.
  54459. *
  54460. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54461. */
  54462. set shadowAngle(value: number);
  54463. /**
  54464. * Gets the direction if it has been set.
  54465. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54466. */
  54467. get direction(): Vector3;
  54468. /**
  54469. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54470. */
  54471. set direction(value: Vector3);
  54472. /**
  54473. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54474. * A PointLight emits the light in every direction.
  54475. * It can cast shadows.
  54476. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54477. * ```javascript
  54478. * var pointLight = new PointLight("pl", camera.position, scene);
  54479. * ```
  54480. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54481. * @param name The light friendly name
  54482. * @param position The position of the point light in the scene
  54483. * @param scene The scene the lights belongs to
  54484. */
  54485. constructor(name: string, position: Vector3, scene: Scene);
  54486. /**
  54487. * Returns the string "PointLight"
  54488. * @returns the class name
  54489. */
  54490. getClassName(): string;
  54491. /**
  54492. * Returns the integer 0.
  54493. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54494. */
  54495. getTypeID(): number;
  54496. /**
  54497. * Specifies wether or not the shadowmap should be a cube texture.
  54498. * @returns true if the shadowmap needs to be a cube texture.
  54499. */
  54500. needCube(): boolean;
  54501. /**
  54502. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54503. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54504. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54505. */
  54506. getShadowDirection(faceIndex?: number): Vector3;
  54507. /**
  54508. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54509. * - fov = PI / 2
  54510. * - aspect ratio : 1.0
  54511. * - z-near and far equal to the active camera minZ and maxZ.
  54512. * Returns the PointLight.
  54513. */
  54514. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54515. protected _buildUniformLayout(): void;
  54516. /**
  54517. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54518. * @param effect The effect to update
  54519. * @param lightIndex The index of the light in the effect to update
  54520. * @returns The point light
  54521. */
  54522. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54523. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54524. /**
  54525. * Prepares the list of defines specific to the light type.
  54526. * @param defines the list of defines
  54527. * @param lightIndex defines the index of the light for the effect
  54528. */
  54529. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54530. }
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * Header information of HDR texture files.
  54535. */
  54536. export interface HDRInfo {
  54537. /**
  54538. * The height of the texture in pixels.
  54539. */
  54540. height: number;
  54541. /**
  54542. * The width of the texture in pixels.
  54543. */
  54544. width: number;
  54545. /**
  54546. * The index of the beginning of the data in the binary file.
  54547. */
  54548. dataPosition: number;
  54549. }
  54550. /**
  54551. * This groups tools to convert HDR texture to native colors array.
  54552. */
  54553. export class HDRTools {
  54554. private static Ldexp;
  54555. private static Rgbe2float;
  54556. private static readStringLine;
  54557. /**
  54558. * Reads header information from an RGBE texture stored in a native array.
  54559. * More information on this format are available here:
  54560. * https://en.wikipedia.org/wiki/RGBE_image_format
  54561. *
  54562. * @param uint8array The binary file stored in native array.
  54563. * @return The header information.
  54564. */
  54565. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54566. /**
  54567. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54568. * This RGBE texture needs to store the information as a panorama.
  54569. *
  54570. * More information on this format are available here:
  54571. * https://en.wikipedia.org/wiki/RGBE_image_format
  54572. *
  54573. * @param buffer The binary file stored in an array buffer.
  54574. * @param size The expected size of the extracted cubemap.
  54575. * @return The Cube Map information.
  54576. */
  54577. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54578. /**
  54579. * Returns the pixels data extracted from an RGBE texture.
  54580. * This pixels will be stored left to right up to down in the R G B order in one array.
  54581. *
  54582. * More information on this format are available here:
  54583. * https://en.wikipedia.org/wiki/RGBE_image_format
  54584. *
  54585. * @param uint8array The binary file stored in an array buffer.
  54586. * @param hdrInfo The header information of the file.
  54587. * @return The pixels data in RGB right to left up to down order.
  54588. */
  54589. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54590. private static RGBE_ReadPixels_RLE;
  54591. }
  54592. }
  54593. declare module BABYLON {
  54594. /**
  54595. * This represents a texture coming from an HDR input.
  54596. *
  54597. * The only supported format is currently panorama picture stored in RGBE format.
  54598. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54599. */
  54600. export class HDRCubeTexture extends BaseTexture {
  54601. private static _facesMapping;
  54602. private _generateHarmonics;
  54603. private _noMipmap;
  54604. private _textureMatrix;
  54605. private _size;
  54606. private _onLoad;
  54607. private _onError;
  54608. /**
  54609. * The texture URL.
  54610. */
  54611. url: string;
  54612. /**
  54613. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54614. */
  54615. coordinatesMode: number;
  54616. protected _isBlocking: boolean;
  54617. /**
  54618. * Sets wether or not the texture is blocking during loading.
  54619. */
  54620. set isBlocking(value: boolean);
  54621. /**
  54622. * Gets wether or not the texture is blocking during loading.
  54623. */
  54624. get isBlocking(): boolean;
  54625. protected _rotationY: number;
  54626. /**
  54627. * Sets texture matrix rotation angle around Y axis in radians.
  54628. */
  54629. set rotationY(value: number);
  54630. /**
  54631. * Gets texture matrix rotation angle around Y axis radians.
  54632. */
  54633. get rotationY(): number;
  54634. /**
  54635. * Gets or sets the center of the bounding box associated with the cube texture
  54636. * It must define where the camera used to render the texture was set
  54637. */
  54638. boundingBoxPosition: Vector3;
  54639. private _boundingBoxSize;
  54640. /**
  54641. * Gets or sets the size of the bounding box associated with the cube texture
  54642. * When defined, the cubemap will switch to local mode
  54643. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54644. * @example https://www.babylonjs-playground.com/#RNASML
  54645. */
  54646. set boundingBoxSize(value: Vector3);
  54647. get boundingBoxSize(): Vector3;
  54648. /**
  54649. * Instantiates an HDRTexture from the following parameters.
  54650. *
  54651. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54652. * @param scene The scene the texture will be used in
  54653. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54654. * @param noMipmap Forces to not generate the mipmap if true
  54655. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54656. * @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)
  54657. * @param reserved Reserved flag for internal use.
  54658. */
  54659. 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>);
  54660. /**
  54661. * Get the current class name of the texture useful for serialization or dynamic coding.
  54662. * @returns "HDRCubeTexture"
  54663. */
  54664. getClassName(): string;
  54665. /**
  54666. * Occurs when the file is raw .hdr file.
  54667. */
  54668. private loadTexture;
  54669. clone(): HDRCubeTexture;
  54670. delayLoad(): void;
  54671. /**
  54672. * Get the texture reflection matrix used to rotate/transform the reflection.
  54673. * @returns the reflection matrix
  54674. */
  54675. getReflectionTextureMatrix(): Matrix;
  54676. /**
  54677. * Set the texture reflection matrix used to rotate/transform the reflection.
  54678. * @param value Define the reflection matrix to set
  54679. */
  54680. setReflectionTextureMatrix(value: Matrix): void;
  54681. /**
  54682. * Parses a JSON representation of an HDR Texture in order to create the texture
  54683. * @param parsedTexture Define the JSON representation
  54684. * @param scene Define the scene the texture should be created in
  54685. * @param rootUrl Define the root url in case we need to load relative dependencies
  54686. * @returns the newly created texture after parsing
  54687. */
  54688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54689. serialize(): any;
  54690. }
  54691. }
  54692. declare module BABYLON {
  54693. /**
  54694. * Class used to control physics engine
  54695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54696. */
  54697. export class PhysicsEngine implements IPhysicsEngine {
  54698. private _physicsPlugin;
  54699. /**
  54700. * Global value used to control the smallest number supported by the simulation
  54701. */
  54702. static Epsilon: number;
  54703. private _impostors;
  54704. private _joints;
  54705. private _subTimeStep;
  54706. /**
  54707. * Gets the gravity vector used by the simulation
  54708. */
  54709. gravity: Vector3;
  54710. /**
  54711. * Factory used to create the default physics plugin.
  54712. * @returns The default physics plugin
  54713. */
  54714. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54715. /**
  54716. * Creates a new Physics Engine
  54717. * @param gravity defines the gravity vector used by the simulation
  54718. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54719. */
  54720. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54721. /**
  54722. * Sets the gravity vector used by the simulation
  54723. * @param gravity defines the gravity vector to use
  54724. */
  54725. setGravity(gravity: Vector3): void;
  54726. /**
  54727. * Set the time step of the physics engine.
  54728. * Default is 1/60.
  54729. * To slow it down, enter 1/600 for example.
  54730. * To speed it up, 1/30
  54731. * @param newTimeStep defines the new timestep to apply to this world.
  54732. */
  54733. setTimeStep(newTimeStep?: number): void;
  54734. /**
  54735. * Get the time step of the physics engine.
  54736. * @returns the current time step
  54737. */
  54738. getTimeStep(): number;
  54739. /**
  54740. * Set the sub time step of the physics engine.
  54741. * Default is 0 meaning there is no sub steps
  54742. * To increase physics resolution precision, set a small value (like 1 ms)
  54743. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54744. */
  54745. setSubTimeStep(subTimeStep?: number): void;
  54746. /**
  54747. * Get the sub time step of the physics engine.
  54748. * @returns the current sub time step
  54749. */
  54750. getSubTimeStep(): number;
  54751. /**
  54752. * Release all resources
  54753. */
  54754. dispose(): void;
  54755. /**
  54756. * Gets the name of the current physics plugin
  54757. * @returns the name of the plugin
  54758. */
  54759. getPhysicsPluginName(): string;
  54760. /**
  54761. * Adding a new impostor for the impostor tracking.
  54762. * This will be done by the impostor itself.
  54763. * @param impostor the impostor to add
  54764. */
  54765. addImpostor(impostor: PhysicsImpostor): void;
  54766. /**
  54767. * Remove an impostor from the engine.
  54768. * This impostor and its mesh will not longer be updated by the physics engine.
  54769. * @param impostor the impostor to remove
  54770. */
  54771. removeImpostor(impostor: PhysicsImpostor): void;
  54772. /**
  54773. * Add a joint to the physics engine
  54774. * @param mainImpostor defines the main impostor to which the joint is added.
  54775. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54776. * @param joint defines the joint that will connect both impostors.
  54777. */
  54778. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54779. /**
  54780. * Removes a joint from the simulation
  54781. * @param mainImpostor defines the impostor used with the joint
  54782. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54783. * @param joint defines the joint to remove
  54784. */
  54785. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54786. /**
  54787. * Called by the scene. No need to call it.
  54788. * @param delta defines the timespam between frames
  54789. */
  54790. _step(delta: number): void;
  54791. /**
  54792. * Gets the current plugin used to run the simulation
  54793. * @returns current plugin
  54794. */
  54795. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54796. /**
  54797. * Gets the list of physic impostors
  54798. * @returns an array of PhysicsImpostor
  54799. */
  54800. getImpostors(): Array<PhysicsImpostor>;
  54801. /**
  54802. * Gets the impostor for a physics enabled object
  54803. * @param object defines the object impersonated by the impostor
  54804. * @returns the PhysicsImpostor or null if not found
  54805. */
  54806. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54807. /**
  54808. * Gets the impostor for a physics body object
  54809. * @param body defines physics body used by the impostor
  54810. * @returns the PhysicsImpostor or null if not found
  54811. */
  54812. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54813. /**
  54814. * Does a raycast in the physics world
  54815. * @param from when should the ray start?
  54816. * @param to when should the ray end?
  54817. * @returns PhysicsRaycastResult
  54818. */
  54819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54820. }
  54821. }
  54822. declare module BABYLON {
  54823. /** @hidden */
  54824. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54825. private _useDeltaForWorldStep;
  54826. world: any;
  54827. name: string;
  54828. private _physicsMaterials;
  54829. private _fixedTimeStep;
  54830. private _cannonRaycastResult;
  54831. private _raycastResult;
  54832. private _physicsBodysToRemoveAfterStep;
  54833. BJSCANNON: any;
  54834. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54835. setGravity(gravity: Vector3): void;
  54836. setTimeStep(timeStep: number): void;
  54837. getTimeStep(): number;
  54838. executeStep(delta: number): void;
  54839. private _removeMarkedPhysicsBodiesFromWorld;
  54840. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54841. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54842. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54843. private _processChildMeshes;
  54844. removePhysicsBody(impostor: PhysicsImpostor): void;
  54845. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54846. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54847. private _addMaterial;
  54848. private _checkWithEpsilon;
  54849. private _createShape;
  54850. private _createHeightmap;
  54851. private _minus90X;
  54852. private _plus90X;
  54853. private _tmpPosition;
  54854. private _tmpDeltaPosition;
  54855. private _tmpUnityRotation;
  54856. private _updatePhysicsBodyTransformation;
  54857. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54858. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54859. isSupported(): boolean;
  54860. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54861. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54862. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54863. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54864. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54865. getBodyMass(impostor: PhysicsImpostor): number;
  54866. getBodyFriction(impostor: PhysicsImpostor): number;
  54867. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54868. getBodyRestitution(impostor: PhysicsImpostor): number;
  54869. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54870. sleepBody(impostor: PhysicsImpostor): void;
  54871. wakeUpBody(impostor: PhysicsImpostor): void;
  54872. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54873. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54874. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54876. getRadius(impostor: PhysicsImpostor): number;
  54877. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54878. dispose(): void;
  54879. private _extendNamespace;
  54880. /**
  54881. * Does a raycast in the physics world
  54882. * @param from when should the ray start?
  54883. * @param to when should the ray end?
  54884. * @returns PhysicsRaycastResult
  54885. */
  54886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54887. }
  54888. }
  54889. declare module BABYLON {
  54890. /** @hidden */
  54891. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54892. world: any;
  54893. name: string;
  54894. BJSOIMO: any;
  54895. private _raycastResult;
  54896. constructor(iterations?: number, oimoInjection?: any);
  54897. setGravity(gravity: Vector3): void;
  54898. setTimeStep(timeStep: number): void;
  54899. getTimeStep(): number;
  54900. private _tmpImpostorsArray;
  54901. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54902. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54903. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54904. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54905. private _tmpPositionVector;
  54906. removePhysicsBody(impostor: PhysicsImpostor): void;
  54907. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54908. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54909. isSupported(): boolean;
  54910. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54911. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54912. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54913. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54914. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54915. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54916. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54917. getBodyMass(impostor: PhysicsImpostor): number;
  54918. getBodyFriction(impostor: PhysicsImpostor): number;
  54919. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54920. getBodyRestitution(impostor: PhysicsImpostor): number;
  54921. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54922. sleepBody(impostor: PhysicsImpostor): void;
  54923. wakeUpBody(impostor: PhysicsImpostor): void;
  54924. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54925. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54926. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54928. getRadius(impostor: PhysicsImpostor): number;
  54929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54930. dispose(): void;
  54931. /**
  54932. * Does a raycast in the physics world
  54933. * @param from when should the ray start?
  54934. * @param to when should the ray end?
  54935. * @returns PhysicsRaycastResult
  54936. */
  54937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54938. }
  54939. }
  54940. declare module BABYLON {
  54941. /**
  54942. * Class containing static functions to help procedurally build meshes
  54943. */
  54944. export class RibbonBuilder {
  54945. /**
  54946. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54947. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54948. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54949. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54950. * * 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
  54951. * * 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
  54952. * * 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
  54953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54954. * * 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
  54955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54956. * * 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
  54957. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54958. * * 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
  54959. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54961. * @param name defines the name of the mesh
  54962. * @param options defines the options used to create the mesh
  54963. * @param scene defines the hosting scene
  54964. * @returns the ribbon mesh
  54965. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54967. */
  54968. static CreateRibbon(name: string, options: {
  54969. pathArray: Vector3[][];
  54970. closeArray?: boolean;
  54971. closePath?: boolean;
  54972. offset?: number;
  54973. updatable?: boolean;
  54974. sideOrientation?: number;
  54975. frontUVs?: Vector4;
  54976. backUVs?: Vector4;
  54977. instance?: Mesh;
  54978. invertUV?: boolean;
  54979. uvs?: Vector2[];
  54980. colors?: Color4[];
  54981. }, scene?: Nullable<Scene>): Mesh;
  54982. }
  54983. }
  54984. declare module BABYLON {
  54985. /**
  54986. * Class containing static functions to help procedurally build meshes
  54987. */
  54988. export class ShapeBuilder {
  54989. /**
  54990. * 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.
  54991. * * 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.
  54992. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54993. * * 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.
  54994. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54995. * * 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
  54996. * * 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
  54997. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54999. * * 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
  55000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55002. * @param name defines the name of the mesh
  55003. * @param options defines the options used to create the mesh
  55004. * @param scene defines the hosting scene
  55005. * @returns the extruded shape mesh
  55006. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55008. */
  55009. static ExtrudeShape(name: string, options: {
  55010. shape: Vector3[];
  55011. path: Vector3[];
  55012. scale?: number;
  55013. rotation?: number;
  55014. cap?: number;
  55015. updatable?: boolean;
  55016. sideOrientation?: number;
  55017. frontUVs?: Vector4;
  55018. backUVs?: Vector4;
  55019. instance?: Mesh;
  55020. invertUV?: boolean;
  55021. }, scene?: Nullable<Scene>): Mesh;
  55022. /**
  55023. * Creates an custom extruded shape mesh.
  55024. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55025. * * 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.
  55026. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55027. * * 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
  55028. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55029. * * 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
  55030. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55031. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55032. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55033. * * 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
  55034. * * 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
  55035. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55037. * * 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
  55038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55040. * @param name defines the name of the mesh
  55041. * @param options defines the options used to create the mesh
  55042. * @param scene defines the hosting scene
  55043. * @returns the custom extruded shape mesh
  55044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55047. */
  55048. static ExtrudeShapeCustom(name: string, options: {
  55049. shape: Vector3[];
  55050. path: Vector3[];
  55051. scaleFunction?: any;
  55052. rotationFunction?: any;
  55053. ribbonCloseArray?: boolean;
  55054. ribbonClosePath?: boolean;
  55055. cap?: number;
  55056. updatable?: boolean;
  55057. sideOrientation?: number;
  55058. frontUVs?: Vector4;
  55059. backUVs?: Vector4;
  55060. instance?: Mesh;
  55061. invertUV?: boolean;
  55062. }, scene?: Nullable<Scene>): Mesh;
  55063. private static _ExtrudeShapeGeneric;
  55064. }
  55065. }
  55066. declare module BABYLON {
  55067. /**
  55068. * AmmoJS Physics plugin
  55069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55070. * @see https://github.com/kripken/ammo.js/
  55071. */
  55072. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55073. private _useDeltaForWorldStep;
  55074. /**
  55075. * Reference to the Ammo library
  55076. */
  55077. bjsAMMO: any;
  55078. /**
  55079. * Created ammoJS world which physics bodies are added to
  55080. */
  55081. world: any;
  55082. /**
  55083. * Name of the plugin
  55084. */
  55085. name: string;
  55086. private _timeStep;
  55087. private _fixedTimeStep;
  55088. private _maxSteps;
  55089. private _tmpQuaternion;
  55090. private _tmpAmmoTransform;
  55091. private _tmpAmmoQuaternion;
  55092. private _tmpAmmoConcreteContactResultCallback;
  55093. private _collisionConfiguration;
  55094. private _dispatcher;
  55095. private _overlappingPairCache;
  55096. private _solver;
  55097. private _softBodySolver;
  55098. private _tmpAmmoVectorA;
  55099. private _tmpAmmoVectorB;
  55100. private _tmpAmmoVectorC;
  55101. private _tmpAmmoVectorD;
  55102. private _tmpContactCallbackResult;
  55103. private _tmpAmmoVectorRCA;
  55104. private _tmpAmmoVectorRCB;
  55105. private _raycastResult;
  55106. private static readonly DISABLE_COLLISION_FLAG;
  55107. private static readonly KINEMATIC_FLAG;
  55108. private static readonly DISABLE_DEACTIVATION_FLAG;
  55109. /**
  55110. * Initializes the ammoJS plugin
  55111. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55112. * @param ammoInjection can be used to inject your own ammo reference
  55113. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55114. */
  55115. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55116. /**
  55117. * Sets the gravity of the physics world (m/(s^2))
  55118. * @param gravity Gravity to set
  55119. */
  55120. setGravity(gravity: Vector3): void;
  55121. /**
  55122. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55123. * @param timeStep timestep to use in seconds
  55124. */
  55125. setTimeStep(timeStep: number): void;
  55126. /**
  55127. * 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)
  55128. * @param fixedTimeStep fixedTimeStep to use in seconds
  55129. */
  55130. setFixedTimeStep(fixedTimeStep: number): void;
  55131. /**
  55132. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55133. * @param maxSteps the maximum number of steps by the physics engine per frame
  55134. */
  55135. setMaxSteps(maxSteps: number): void;
  55136. /**
  55137. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55138. * @returns the current timestep in seconds
  55139. */
  55140. getTimeStep(): number;
  55141. /**
  55142. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55143. */
  55144. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55145. private _isImpostorInContact;
  55146. private _isImpostorPairInContact;
  55147. private _stepSimulation;
  55148. /**
  55149. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55150. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55151. * After the step the babylon meshes are set to the position of the physics imposters
  55152. * @param delta amount of time to step forward
  55153. * @param impostors array of imposters to update before/after the step
  55154. */
  55155. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55156. /**
  55157. * Update babylon mesh to match physics world object
  55158. * @param impostor imposter to match
  55159. */
  55160. private _afterSoftStep;
  55161. /**
  55162. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55163. * @param impostor imposter to match
  55164. */
  55165. private _ropeStep;
  55166. /**
  55167. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55168. * @param impostor imposter to match
  55169. */
  55170. private _softbodyOrClothStep;
  55171. private _tmpVector;
  55172. private _tmpMatrix;
  55173. /**
  55174. * Applies an impulse on the imposter
  55175. * @param impostor imposter to apply impulse to
  55176. * @param force amount of force to be applied to the imposter
  55177. * @param contactPoint the location to apply the impulse on the imposter
  55178. */
  55179. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55180. /**
  55181. * Applies a force on the imposter
  55182. * @param impostor imposter to apply force
  55183. * @param force amount of force to be applied to the imposter
  55184. * @param contactPoint the location to apply the force on the imposter
  55185. */
  55186. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55187. /**
  55188. * Creates a physics body using the plugin
  55189. * @param impostor the imposter to create the physics body on
  55190. */
  55191. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55192. /**
  55193. * Removes the physics body from the imposter and disposes of the body's memory
  55194. * @param impostor imposter to remove the physics body from
  55195. */
  55196. removePhysicsBody(impostor: PhysicsImpostor): void;
  55197. /**
  55198. * Generates a joint
  55199. * @param impostorJoint the imposter joint to create the joint with
  55200. */
  55201. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55202. /**
  55203. * Removes a joint
  55204. * @param impostorJoint the imposter joint to remove the joint from
  55205. */
  55206. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55207. private _addMeshVerts;
  55208. /**
  55209. * Initialise the soft body vertices to match its object's (mesh) vertices
  55210. * Softbody vertices (nodes) are in world space and to match this
  55211. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55212. * @param impostor to create the softbody for
  55213. */
  55214. private _softVertexData;
  55215. /**
  55216. * Create an impostor's soft body
  55217. * @param impostor to create the softbody for
  55218. */
  55219. private _createSoftbody;
  55220. /**
  55221. * Create cloth for an impostor
  55222. * @param impostor to create the softbody for
  55223. */
  55224. private _createCloth;
  55225. /**
  55226. * Create rope for an impostor
  55227. * @param impostor to create the softbody for
  55228. */
  55229. private _createRope;
  55230. /**
  55231. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55232. * @param impostor to create the custom physics shape for
  55233. */
  55234. private _createCustom;
  55235. private _addHullVerts;
  55236. private _createShape;
  55237. /**
  55238. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55239. * @param impostor imposter containing the physics body and babylon object
  55240. */
  55241. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55242. /**
  55243. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55244. * @param impostor imposter containing the physics body and babylon object
  55245. * @param newPosition new position
  55246. * @param newRotation new rotation
  55247. */
  55248. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55249. /**
  55250. * If this plugin is supported
  55251. * @returns true if its supported
  55252. */
  55253. isSupported(): boolean;
  55254. /**
  55255. * Sets the linear velocity of the physics body
  55256. * @param impostor imposter to set the velocity on
  55257. * @param velocity velocity to set
  55258. */
  55259. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55260. /**
  55261. * Sets the angular velocity of the physics body
  55262. * @param impostor imposter to set the velocity on
  55263. * @param velocity velocity to set
  55264. */
  55265. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55266. /**
  55267. * gets the linear velocity
  55268. * @param impostor imposter to get linear velocity from
  55269. * @returns linear velocity
  55270. */
  55271. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55272. /**
  55273. * gets the angular velocity
  55274. * @param impostor imposter to get angular velocity from
  55275. * @returns angular velocity
  55276. */
  55277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55278. /**
  55279. * Sets the mass of physics body
  55280. * @param impostor imposter to set the mass on
  55281. * @param mass mass to set
  55282. */
  55283. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55284. /**
  55285. * Gets the mass of the physics body
  55286. * @param impostor imposter to get the mass from
  55287. * @returns mass
  55288. */
  55289. getBodyMass(impostor: PhysicsImpostor): number;
  55290. /**
  55291. * Gets friction of the impostor
  55292. * @param impostor impostor to get friction from
  55293. * @returns friction value
  55294. */
  55295. getBodyFriction(impostor: PhysicsImpostor): number;
  55296. /**
  55297. * Sets friction of the impostor
  55298. * @param impostor impostor to set friction on
  55299. * @param friction friction value
  55300. */
  55301. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55302. /**
  55303. * Gets restitution of the impostor
  55304. * @param impostor impostor to get restitution from
  55305. * @returns restitution value
  55306. */
  55307. getBodyRestitution(impostor: PhysicsImpostor): number;
  55308. /**
  55309. * Sets resitution of the impostor
  55310. * @param impostor impostor to set resitution on
  55311. * @param restitution resitution value
  55312. */
  55313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55314. /**
  55315. * Gets pressure inside the impostor
  55316. * @param impostor impostor to get pressure from
  55317. * @returns pressure value
  55318. */
  55319. getBodyPressure(impostor: PhysicsImpostor): number;
  55320. /**
  55321. * Sets pressure inside a soft body impostor
  55322. * Cloth and rope must remain 0 pressure
  55323. * @param impostor impostor to set pressure on
  55324. * @param pressure pressure value
  55325. */
  55326. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55327. /**
  55328. * Gets stiffness of the impostor
  55329. * @param impostor impostor to get stiffness from
  55330. * @returns pressure value
  55331. */
  55332. getBodyStiffness(impostor: PhysicsImpostor): number;
  55333. /**
  55334. * Sets stiffness of the impostor
  55335. * @param impostor impostor to set stiffness on
  55336. * @param stiffness stiffness value from 0 to 1
  55337. */
  55338. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55339. /**
  55340. * Gets velocityIterations of the impostor
  55341. * @param impostor impostor to get velocity iterations from
  55342. * @returns velocityIterations value
  55343. */
  55344. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55345. /**
  55346. * Sets velocityIterations of the impostor
  55347. * @param impostor impostor to set velocity iterations on
  55348. * @param velocityIterations velocityIterations value
  55349. */
  55350. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55351. /**
  55352. * Gets positionIterations of the impostor
  55353. * @param impostor impostor to get position iterations from
  55354. * @returns positionIterations value
  55355. */
  55356. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55357. /**
  55358. * Sets positionIterations of the impostor
  55359. * @param impostor impostor to set position on
  55360. * @param positionIterations positionIterations value
  55361. */
  55362. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55363. /**
  55364. * Append an anchor to a cloth object
  55365. * @param impostor is the cloth impostor to add anchor to
  55366. * @param otherImpostor is the rigid impostor to anchor to
  55367. * @param width ratio across width from 0 to 1
  55368. * @param height ratio up height from 0 to 1
  55369. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55370. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55371. */
  55372. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55373. /**
  55374. * Append an hook to a rope object
  55375. * @param impostor is the rope impostor to add hook to
  55376. * @param otherImpostor is the rigid impostor to hook to
  55377. * @param length ratio along the rope from 0 to 1
  55378. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55379. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55380. */
  55381. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55382. /**
  55383. * Sleeps the physics body and stops it from being active
  55384. * @param impostor impostor to sleep
  55385. */
  55386. sleepBody(impostor: PhysicsImpostor): void;
  55387. /**
  55388. * Activates the physics body
  55389. * @param impostor impostor to activate
  55390. */
  55391. wakeUpBody(impostor: PhysicsImpostor): void;
  55392. /**
  55393. * Updates the distance parameters of the joint
  55394. * @param joint joint to update
  55395. * @param maxDistance maximum distance of the joint
  55396. * @param minDistance minimum distance of the joint
  55397. */
  55398. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55399. /**
  55400. * Sets a motor on the joint
  55401. * @param joint joint to set motor on
  55402. * @param speed speed of the motor
  55403. * @param maxForce maximum force of the motor
  55404. * @param motorIndex index of the motor
  55405. */
  55406. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55407. /**
  55408. * Sets the motors limit
  55409. * @param joint joint to set limit on
  55410. * @param upperLimit upper limit
  55411. * @param lowerLimit lower limit
  55412. */
  55413. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55414. /**
  55415. * Syncs the position and rotation of a mesh with the impostor
  55416. * @param mesh mesh to sync
  55417. * @param impostor impostor to update the mesh with
  55418. */
  55419. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55420. /**
  55421. * Gets the radius of the impostor
  55422. * @param impostor impostor to get radius from
  55423. * @returns the radius
  55424. */
  55425. getRadius(impostor: PhysicsImpostor): number;
  55426. /**
  55427. * Gets the box size of the impostor
  55428. * @param impostor impostor to get box size from
  55429. * @param result the resulting box size
  55430. */
  55431. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55432. /**
  55433. * Disposes of the impostor
  55434. */
  55435. dispose(): void;
  55436. /**
  55437. * Does a raycast in the physics world
  55438. * @param from when should the ray start?
  55439. * @param to when should the ray end?
  55440. * @returns PhysicsRaycastResult
  55441. */
  55442. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55443. }
  55444. }
  55445. declare module BABYLON {
  55446. interface AbstractScene {
  55447. /**
  55448. * The list of reflection probes added to the scene
  55449. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55450. */
  55451. reflectionProbes: Array<ReflectionProbe>;
  55452. /**
  55453. * Removes the given reflection probe from this scene.
  55454. * @param toRemove The reflection probe to remove
  55455. * @returns The index of the removed reflection probe
  55456. */
  55457. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55458. /**
  55459. * Adds the given reflection probe to this scene.
  55460. * @param newReflectionProbe The reflection probe to add
  55461. */
  55462. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55463. }
  55464. /**
  55465. * Class used to generate realtime reflection / refraction cube textures
  55466. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55467. */
  55468. export class ReflectionProbe {
  55469. /** defines the name of the probe */
  55470. name: string;
  55471. private _scene;
  55472. private _renderTargetTexture;
  55473. private _projectionMatrix;
  55474. private _viewMatrix;
  55475. private _target;
  55476. private _add;
  55477. private _attachedMesh;
  55478. private _invertYAxis;
  55479. /** Gets or sets probe position (center of the cube map) */
  55480. position: Vector3;
  55481. /**
  55482. * Creates a new reflection probe
  55483. * @param name defines the name of the probe
  55484. * @param size defines the texture resolution (for each face)
  55485. * @param scene defines the hosting scene
  55486. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55487. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55488. */
  55489. constructor(
  55490. /** defines the name of the probe */
  55491. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55492. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55493. get samples(): number;
  55494. set samples(value: number);
  55495. /** Gets or sets the refresh rate to use (on every frame by default) */
  55496. get refreshRate(): number;
  55497. set refreshRate(value: number);
  55498. /**
  55499. * Gets the hosting scene
  55500. * @returns a Scene
  55501. */
  55502. getScene(): Scene;
  55503. /** Gets the internal CubeTexture used to render to */
  55504. get cubeTexture(): RenderTargetTexture;
  55505. /** Gets the list of meshes to render */
  55506. get renderList(): Nullable<AbstractMesh[]>;
  55507. /**
  55508. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55509. * @param mesh defines the mesh to attach to
  55510. */
  55511. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55512. /**
  55513. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55514. * @param renderingGroupId The rendering group id corresponding to its index
  55515. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55516. */
  55517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55518. /**
  55519. * Clean all associated resources
  55520. */
  55521. dispose(): void;
  55522. /**
  55523. * Converts the reflection probe information to a readable string for debug purpose.
  55524. * @param fullDetails Supports for multiple levels of logging within scene loading
  55525. * @returns the human readable reflection probe info
  55526. */
  55527. toString(fullDetails?: boolean): string;
  55528. /**
  55529. * Get the class name of the relfection probe.
  55530. * @returns "ReflectionProbe"
  55531. */
  55532. getClassName(): string;
  55533. /**
  55534. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55535. * @returns The JSON representation of the texture
  55536. */
  55537. serialize(): any;
  55538. /**
  55539. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55540. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55541. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55542. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55543. * @returns The parsed reflection probe if successful
  55544. */
  55545. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55546. }
  55547. }
  55548. declare module BABYLON {
  55549. /** @hidden */
  55550. export var _BabylonLoaderRegistered: boolean;
  55551. /**
  55552. * Helps setting up some configuration for the babylon file loader.
  55553. */
  55554. export class BabylonFileLoaderConfiguration {
  55555. /**
  55556. * The loader does not allow injecting custom physix engine into the plugins.
  55557. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55558. * So you could set this variable to your engine import to make it work.
  55559. */
  55560. static LoaderInjectedPhysicsEngine: any;
  55561. }
  55562. }
  55563. declare module BABYLON {
  55564. /**
  55565. * The Physically based simple base material of BJS.
  55566. *
  55567. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55568. * It is used as the base class for both the specGloss and metalRough conventions.
  55569. */
  55570. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55571. /**
  55572. * Number of Simultaneous lights allowed on the material.
  55573. */
  55574. maxSimultaneousLights: number;
  55575. /**
  55576. * If sets to true, disables all the lights affecting the material.
  55577. */
  55578. disableLighting: boolean;
  55579. /**
  55580. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55581. */
  55582. environmentTexture: BaseTexture;
  55583. /**
  55584. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55585. */
  55586. invertNormalMapX: boolean;
  55587. /**
  55588. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55589. */
  55590. invertNormalMapY: boolean;
  55591. /**
  55592. * Normal map used in the model.
  55593. */
  55594. normalTexture: BaseTexture;
  55595. /**
  55596. * Emissivie color used to self-illuminate the model.
  55597. */
  55598. emissiveColor: Color3;
  55599. /**
  55600. * Emissivie texture used to self-illuminate the model.
  55601. */
  55602. emissiveTexture: BaseTexture;
  55603. /**
  55604. * Occlusion Channel Strenght.
  55605. */
  55606. occlusionStrength: number;
  55607. /**
  55608. * Occlusion Texture of the material (adding extra occlusion effects).
  55609. */
  55610. occlusionTexture: BaseTexture;
  55611. /**
  55612. * Defines the alpha limits in alpha test mode.
  55613. */
  55614. alphaCutOff: number;
  55615. /**
  55616. * Gets the current double sided mode.
  55617. */
  55618. get doubleSided(): boolean;
  55619. /**
  55620. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55621. */
  55622. set doubleSided(value: boolean);
  55623. /**
  55624. * Stores the pre-calculated light information of a mesh in a texture.
  55625. */
  55626. lightmapTexture: BaseTexture;
  55627. /**
  55628. * If true, the light map contains occlusion information instead of lighting info.
  55629. */
  55630. useLightmapAsShadowmap: boolean;
  55631. /**
  55632. * Instantiates a new PBRMaterial instance.
  55633. *
  55634. * @param name The material name
  55635. * @param scene The scene the material will be use in.
  55636. */
  55637. constructor(name: string, scene: Scene);
  55638. getClassName(): string;
  55639. }
  55640. }
  55641. declare module BABYLON {
  55642. /**
  55643. * The PBR material of BJS following the metal roughness convention.
  55644. *
  55645. * This fits to the PBR convention in the GLTF definition:
  55646. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55647. */
  55648. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55649. /**
  55650. * The base color has two different interpretations depending on the value of metalness.
  55651. * When the material is a metal, the base color is the specific measured reflectance value
  55652. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55653. * of the material.
  55654. */
  55655. baseColor: Color3;
  55656. /**
  55657. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55658. * well as opacity information in the alpha channel.
  55659. */
  55660. baseTexture: BaseTexture;
  55661. /**
  55662. * Specifies the metallic scalar value of the material.
  55663. * Can also be used to scale the metalness values of the metallic texture.
  55664. */
  55665. metallic: number;
  55666. /**
  55667. * Specifies the roughness scalar value of the material.
  55668. * Can also be used to scale the roughness values of the metallic texture.
  55669. */
  55670. roughness: number;
  55671. /**
  55672. * Texture containing both the metallic value in the B channel and the
  55673. * roughness value in the G channel to keep better precision.
  55674. */
  55675. metallicRoughnessTexture: BaseTexture;
  55676. /**
  55677. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55678. *
  55679. * @param name The material name
  55680. * @param scene The scene the material will be use in.
  55681. */
  55682. constructor(name: string, scene: Scene);
  55683. /**
  55684. * Return the currrent class name of the material.
  55685. */
  55686. getClassName(): string;
  55687. /**
  55688. * Makes a duplicate of the current material.
  55689. * @param name - name to use for the new material.
  55690. */
  55691. clone(name: string): PBRMetallicRoughnessMaterial;
  55692. /**
  55693. * Serialize the material to a parsable JSON object.
  55694. */
  55695. serialize(): any;
  55696. /**
  55697. * Parses a JSON object correponding to the serialize function.
  55698. */
  55699. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55700. }
  55701. }
  55702. declare module BABYLON {
  55703. /**
  55704. * The PBR material of BJS following the specular glossiness convention.
  55705. *
  55706. * This fits to the PBR convention in the GLTF definition:
  55707. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55708. */
  55709. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55710. /**
  55711. * Specifies the diffuse color of the material.
  55712. */
  55713. diffuseColor: Color3;
  55714. /**
  55715. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55716. * channel.
  55717. */
  55718. diffuseTexture: BaseTexture;
  55719. /**
  55720. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55721. */
  55722. specularColor: Color3;
  55723. /**
  55724. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55725. */
  55726. glossiness: number;
  55727. /**
  55728. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55729. */
  55730. specularGlossinessTexture: BaseTexture;
  55731. /**
  55732. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55733. *
  55734. * @param name The material name
  55735. * @param scene The scene the material will be use in.
  55736. */
  55737. constructor(name: string, scene: Scene);
  55738. /**
  55739. * Return the currrent class name of the material.
  55740. */
  55741. getClassName(): string;
  55742. /**
  55743. * Makes a duplicate of the current material.
  55744. * @param name - name to use for the new material.
  55745. */
  55746. clone(name: string): PBRSpecularGlossinessMaterial;
  55747. /**
  55748. * Serialize the material to a parsable JSON object.
  55749. */
  55750. serialize(): any;
  55751. /**
  55752. * Parses a JSON object correponding to the serialize function.
  55753. */
  55754. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55755. }
  55756. }
  55757. declare module BABYLON {
  55758. /**
  55759. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55760. * It can help converting any input color in a desired output one. This can then be used to create effects
  55761. * from sepia, black and white to sixties or futuristic rendering...
  55762. *
  55763. * The only supported format is currently 3dl.
  55764. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55765. */
  55766. export class ColorGradingTexture extends BaseTexture {
  55767. /**
  55768. * The current texture matrix. (will always be identity in color grading texture)
  55769. */
  55770. private _textureMatrix;
  55771. /**
  55772. * The texture URL.
  55773. */
  55774. url: string;
  55775. /**
  55776. * Empty line regex stored for GC.
  55777. */
  55778. private static _noneEmptyLineRegex;
  55779. private _engine;
  55780. /**
  55781. * Instantiates a ColorGradingTexture from the following parameters.
  55782. *
  55783. * @param url The location of the color gradind data (currently only supporting 3dl)
  55784. * @param scene The scene the texture will be used in
  55785. */
  55786. constructor(url: string, scene: Scene);
  55787. /**
  55788. * Returns the texture matrix used in most of the material.
  55789. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55790. */
  55791. getTextureMatrix(): Matrix;
  55792. /**
  55793. * Occurs when the file being loaded is a .3dl LUT file.
  55794. */
  55795. private load3dlTexture;
  55796. /**
  55797. * Starts the loading process of the texture.
  55798. */
  55799. private loadTexture;
  55800. /**
  55801. * Clones the color gradind texture.
  55802. */
  55803. clone(): ColorGradingTexture;
  55804. /**
  55805. * Called during delayed load for textures.
  55806. */
  55807. delayLoad(): void;
  55808. /**
  55809. * Parses a color grading texture serialized by Babylon.
  55810. * @param parsedTexture The texture information being parsedTexture
  55811. * @param scene The scene to load the texture in
  55812. * @param rootUrl The root url of the data assets to load
  55813. * @return A color gradind texture
  55814. */
  55815. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55816. /**
  55817. * Serializes the LUT texture to json format.
  55818. */
  55819. serialize(): any;
  55820. }
  55821. }
  55822. declare module BABYLON {
  55823. /**
  55824. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55825. */
  55826. export class EquiRectangularCubeTexture extends BaseTexture {
  55827. /** The six faces of the cube. */
  55828. private static _FacesMapping;
  55829. private _noMipmap;
  55830. private _onLoad;
  55831. private _onError;
  55832. /** The size of the cubemap. */
  55833. private _size;
  55834. /** The buffer of the image. */
  55835. private _buffer;
  55836. /** The width of the input image. */
  55837. private _width;
  55838. /** The height of the input image. */
  55839. private _height;
  55840. /** The URL to the image. */
  55841. url: string;
  55842. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55843. coordinatesMode: number;
  55844. /**
  55845. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55846. * @param url The location of the image
  55847. * @param scene The scene the texture will be used in
  55848. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55849. * @param noMipmap Forces to not generate the mipmap if true
  55850. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55851. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55852. * @param onLoad — defines a callback called when texture is loaded
  55853. * @param onError — defines a callback called if there is an error
  55854. */
  55855. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55856. /**
  55857. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55858. */
  55859. private loadImage;
  55860. /**
  55861. * Convert the image buffer into a cubemap and create a CubeTexture.
  55862. */
  55863. private loadTexture;
  55864. /**
  55865. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55866. * @param buffer The ArrayBuffer that should be converted.
  55867. * @returns The buffer as Float32Array.
  55868. */
  55869. private getFloat32ArrayFromArrayBuffer;
  55870. /**
  55871. * Get the current class name of the texture useful for serialization or dynamic coding.
  55872. * @returns "EquiRectangularCubeTexture"
  55873. */
  55874. getClassName(): string;
  55875. /**
  55876. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55877. * @returns A clone of the current EquiRectangularCubeTexture.
  55878. */
  55879. clone(): EquiRectangularCubeTexture;
  55880. }
  55881. }
  55882. declare module BABYLON {
  55883. /**
  55884. * Based on jsTGALoader - Javascript loader for TGA file
  55885. * By Vincent Thibault
  55886. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55887. */
  55888. export class TGATools {
  55889. private static _TYPE_INDEXED;
  55890. private static _TYPE_RGB;
  55891. private static _TYPE_GREY;
  55892. private static _TYPE_RLE_INDEXED;
  55893. private static _TYPE_RLE_RGB;
  55894. private static _TYPE_RLE_GREY;
  55895. private static _ORIGIN_MASK;
  55896. private static _ORIGIN_SHIFT;
  55897. private static _ORIGIN_BL;
  55898. private static _ORIGIN_BR;
  55899. private static _ORIGIN_UL;
  55900. private static _ORIGIN_UR;
  55901. /**
  55902. * Gets the header of a TGA file
  55903. * @param data defines the TGA data
  55904. * @returns the header
  55905. */
  55906. static GetTGAHeader(data: Uint8Array): any;
  55907. /**
  55908. * Uploads TGA content to a Babylon Texture
  55909. * @hidden
  55910. */
  55911. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55912. /** @hidden */
  55913. 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;
  55914. /** @hidden */
  55915. 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;
  55916. /** @hidden */
  55917. 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;
  55918. /** @hidden */
  55919. 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;
  55920. /** @hidden */
  55921. 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;
  55922. /** @hidden */
  55923. 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;
  55924. }
  55925. }
  55926. declare module BABYLON {
  55927. /**
  55928. * Implementation of the TGA Texture Loader.
  55929. * @hidden
  55930. */
  55931. export class _TGATextureLoader implements IInternalTextureLoader {
  55932. /**
  55933. * Defines wether the loader supports cascade loading the different faces.
  55934. */
  55935. readonly supportCascades: boolean;
  55936. /**
  55937. * This returns if the loader support the current file information.
  55938. * @param extension defines the file extension of the file being loaded
  55939. * @returns true if the loader can load the specified file
  55940. */
  55941. canLoad(extension: string): boolean;
  55942. /**
  55943. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55944. * @param data contains the texture data
  55945. * @param texture defines the BabylonJS internal texture
  55946. * @param createPolynomials will be true if polynomials have been requested
  55947. * @param onLoad defines the callback to trigger once the texture is ready
  55948. * @param onError defines the callback to trigger in case of error
  55949. */
  55950. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55951. /**
  55952. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55953. * @param data contains the texture data
  55954. * @param texture defines the BabylonJS internal texture
  55955. * @param callback defines the method to call once ready to upload
  55956. */
  55957. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55958. }
  55959. }
  55960. declare module BABYLON {
  55961. /**
  55962. * Info about the .basis files
  55963. */
  55964. class BasisFileInfo {
  55965. /**
  55966. * If the file has alpha
  55967. */
  55968. hasAlpha: boolean;
  55969. /**
  55970. * Info about each image of the basis file
  55971. */
  55972. images: Array<{
  55973. levels: Array<{
  55974. width: number;
  55975. height: number;
  55976. transcodedPixels: ArrayBufferView;
  55977. }>;
  55978. }>;
  55979. }
  55980. /**
  55981. * Result of transcoding a basis file
  55982. */
  55983. class TranscodeResult {
  55984. /**
  55985. * Info about the .basis file
  55986. */
  55987. fileInfo: BasisFileInfo;
  55988. /**
  55989. * Format to use when loading the file
  55990. */
  55991. format: number;
  55992. }
  55993. /**
  55994. * Configuration options for the Basis transcoder
  55995. */
  55996. export class BasisTranscodeConfiguration {
  55997. /**
  55998. * Supported compression formats used to determine the supported output format of the transcoder
  55999. */
  56000. supportedCompressionFormats?: {
  56001. /**
  56002. * etc1 compression format
  56003. */
  56004. etc1?: boolean;
  56005. /**
  56006. * s3tc compression format
  56007. */
  56008. s3tc?: boolean;
  56009. /**
  56010. * pvrtc compression format
  56011. */
  56012. pvrtc?: boolean;
  56013. /**
  56014. * etc2 compression format
  56015. */
  56016. etc2?: boolean;
  56017. };
  56018. /**
  56019. * If mipmap levels should be loaded for transcoded images (Default: true)
  56020. */
  56021. loadMipmapLevels?: boolean;
  56022. /**
  56023. * Index of a single image to load (Default: all images)
  56024. */
  56025. loadSingleImage?: number;
  56026. }
  56027. /**
  56028. * Used to load .Basis files
  56029. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56030. */
  56031. export class BasisTools {
  56032. private static _IgnoreSupportedFormats;
  56033. /**
  56034. * URL to use when loading the basis transcoder
  56035. */
  56036. static JSModuleURL: string;
  56037. /**
  56038. * URL to use when loading the wasm module for the transcoder
  56039. */
  56040. static WasmModuleURL: string;
  56041. /**
  56042. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56043. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56044. * @returns internal format corresponding to the Basis format
  56045. */
  56046. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56047. private static _WorkerPromise;
  56048. private static _Worker;
  56049. private static _actionId;
  56050. private static _CreateWorkerAsync;
  56051. /**
  56052. * Transcodes a loaded image file to compressed pixel data
  56053. * @param data image data to transcode
  56054. * @param config configuration options for the transcoding
  56055. * @returns a promise resulting in the transcoded image
  56056. */
  56057. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56058. /**
  56059. * Loads a texture from the transcode result
  56060. * @param texture texture load to
  56061. * @param transcodeResult the result of transcoding the basis file to load from
  56062. */
  56063. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56064. }
  56065. }
  56066. declare module BABYLON {
  56067. /**
  56068. * Loader for .basis file format
  56069. */
  56070. export class _BasisTextureLoader implements IInternalTextureLoader {
  56071. /**
  56072. * Defines whether the loader supports cascade loading the different faces.
  56073. */
  56074. readonly supportCascades: boolean;
  56075. /**
  56076. * This returns if the loader support the current file information.
  56077. * @param extension defines the file extension of the file being loaded
  56078. * @returns true if the loader can load the specified file
  56079. */
  56080. canLoad(extension: string): boolean;
  56081. /**
  56082. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56083. * @param data contains the texture data
  56084. * @param texture defines the BabylonJS internal texture
  56085. * @param createPolynomials will be true if polynomials have been requested
  56086. * @param onLoad defines the callback to trigger once the texture is ready
  56087. * @param onError defines the callback to trigger in case of error
  56088. */
  56089. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56090. /**
  56091. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56092. * @param data contains the texture data
  56093. * @param texture defines the BabylonJS internal texture
  56094. * @param callback defines the method to call once ready to upload
  56095. */
  56096. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56097. }
  56098. }
  56099. declare module BABYLON {
  56100. /**
  56101. * 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.
  56102. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56104. */
  56105. export class CustomProceduralTexture extends ProceduralTexture {
  56106. private _animate;
  56107. private _time;
  56108. private _config;
  56109. private _texturePath;
  56110. /**
  56111. * Instantiates a new Custom Procedural Texture.
  56112. * 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.
  56113. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56115. * @param name Define the name of the texture
  56116. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56117. * @param size Define the size of the texture to create
  56118. * @param scene Define the scene the texture belongs to
  56119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56120. * @param generateMipMaps Define if the texture should creates mip maps or not
  56121. */
  56122. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56123. private _loadJson;
  56124. /**
  56125. * Is the texture ready to be used ? (rendered at least once)
  56126. * @returns true if ready, otherwise, false.
  56127. */
  56128. isReady(): boolean;
  56129. /**
  56130. * Render the texture to its associated render target.
  56131. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56132. */
  56133. render(useCameraPostProcess?: boolean): void;
  56134. /**
  56135. * Update the list of dependant textures samplers in the shader.
  56136. */
  56137. updateTextures(): void;
  56138. /**
  56139. * Update the uniform values of the procedural texture in the shader.
  56140. */
  56141. updateShaderUniforms(): void;
  56142. /**
  56143. * Define if the texture animates or not.
  56144. */
  56145. get animate(): boolean;
  56146. set animate(value: boolean);
  56147. }
  56148. }
  56149. declare module BABYLON {
  56150. /** @hidden */
  56151. export var noisePixelShader: {
  56152. name: string;
  56153. shader: string;
  56154. };
  56155. }
  56156. declare module BABYLON {
  56157. /**
  56158. * Class used to generate noise procedural textures
  56159. */
  56160. export class NoiseProceduralTexture extends ProceduralTexture {
  56161. private _time;
  56162. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56163. brightness: number;
  56164. /** Defines the number of octaves to process */
  56165. octaves: number;
  56166. /** Defines the level of persistence (0.8 by default) */
  56167. persistence: number;
  56168. /** Gets or sets animation speed factor (default is 1) */
  56169. animationSpeedFactor: number;
  56170. /**
  56171. * Creates a new NoiseProceduralTexture
  56172. * @param name defines the name fo the texture
  56173. * @param size defines the size of the texture (default is 256)
  56174. * @param scene defines the hosting scene
  56175. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56176. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56177. */
  56178. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56179. private _updateShaderUniforms;
  56180. protected _getDefines(): string;
  56181. /** Generate the current state of the procedural texture */
  56182. render(useCameraPostProcess?: boolean): void;
  56183. /**
  56184. * Serializes this noise procedural texture
  56185. * @returns a serialized noise procedural texture object
  56186. */
  56187. serialize(): any;
  56188. /**
  56189. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56190. * @param parsedTexture defines parsed texture data
  56191. * @param scene defines the current scene
  56192. * @param rootUrl defines the root URL containing noise procedural texture information
  56193. * @returns a parsed NoiseProceduralTexture
  56194. */
  56195. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56196. }
  56197. }
  56198. declare module BABYLON {
  56199. /**
  56200. * Raw cube texture where the raw buffers are passed in
  56201. */
  56202. export class RawCubeTexture extends CubeTexture {
  56203. /**
  56204. * Creates a cube texture where the raw buffers are passed in.
  56205. * @param scene defines the scene the texture is attached to
  56206. * @param data defines the array of data to use to create each face
  56207. * @param size defines the size of the textures
  56208. * @param format defines the format of the data
  56209. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56210. * @param generateMipMaps defines if the engine should generate the mip levels
  56211. * @param invertY defines if data must be stored with Y axis inverted
  56212. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56213. * @param compression defines the compression used (null by default)
  56214. */
  56215. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56216. /**
  56217. * Updates the raw cube texture.
  56218. * @param data defines the data to store
  56219. * @param format defines the data format
  56220. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56221. * @param invertY defines if data must be stored with Y axis inverted
  56222. * @param compression defines the compression used (null by default)
  56223. * @param level defines which level of the texture to update
  56224. */
  56225. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56226. /**
  56227. * Updates a raw cube texture with RGBD encoded data.
  56228. * @param data defines the array of data [mipmap][face] to use to create each face
  56229. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56230. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56231. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56232. * @returns a promsie that resolves when the operation is complete
  56233. */
  56234. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56235. /**
  56236. * Clones the raw cube texture.
  56237. * @return a new cube texture
  56238. */
  56239. clone(): CubeTexture;
  56240. /** @hidden */
  56241. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56242. }
  56243. }
  56244. declare module BABYLON {
  56245. /**
  56246. * Class used to store 3D textures containing user data
  56247. */
  56248. export class RawTexture3D extends Texture {
  56249. /** Gets or sets the texture format to use */
  56250. format: number;
  56251. private _engine;
  56252. /**
  56253. * Create a new RawTexture3D
  56254. * @param data defines the data of the texture
  56255. * @param width defines the width of the texture
  56256. * @param height defines the height of the texture
  56257. * @param depth defines the depth of the texture
  56258. * @param format defines the texture format to use
  56259. * @param scene defines the hosting scene
  56260. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56261. * @param invertY defines if texture must be stored with Y axis inverted
  56262. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56263. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56264. */
  56265. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56266. /** Gets or sets the texture format to use */
  56267. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56268. /**
  56269. * Update the texture with new data
  56270. * @param data defines the data to store in the texture
  56271. */
  56272. update(data: ArrayBufferView): void;
  56273. }
  56274. }
  56275. declare module BABYLON {
  56276. /**
  56277. * Class used to store 2D array textures containing user data
  56278. */
  56279. export class RawTexture2DArray extends Texture {
  56280. /** Gets or sets the texture format to use */
  56281. format: number;
  56282. private _engine;
  56283. /**
  56284. * Create a new RawTexture2DArray
  56285. * @param data defines the data of the texture
  56286. * @param width defines the width of the texture
  56287. * @param height defines the height of the texture
  56288. * @param depth defines the number of layers of the texture
  56289. * @param format defines the texture format to use
  56290. * @param scene defines the hosting scene
  56291. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56292. * @param invertY defines if texture must be stored with Y axis inverted
  56293. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56294. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56295. */
  56296. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56297. /** Gets or sets the texture format to use */
  56298. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56299. /**
  56300. * Update the texture with new data
  56301. * @param data defines the data to store in the texture
  56302. */
  56303. update(data: ArrayBufferView): void;
  56304. }
  56305. }
  56306. declare module BABYLON {
  56307. /**
  56308. * Creates a refraction texture used by refraction channel of the standard material.
  56309. * It is like a mirror but to see through a material.
  56310. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56311. */
  56312. export class RefractionTexture extends RenderTargetTexture {
  56313. /**
  56314. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56315. * 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.
  56316. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56317. */
  56318. refractionPlane: Plane;
  56319. /**
  56320. * Define how deep under the surface we should see.
  56321. */
  56322. depth: number;
  56323. /**
  56324. * Creates a refraction texture used by refraction channel of the standard material.
  56325. * It is like a mirror but to see through a material.
  56326. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56327. * @param name Define the texture name
  56328. * @param size Define the size of the underlying texture
  56329. * @param scene Define the scene the refraction belongs to
  56330. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56331. */
  56332. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56333. /**
  56334. * Clone the refraction texture.
  56335. * @returns the cloned texture
  56336. */
  56337. clone(): RefractionTexture;
  56338. /**
  56339. * Serialize the texture to a JSON representation you could use in Parse later on
  56340. * @returns the serialized JSON representation
  56341. */
  56342. serialize(): any;
  56343. }
  56344. }
  56345. declare module BABYLON {
  56346. /**
  56347. * Defines the options related to the creation of an HtmlElementTexture
  56348. */
  56349. export interface IHtmlElementTextureOptions {
  56350. /**
  56351. * Defines wether mip maps should be created or not.
  56352. */
  56353. generateMipMaps?: boolean;
  56354. /**
  56355. * Defines the sampling mode of the texture.
  56356. */
  56357. samplingMode?: number;
  56358. /**
  56359. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56360. */
  56361. engine: Nullable<ThinEngine>;
  56362. /**
  56363. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56364. */
  56365. scene: Nullable<Scene>;
  56366. }
  56367. /**
  56368. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56369. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56370. * is automatically managed.
  56371. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56372. * in your application.
  56373. *
  56374. * As the update is not automatic, you need to call them manually.
  56375. */
  56376. export class HtmlElementTexture extends BaseTexture {
  56377. /**
  56378. * The texture URL.
  56379. */
  56380. element: HTMLVideoElement | HTMLCanvasElement;
  56381. private static readonly DefaultOptions;
  56382. private _textureMatrix;
  56383. private _engine;
  56384. private _isVideo;
  56385. private _generateMipMaps;
  56386. private _samplingMode;
  56387. /**
  56388. * Instantiates a HtmlElementTexture from the following parameters.
  56389. *
  56390. * @param name Defines the name of the texture
  56391. * @param element Defines the video or canvas the texture is filled with
  56392. * @param options Defines the other none mandatory texture creation options
  56393. */
  56394. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56395. private _createInternalTexture;
  56396. /**
  56397. * Returns the texture matrix used in most of the material.
  56398. */
  56399. getTextureMatrix(): Matrix;
  56400. /**
  56401. * Updates the content of the texture.
  56402. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56403. */
  56404. update(invertY?: Nullable<boolean>): void;
  56405. }
  56406. }
  56407. declare module BABYLON {
  56408. /**
  56409. * Defines the basic options interface of a TexturePacker Frame
  56410. */
  56411. export interface ITexturePackerFrame {
  56412. /**
  56413. * The frame ID
  56414. */
  56415. id: number;
  56416. /**
  56417. * The frames Scale
  56418. */
  56419. scale: Vector2;
  56420. /**
  56421. * The Frames offset
  56422. */
  56423. offset: Vector2;
  56424. }
  56425. /**
  56426. * This is a support class for frame Data on texture packer sets.
  56427. */
  56428. export class TexturePackerFrame implements ITexturePackerFrame {
  56429. /**
  56430. * The frame ID
  56431. */
  56432. id: number;
  56433. /**
  56434. * The frames Scale
  56435. */
  56436. scale: Vector2;
  56437. /**
  56438. * The Frames offset
  56439. */
  56440. offset: Vector2;
  56441. /**
  56442. * Initializes a texture package frame.
  56443. * @param id The numerical frame identifier
  56444. * @param scale Scalar Vector2 for UV frame
  56445. * @param offset Vector2 for the frame position in UV units.
  56446. * @returns TexturePackerFrame
  56447. */
  56448. constructor(id: number, scale: Vector2, offset: Vector2);
  56449. }
  56450. }
  56451. declare module BABYLON {
  56452. /**
  56453. * Defines the basic options interface of a TexturePacker
  56454. */
  56455. export interface ITexturePackerOptions {
  56456. /**
  56457. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56458. */
  56459. map?: string[];
  56460. /**
  56461. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56462. */
  56463. uvsIn?: string;
  56464. /**
  56465. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56466. */
  56467. uvsOut?: string;
  56468. /**
  56469. * number representing the layout style. Defaults to LAYOUT_STRIP
  56470. */
  56471. layout?: number;
  56472. /**
  56473. * number of columns if using custom column count layout(2). This defaults to 4.
  56474. */
  56475. colnum?: number;
  56476. /**
  56477. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56478. */
  56479. updateInputMeshes?: boolean;
  56480. /**
  56481. * boolean flag to dispose all the source textures. Defaults to true.
  56482. */
  56483. disposeSources?: boolean;
  56484. /**
  56485. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56486. */
  56487. fillBlanks?: boolean;
  56488. /**
  56489. * string value representing the context fill style color. Defaults to 'black'.
  56490. */
  56491. customFillColor?: string;
  56492. /**
  56493. * Width and Height Value of each Frame in the TexturePacker Sets
  56494. */
  56495. frameSize?: number;
  56496. /**
  56497. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56498. */
  56499. paddingRatio?: number;
  56500. /**
  56501. * Number that declares the fill method for the padding gutter.
  56502. */
  56503. paddingMode?: number;
  56504. /**
  56505. * If in SUBUV_COLOR padding mode what color to use.
  56506. */
  56507. paddingColor?: Color3 | Color4;
  56508. }
  56509. /**
  56510. * Defines the basic interface of a TexturePacker JSON File
  56511. */
  56512. export interface ITexturePackerJSON {
  56513. /**
  56514. * The frame ID
  56515. */
  56516. name: string;
  56517. /**
  56518. * The base64 channel data
  56519. */
  56520. sets: any;
  56521. /**
  56522. * The options of the Packer
  56523. */
  56524. options: ITexturePackerOptions;
  56525. /**
  56526. * The frame data of the Packer
  56527. */
  56528. frames: Array<number>;
  56529. }
  56530. /**
  56531. * This is a support class that generates a series of packed texture sets.
  56532. * @see https://doc.babylonjs.com/babylon101/materials
  56533. */
  56534. export class TexturePacker {
  56535. /** Packer Layout Constant 0 */
  56536. static readonly LAYOUT_STRIP: number;
  56537. /** Packer Layout Constant 1 */
  56538. static readonly LAYOUT_POWER2: number;
  56539. /** Packer Layout Constant 2 */
  56540. static readonly LAYOUT_COLNUM: number;
  56541. /** Packer Layout Constant 0 */
  56542. static readonly SUBUV_WRAP: number;
  56543. /** Packer Layout Constant 1 */
  56544. static readonly SUBUV_EXTEND: number;
  56545. /** Packer Layout Constant 2 */
  56546. static readonly SUBUV_COLOR: number;
  56547. /** The Name of the Texture Package */
  56548. name: string;
  56549. /** The scene scope of the TexturePacker */
  56550. scene: Scene;
  56551. /** The Meshes to target */
  56552. meshes: AbstractMesh[];
  56553. /** Arguments passed with the Constructor */
  56554. options: ITexturePackerOptions;
  56555. /** The promise that is started upon initialization */
  56556. promise: Nullable<Promise<TexturePacker | string>>;
  56557. /** The Container object for the channel sets that are generated */
  56558. sets: object;
  56559. /** The Container array for the frames that are generated */
  56560. frames: TexturePackerFrame[];
  56561. /** The expected number of textures the system is parsing. */
  56562. private _expecting;
  56563. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56564. private _paddingValue;
  56565. /**
  56566. * Initializes a texture package series from an array of meshes or a single mesh.
  56567. * @param name The name of the package
  56568. * @param meshes The target meshes to compose the package from
  56569. * @param options The arguments that texture packer should follow while building.
  56570. * @param scene The scene which the textures are scoped to.
  56571. * @returns TexturePacker
  56572. */
  56573. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56574. /**
  56575. * Starts the package process
  56576. * @param resolve The promises resolution function
  56577. * @returns TexturePacker
  56578. */
  56579. private _createFrames;
  56580. /**
  56581. * Calculates the Size of the Channel Sets
  56582. * @returns Vector2
  56583. */
  56584. private _calculateSize;
  56585. /**
  56586. * Calculates the UV data for the frames.
  56587. * @param baseSize the base frameSize
  56588. * @param padding the base frame padding
  56589. * @param dtSize size of the Dynamic Texture for that channel
  56590. * @param dtUnits is 1/dtSize
  56591. * @param update flag to update the input meshes
  56592. */
  56593. private _calculateMeshUVFrames;
  56594. /**
  56595. * Calculates the frames Offset.
  56596. * @param index of the frame
  56597. * @returns Vector2
  56598. */
  56599. private _getFrameOffset;
  56600. /**
  56601. * Updates a Mesh to the frame data
  56602. * @param mesh that is the target
  56603. * @param frameID or the frame index
  56604. */
  56605. private _updateMeshUV;
  56606. /**
  56607. * Updates a Meshes materials to use the texture packer channels
  56608. * @param m is the mesh to target
  56609. * @param force all channels on the packer to be set.
  56610. */
  56611. private _updateTextureReferences;
  56612. /**
  56613. * Public method to set a Mesh to a frame
  56614. * @param m that is the target
  56615. * @param frameID or the frame index
  56616. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56617. */
  56618. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56619. /**
  56620. * Starts the async promise to compile the texture packer.
  56621. * @returns Promise<void>
  56622. */
  56623. processAsync(): Promise<void>;
  56624. /**
  56625. * Disposes all textures associated with this packer
  56626. */
  56627. dispose(): void;
  56628. /**
  56629. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56630. * @param imageType is the image type to use.
  56631. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56632. */
  56633. download(imageType?: string, quality?: number): void;
  56634. /**
  56635. * Public method to load a texturePacker JSON file.
  56636. * @param data of the JSON file in string format.
  56637. */
  56638. updateFromJSON(data: string): void;
  56639. }
  56640. }
  56641. declare module BABYLON {
  56642. /**
  56643. * Enum used to define the target of a block
  56644. */
  56645. export enum NodeMaterialBlockTargets {
  56646. /** Vertex shader */
  56647. Vertex = 1,
  56648. /** Fragment shader */
  56649. Fragment = 2,
  56650. /** Neutral */
  56651. Neutral = 4,
  56652. /** Vertex and Fragment */
  56653. VertexAndFragment = 3
  56654. }
  56655. }
  56656. declare module BABYLON {
  56657. /**
  56658. * Defines the kind of connection point for node based material
  56659. */
  56660. export enum NodeMaterialBlockConnectionPointTypes {
  56661. /** Float */
  56662. Float = 1,
  56663. /** Int */
  56664. Int = 2,
  56665. /** Vector2 */
  56666. Vector2 = 4,
  56667. /** Vector3 */
  56668. Vector3 = 8,
  56669. /** Vector4 */
  56670. Vector4 = 16,
  56671. /** Color3 */
  56672. Color3 = 32,
  56673. /** Color4 */
  56674. Color4 = 64,
  56675. /** Matrix */
  56676. Matrix = 128,
  56677. /** Detect type based on connection */
  56678. AutoDetect = 1024,
  56679. /** Output type that will be defined by input type */
  56680. BasedOnInput = 2048
  56681. }
  56682. }
  56683. declare module BABYLON {
  56684. /**
  56685. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56686. */
  56687. export enum NodeMaterialBlockConnectionPointMode {
  56688. /** Value is an uniform */
  56689. Uniform = 0,
  56690. /** Value is a mesh attribute */
  56691. Attribute = 1,
  56692. /** Value is a varying between vertex and fragment shaders */
  56693. Varying = 2,
  56694. /** Mode is undefined */
  56695. Undefined = 3
  56696. }
  56697. }
  56698. declare module BABYLON {
  56699. /**
  56700. * Enum used to define system values e.g. values automatically provided by the system
  56701. */
  56702. export enum NodeMaterialSystemValues {
  56703. /** World */
  56704. World = 1,
  56705. /** View */
  56706. View = 2,
  56707. /** Projection */
  56708. Projection = 3,
  56709. /** ViewProjection */
  56710. ViewProjection = 4,
  56711. /** WorldView */
  56712. WorldView = 5,
  56713. /** WorldViewProjection */
  56714. WorldViewProjection = 6,
  56715. /** CameraPosition */
  56716. CameraPosition = 7,
  56717. /** Fog Color */
  56718. FogColor = 8,
  56719. /** Delta time */
  56720. DeltaTime = 9
  56721. }
  56722. }
  56723. declare module BABYLON {
  56724. /**
  56725. * Root class for all node material optimizers
  56726. */
  56727. export class NodeMaterialOptimizer {
  56728. /**
  56729. * Function used to optimize a NodeMaterial graph
  56730. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56731. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56732. */
  56733. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56734. }
  56735. }
  56736. declare module BABYLON {
  56737. /**
  56738. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56739. */
  56740. export class TransformBlock extends NodeMaterialBlock {
  56741. /**
  56742. * Defines the value to use to complement W value to transform it to a Vector4
  56743. */
  56744. complementW: number;
  56745. /**
  56746. * Defines the value to use to complement z value to transform it to a Vector4
  56747. */
  56748. complementZ: number;
  56749. /**
  56750. * Creates a new TransformBlock
  56751. * @param name defines the block name
  56752. */
  56753. constructor(name: string);
  56754. /**
  56755. * Gets the current class name
  56756. * @returns the class name
  56757. */
  56758. getClassName(): string;
  56759. /**
  56760. * Gets the vector input
  56761. */
  56762. get vector(): NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the output component
  56765. */
  56766. get output(): NodeMaterialConnectionPoint;
  56767. /**
  56768. * Gets the xyz output component
  56769. */
  56770. get xyz(): NodeMaterialConnectionPoint;
  56771. /**
  56772. * Gets the matrix transform input
  56773. */
  56774. get transform(): NodeMaterialConnectionPoint;
  56775. protected _buildBlock(state: NodeMaterialBuildState): this;
  56776. serialize(): any;
  56777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56778. protected _dumpPropertiesCode(): string;
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. /**
  56783. * Block used to output the vertex position
  56784. */
  56785. export class VertexOutputBlock extends NodeMaterialBlock {
  56786. /**
  56787. * Creates a new VertexOutputBlock
  56788. * @param name defines the block name
  56789. */
  56790. constructor(name: string);
  56791. /**
  56792. * Gets the current class name
  56793. * @returns the class name
  56794. */
  56795. getClassName(): string;
  56796. /**
  56797. * Gets the vector input component
  56798. */
  56799. get vector(): NodeMaterialConnectionPoint;
  56800. protected _buildBlock(state: NodeMaterialBuildState): this;
  56801. }
  56802. }
  56803. declare module BABYLON {
  56804. /**
  56805. * Block used to output the final color
  56806. */
  56807. export class FragmentOutputBlock extends NodeMaterialBlock {
  56808. /**
  56809. * Create a new FragmentOutputBlock
  56810. * @param name defines the block name
  56811. */
  56812. constructor(name: string);
  56813. /**
  56814. * Gets the current class name
  56815. * @returns the class name
  56816. */
  56817. getClassName(): string;
  56818. /**
  56819. * Gets the rgba input component
  56820. */
  56821. get rgba(): NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the rgb input component
  56824. */
  56825. get rgb(): NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the a input component
  56828. */
  56829. get a(): NodeMaterialConnectionPoint;
  56830. protected _buildBlock(state: NodeMaterialBuildState): this;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Block used to read a reflection texture from a sampler
  56836. */
  56837. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56838. private _define3DName;
  56839. private _defineCubicName;
  56840. private _defineExplicitName;
  56841. private _defineProjectionName;
  56842. private _defineLocalCubicName;
  56843. private _defineSphericalName;
  56844. private _definePlanarName;
  56845. private _defineEquirectangularName;
  56846. private _defineMirroredEquirectangularFixedName;
  56847. private _defineEquirectangularFixedName;
  56848. private _defineSkyboxName;
  56849. private _cubeSamplerName;
  56850. private _2DSamplerName;
  56851. private _positionUVWName;
  56852. private _directionWName;
  56853. private _reflectionCoordsName;
  56854. private _reflection2DCoordsName;
  56855. private _reflectionColorName;
  56856. private _reflectionMatrixName;
  56857. /**
  56858. * Gets or sets the texture associated with the node
  56859. */
  56860. texture: Nullable<BaseTexture>;
  56861. /**
  56862. * Create a new TextureBlock
  56863. * @param name defines the block name
  56864. */
  56865. constructor(name: string);
  56866. /**
  56867. * Gets the current class name
  56868. * @returns the class name
  56869. */
  56870. getClassName(): string;
  56871. /**
  56872. * Gets the world position input component
  56873. */
  56874. get position(): NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the world position input component
  56877. */
  56878. get worldPosition(): NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the world normal input component
  56881. */
  56882. get worldNormal(): NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the world input component
  56885. */
  56886. get world(): NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the camera (or eye) position component
  56889. */
  56890. get cameraPosition(): NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the view input component
  56893. */
  56894. get view(): NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the rgb output component
  56897. */
  56898. get rgb(): NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the r output component
  56901. */
  56902. get r(): NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the g output component
  56905. */
  56906. get g(): NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the b output component
  56909. */
  56910. get b(): NodeMaterialConnectionPoint;
  56911. autoConfigure(material: NodeMaterial): void;
  56912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56913. isReady(): boolean;
  56914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56915. private _injectVertexCode;
  56916. private _writeOutput;
  56917. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56918. protected _dumpPropertiesCode(): string;
  56919. serialize(): any;
  56920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56921. }
  56922. }
  56923. declare module BABYLON {
  56924. /**
  56925. * Interface used to configure the node material editor
  56926. */
  56927. export interface INodeMaterialEditorOptions {
  56928. /** Define the URl to load node editor script */
  56929. editorURL?: string;
  56930. }
  56931. /** @hidden */
  56932. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56933. NORMAL: boolean;
  56934. TANGENT: boolean;
  56935. UV1: boolean;
  56936. /** BONES */
  56937. NUM_BONE_INFLUENCERS: number;
  56938. BonesPerMesh: number;
  56939. BONETEXTURE: boolean;
  56940. /** MORPH TARGETS */
  56941. MORPHTARGETS: boolean;
  56942. MORPHTARGETS_NORMAL: boolean;
  56943. MORPHTARGETS_TANGENT: boolean;
  56944. MORPHTARGETS_UV: boolean;
  56945. NUM_MORPH_INFLUENCERS: number;
  56946. /** IMAGE PROCESSING */
  56947. IMAGEPROCESSING: boolean;
  56948. VIGNETTE: boolean;
  56949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56950. VIGNETTEBLENDMODEOPAQUE: boolean;
  56951. TONEMAPPING: boolean;
  56952. TONEMAPPING_ACES: boolean;
  56953. CONTRAST: boolean;
  56954. EXPOSURE: boolean;
  56955. COLORCURVES: boolean;
  56956. COLORGRADING: boolean;
  56957. COLORGRADING3D: boolean;
  56958. SAMPLER3DGREENDEPTH: boolean;
  56959. SAMPLER3DBGRMAP: boolean;
  56960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56961. /** MISC. */
  56962. BUMPDIRECTUV: number;
  56963. constructor();
  56964. setValue(name: string, value: boolean): void;
  56965. }
  56966. /**
  56967. * Class used to configure NodeMaterial
  56968. */
  56969. export interface INodeMaterialOptions {
  56970. /**
  56971. * Defines if blocks should emit comments
  56972. */
  56973. emitComments: boolean;
  56974. }
  56975. /**
  56976. * Class used to create a node based material built by assembling shader blocks
  56977. */
  56978. export class NodeMaterial extends PushMaterial {
  56979. private static _BuildIdGenerator;
  56980. private _options;
  56981. private _vertexCompilationState;
  56982. private _fragmentCompilationState;
  56983. private _sharedData;
  56984. private _buildId;
  56985. private _buildWasSuccessful;
  56986. private _cachedWorldViewMatrix;
  56987. private _cachedWorldViewProjectionMatrix;
  56988. private _optimizers;
  56989. private _animationFrame;
  56990. /** Define the Url to load node editor script */
  56991. static EditorURL: string;
  56992. /** Define the Url to load snippets */
  56993. static SnippetUrl: string;
  56994. private BJSNODEMATERIALEDITOR;
  56995. /** Get the inspector from bundle or global */
  56996. private _getGlobalNodeMaterialEditor;
  56997. /**
  56998. * Gets or sets data used by visual editor
  56999. * @see https://nme.babylonjs.com
  57000. */
  57001. editorData: any;
  57002. /**
  57003. * 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)
  57004. */
  57005. ignoreAlpha: boolean;
  57006. /**
  57007. * Defines the maximum number of lights that can be used in the material
  57008. */
  57009. maxSimultaneousLights: number;
  57010. /**
  57011. * Observable raised when the material is built
  57012. */
  57013. onBuildObservable: Observable<NodeMaterial>;
  57014. /**
  57015. * Gets or sets the root nodes of the material vertex shader
  57016. */
  57017. _vertexOutputNodes: NodeMaterialBlock[];
  57018. /**
  57019. * Gets or sets the root nodes of the material fragment (pixel) shader
  57020. */
  57021. _fragmentOutputNodes: NodeMaterialBlock[];
  57022. /** Gets or sets options to control the node material overall behavior */
  57023. get options(): INodeMaterialOptions;
  57024. set options(options: INodeMaterialOptions);
  57025. /**
  57026. * Default configuration related to image processing available in the standard Material.
  57027. */
  57028. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57029. /**
  57030. * Gets the image processing configuration used either in this material.
  57031. */
  57032. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57033. /**
  57034. * Sets the Default image processing configuration used either in the this material.
  57035. *
  57036. * If sets to null, the scene one is in use.
  57037. */
  57038. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57039. /**
  57040. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57041. */
  57042. attachedBlocks: NodeMaterialBlock[];
  57043. /**
  57044. * Create a new node based material
  57045. * @param name defines the material name
  57046. * @param scene defines the hosting scene
  57047. * @param options defines creation option
  57048. */
  57049. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57050. /**
  57051. * Gets the current class name of the material e.g. "NodeMaterial"
  57052. * @returns the class name
  57053. */
  57054. getClassName(): string;
  57055. /**
  57056. * Keep track of the image processing observer to allow dispose and replace.
  57057. */
  57058. private _imageProcessingObserver;
  57059. /**
  57060. * Attaches a new image processing configuration to the Standard Material.
  57061. * @param configuration
  57062. */
  57063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57064. /**
  57065. * Get a block by its name
  57066. * @param name defines the name of the block to retrieve
  57067. * @returns the required block or null if not found
  57068. */
  57069. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57070. /**
  57071. * Get a block by its name
  57072. * @param predicate defines the predicate used to find the good candidate
  57073. * @returns the required block or null if not found
  57074. */
  57075. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57076. /**
  57077. * Get an input block by its name
  57078. * @param predicate defines the predicate used to find the good candidate
  57079. * @returns the required input block or null if not found
  57080. */
  57081. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57082. /**
  57083. * Gets the list of input blocks attached to this material
  57084. * @returns an array of InputBlocks
  57085. */
  57086. getInputBlocks(): InputBlock[];
  57087. /**
  57088. * Adds a new optimizer to the list of optimizers
  57089. * @param optimizer defines the optimizers to add
  57090. * @returns the current material
  57091. */
  57092. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57093. /**
  57094. * Remove an optimizer from the list of optimizers
  57095. * @param optimizer defines the optimizers to remove
  57096. * @returns the current material
  57097. */
  57098. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57099. /**
  57100. * Add a new block to the list of output nodes
  57101. * @param node defines the node to add
  57102. * @returns the current material
  57103. */
  57104. addOutputNode(node: NodeMaterialBlock): this;
  57105. /**
  57106. * Remove a block from the list of root nodes
  57107. * @param node defines the node to remove
  57108. * @returns the current material
  57109. */
  57110. removeOutputNode(node: NodeMaterialBlock): this;
  57111. private _addVertexOutputNode;
  57112. private _removeVertexOutputNode;
  57113. private _addFragmentOutputNode;
  57114. private _removeFragmentOutputNode;
  57115. /**
  57116. * Specifies if the material will require alpha blending
  57117. * @returns a boolean specifying if alpha blending is needed
  57118. */
  57119. needAlphaBlending(): boolean;
  57120. /**
  57121. * Specifies if this material should be rendered in alpha test mode
  57122. * @returns a boolean specifying if an alpha test is needed.
  57123. */
  57124. needAlphaTesting(): boolean;
  57125. private _initializeBlock;
  57126. private _resetDualBlocks;
  57127. /**
  57128. * Remove a block from the current node material
  57129. * @param block defines the block to remove
  57130. */
  57131. removeBlock(block: NodeMaterialBlock): void;
  57132. /**
  57133. * Build the material and generates the inner effect
  57134. * @param verbose defines if the build should log activity
  57135. */
  57136. build(verbose?: boolean): void;
  57137. /**
  57138. * Runs an otpimization phase to try to improve the shader code
  57139. */
  57140. optimize(): void;
  57141. private _prepareDefinesForAttributes;
  57142. /**
  57143. * Get if the submesh is ready to be used and all its information available.
  57144. * Child classes can use it to update shaders
  57145. * @param mesh defines the mesh to check
  57146. * @param subMesh defines which submesh to check
  57147. * @param useInstances specifies that instances should be used
  57148. * @returns a boolean indicating that the submesh is ready or not
  57149. */
  57150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57151. /**
  57152. * Get a string representing the shaders built by the current node graph
  57153. */
  57154. get compiledShaders(): string;
  57155. /**
  57156. * Binds the world matrix to the material
  57157. * @param world defines the world transformation matrix
  57158. */
  57159. bindOnlyWorldMatrix(world: Matrix): void;
  57160. /**
  57161. * Binds the submesh to this material by preparing the effect and shader to draw
  57162. * @param world defines the world transformation matrix
  57163. * @param mesh defines the mesh containing the submesh
  57164. * @param subMesh defines the submesh to bind the material to
  57165. */
  57166. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57167. /**
  57168. * Gets the active textures from the material
  57169. * @returns an array of textures
  57170. */
  57171. getActiveTextures(): BaseTexture[];
  57172. /**
  57173. * Gets the list of texture blocks
  57174. * @returns an array of texture blocks
  57175. */
  57176. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57177. /**
  57178. * Specifies if the material uses a texture
  57179. * @param texture defines the texture to check against the material
  57180. * @returns a boolean specifying if the material uses the texture
  57181. */
  57182. hasTexture(texture: BaseTexture): boolean;
  57183. /**
  57184. * Disposes the material
  57185. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57186. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57187. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57188. */
  57189. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57190. /** Creates the node editor window. */
  57191. private _createNodeEditor;
  57192. /**
  57193. * Launch the node material editor
  57194. * @param config Define the configuration of the editor
  57195. * @return a promise fulfilled when the node editor is visible
  57196. */
  57197. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57198. /**
  57199. * Clear the current material
  57200. */
  57201. clear(): void;
  57202. /**
  57203. * Clear the current material and set it to a default state
  57204. */
  57205. setToDefault(): void;
  57206. /**
  57207. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57208. * @param url defines the url to load from
  57209. * @returns a promise that will fullfil when the material is fully loaded
  57210. */
  57211. loadAsync(url: string): Promise<void>;
  57212. private _gatherBlocks;
  57213. /**
  57214. * Generate a string containing the code declaration required to create an equivalent of this material
  57215. * @returns a string
  57216. */
  57217. generateCode(): string;
  57218. /**
  57219. * Serializes this material in a JSON representation
  57220. * @returns the serialized material object
  57221. */
  57222. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57223. private _restoreConnections;
  57224. /**
  57225. * Clear the current graph and load a new one from a serialization object
  57226. * @param source defines the JSON representation of the material
  57227. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57228. */
  57229. loadFromSerialization(source: any, rootUrl?: string): void;
  57230. /**
  57231. * Creates a node material from parsed material data
  57232. * @param source defines the JSON representation of the material
  57233. * @param scene defines the hosting scene
  57234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57235. * @returns a new node material
  57236. */
  57237. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57238. /**
  57239. * Creates a node material from a snippet saved in a remote file
  57240. * @param name defines the name of the material to create
  57241. * @param url defines the url to load from
  57242. * @param scene defines the hosting scene
  57243. * @returns a promise that will resolve to the new node material
  57244. */
  57245. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57246. /**
  57247. * Creates a node material from a snippet saved by the node material editor
  57248. * @param snippetId defines the snippet to load
  57249. * @param scene defines the hosting scene
  57250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57251. * @returns a promise that will resolve to the new node material
  57252. */
  57253. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57254. /**
  57255. * Creates a new node material set to default basic configuration
  57256. * @param name defines the name of the material
  57257. * @param scene defines the hosting scene
  57258. * @returns a new NodeMaterial
  57259. */
  57260. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57261. }
  57262. }
  57263. declare module BABYLON {
  57264. /**
  57265. * Block used to read a texture from a sampler
  57266. */
  57267. export class TextureBlock extends NodeMaterialBlock {
  57268. private _defineName;
  57269. private _linearDefineName;
  57270. private _tempTextureRead;
  57271. private _samplerName;
  57272. private _transformedUVName;
  57273. private _textureTransformName;
  57274. private _textureInfoName;
  57275. private _mainUVName;
  57276. private _mainUVDefineName;
  57277. /**
  57278. * Gets or sets the texture associated with the node
  57279. */
  57280. texture: Nullable<Texture>;
  57281. /**
  57282. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57283. */
  57284. convertToGammaSpace: boolean;
  57285. /**
  57286. * Create a new TextureBlock
  57287. * @param name defines the block name
  57288. */
  57289. constructor(name: string);
  57290. /**
  57291. * Gets the current class name
  57292. * @returns the class name
  57293. */
  57294. getClassName(): string;
  57295. /**
  57296. * Gets the uv input component
  57297. */
  57298. get uv(): NodeMaterialConnectionPoint;
  57299. /**
  57300. * Gets the rgba output component
  57301. */
  57302. get rgba(): NodeMaterialConnectionPoint;
  57303. /**
  57304. * Gets the rgb output component
  57305. */
  57306. get rgb(): NodeMaterialConnectionPoint;
  57307. /**
  57308. * Gets the r output component
  57309. */
  57310. get r(): NodeMaterialConnectionPoint;
  57311. /**
  57312. * Gets the g output component
  57313. */
  57314. get g(): NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the b output component
  57317. */
  57318. get b(): NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the a output component
  57321. */
  57322. get a(): NodeMaterialConnectionPoint;
  57323. get target(): NodeMaterialBlockTargets;
  57324. autoConfigure(material: NodeMaterial): void;
  57325. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57327. isReady(): boolean;
  57328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57329. private get _isMixed();
  57330. private _injectVertexCode;
  57331. private _writeTextureRead;
  57332. private _writeOutput;
  57333. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57334. protected _dumpPropertiesCode(): string;
  57335. serialize(): any;
  57336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57337. }
  57338. }
  57339. declare module BABYLON {
  57340. /**
  57341. * Class used to store shared data between 2 NodeMaterialBuildState
  57342. */
  57343. export class NodeMaterialBuildStateSharedData {
  57344. /**
  57345. * Gets the list of emitted varyings
  57346. */
  57347. temps: string[];
  57348. /**
  57349. * Gets the list of emitted varyings
  57350. */
  57351. varyings: string[];
  57352. /**
  57353. * Gets the varying declaration string
  57354. */
  57355. varyingDeclaration: string;
  57356. /**
  57357. * Input blocks
  57358. */
  57359. inputBlocks: InputBlock[];
  57360. /**
  57361. * Input blocks
  57362. */
  57363. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57364. /**
  57365. * Bindable blocks (Blocks that need to set data to the effect)
  57366. */
  57367. bindableBlocks: NodeMaterialBlock[];
  57368. /**
  57369. * List of blocks that can provide a compilation fallback
  57370. */
  57371. blocksWithFallbacks: NodeMaterialBlock[];
  57372. /**
  57373. * List of blocks that can provide a define update
  57374. */
  57375. blocksWithDefines: NodeMaterialBlock[];
  57376. /**
  57377. * List of blocks that can provide a repeatable content
  57378. */
  57379. repeatableContentBlocks: NodeMaterialBlock[];
  57380. /**
  57381. * List of blocks that can provide a dynamic list of uniforms
  57382. */
  57383. dynamicUniformBlocks: NodeMaterialBlock[];
  57384. /**
  57385. * List of blocks that can block the isReady function for the material
  57386. */
  57387. blockingBlocks: NodeMaterialBlock[];
  57388. /**
  57389. * Gets the list of animated inputs
  57390. */
  57391. animatedInputs: InputBlock[];
  57392. /**
  57393. * Build Id used to avoid multiple recompilations
  57394. */
  57395. buildId: number;
  57396. /** List of emitted variables */
  57397. variableNames: {
  57398. [key: string]: number;
  57399. };
  57400. /** List of emitted defines */
  57401. defineNames: {
  57402. [key: string]: number;
  57403. };
  57404. /** Should emit comments? */
  57405. emitComments: boolean;
  57406. /** Emit build activity */
  57407. verbose: boolean;
  57408. /** Gets or sets the hosting scene */
  57409. scene: Scene;
  57410. /**
  57411. * Gets the compilation hints emitted at compilation time
  57412. */
  57413. hints: {
  57414. needWorldViewMatrix: boolean;
  57415. needWorldViewProjectionMatrix: boolean;
  57416. needAlphaBlending: boolean;
  57417. needAlphaTesting: boolean;
  57418. };
  57419. /**
  57420. * List of compilation checks
  57421. */
  57422. checks: {
  57423. emitVertex: boolean;
  57424. emitFragment: boolean;
  57425. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57426. };
  57427. /** Creates a new shared data */
  57428. constructor();
  57429. /**
  57430. * Emits console errors and exceptions if there is a failing check
  57431. */
  57432. emitErrors(): void;
  57433. }
  57434. }
  57435. declare module BABYLON {
  57436. /**
  57437. * Class used to store node based material build state
  57438. */
  57439. export class NodeMaterialBuildState {
  57440. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57441. supportUniformBuffers: boolean;
  57442. /**
  57443. * Gets the list of emitted attributes
  57444. */
  57445. attributes: string[];
  57446. /**
  57447. * Gets the list of emitted uniforms
  57448. */
  57449. uniforms: string[];
  57450. /**
  57451. * Gets the list of emitted constants
  57452. */
  57453. constants: string[];
  57454. /**
  57455. * Gets the list of emitted samplers
  57456. */
  57457. samplers: string[];
  57458. /**
  57459. * Gets the list of emitted functions
  57460. */
  57461. functions: {
  57462. [key: string]: string;
  57463. };
  57464. /**
  57465. * Gets the list of emitted extensions
  57466. */
  57467. extensions: {
  57468. [key: string]: string;
  57469. };
  57470. /**
  57471. * Gets the target of the compilation state
  57472. */
  57473. target: NodeMaterialBlockTargets;
  57474. /**
  57475. * Gets the list of emitted counters
  57476. */
  57477. counters: {
  57478. [key: string]: number;
  57479. };
  57480. /**
  57481. * Shared data between multiple NodeMaterialBuildState instances
  57482. */
  57483. sharedData: NodeMaterialBuildStateSharedData;
  57484. /** @hidden */
  57485. _vertexState: NodeMaterialBuildState;
  57486. /** @hidden */
  57487. _attributeDeclaration: string;
  57488. /** @hidden */
  57489. _uniformDeclaration: string;
  57490. /** @hidden */
  57491. _constantDeclaration: string;
  57492. /** @hidden */
  57493. _samplerDeclaration: string;
  57494. /** @hidden */
  57495. _varyingTransfer: string;
  57496. private _repeatableContentAnchorIndex;
  57497. /** @hidden */
  57498. _builtCompilationString: string;
  57499. /**
  57500. * Gets the emitted compilation strings
  57501. */
  57502. compilationString: string;
  57503. /**
  57504. * Finalize the compilation strings
  57505. * @param state defines the current compilation state
  57506. */
  57507. finalize(state: NodeMaterialBuildState): void;
  57508. /** @hidden */
  57509. get _repeatableContentAnchor(): string;
  57510. /** @hidden */
  57511. _getFreeVariableName(prefix: string): string;
  57512. /** @hidden */
  57513. _getFreeDefineName(prefix: string): string;
  57514. /** @hidden */
  57515. _excludeVariableName(name: string): void;
  57516. /** @hidden */
  57517. _emit2DSampler(name: string): void;
  57518. /** @hidden */
  57519. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57520. /** @hidden */
  57521. _emitExtension(name: string, extension: string): void;
  57522. /** @hidden */
  57523. _emitFunction(name: string, code: string, comments: string): void;
  57524. /** @hidden */
  57525. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57526. replaceStrings?: {
  57527. search: RegExp;
  57528. replace: string;
  57529. }[];
  57530. repeatKey?: string;
  57531. }): string;
  57532. /** @hidden */
  57533. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57534. repeatKey?: string;
  57535. removeAttributes?: boolean;
  57536. removeUniforms?: boolean;
  57537. removeVaryings?: boolean;
  57538. removeIfDef?: boolean;
  57539. replaceStrings?: {
  57540. search: RegExp;
  57541. replace: string;
  57542. }[];
  57543. }, storeKey?: string): void;
  57544. /** @hidden */
  57545. _registerTempVariable(name: string): boolean;
  57546. /** @hidden */
  57547. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57548. /** @hidden */
  57549. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57550. /** @hidden */
  57551. _emitFloat(value: number): string;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * Defines a block that can be used inside a node based material
  57557. */
  57558. export class NodeMaterialBlock {
  57559. private _buildId;
  57560. private _buildTarget;
  57561. private _target;
  57562. private _isFinalMerger;
  57563. private _isInput;
  57564. protected _isUnique: boolean;
  57565. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57566. inputsAreExclusive: boolean;
  57567. /** @hidden */
  57568. _codeVariableName: string;
  57569. /** @hidden */
  57570. _inputs: NodeMaterialConnectionPoint[];
  57571. /** @hidden */
  57572. _outputs: NodeMaterialConnectionPoint[];
  57573. /** @hidden */
  57574. _preparationId: number;
  57575. /**
  57576. * Gets or sets the name of the block
  57577. */
  57578. name: string;
  57579. /**
  57580. * Gets or sets the unique id of the node
  57581. */
  57582. uniqueId: number;
  57583. /**
  57584. * Gets or sets the comments associated with this block
  57585. */
  57586. comments: string;
  57587. /**
  57588. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57589. */
  57590. get isUnique(): boolean;
  57591. /**
  57592. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57593. */
  57594. get isFinalMerger(): boolean;
  57595. /**
  57596. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57597. */
  57598. get isInput(): boolean;
  57599. /**
  57600. * Gets or sets the build Id
  57601. */
  57602. get buildId(): number;
  57603. set buildId(value: number);
  57604. /**
  57605. * Gets or sets the target of the block
  57606. */
  57607. get target(): NodeMaterialBlockTargets;
  57608. set target(value: NodeMaterialBlockTargets);
  57609. /**
  57610. * Gets the list of input points
  57611. */
  57612. get inputs(): NodeMaterialConnectionPoint[];
  57613. /** Gets the list of output points */
  57614. get outputs(): NodeMaterialConnectionPoint[];
  57615. /**
  57616. * Find an input by its name
  57617. * @param name defines the name of the input to look for
  57618. * @returns the input or null if not found
  57619. */
  57620. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57621. /**
  57622. * Find an output by its name
  57623. * @param name defines the name of the outputto look for
  57624. * @returns the output or null if not found
  57625. */
  57626. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57627. /**
  57628. * Creates a new NodeMaterialBlock
  57629. * @param name defines the block name
  57630. * @param target defines the target of that block (Vertex by default)
  57631. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57632. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57633. */
  57634. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57635. /**
  57636. * Initialize the block and prepare the context for build
  57637. * @param state defines the state that will be used for the build
  57638. */
  57639. initialize(state: NodeMaterialBuildState): void;
  57640. /**
  57641. * Bind data to effect. Will only be called for blocks with isBindable === true
  57642. * @param effect defines the effect to bind data to
  57643. * @param nodeMaterial defines the hosting NodeMaterial
  57644. * @param mesh defines the mesh that will be rendered
  57645. */
  57646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57647. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57648. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57649. protected _writeFloat(value: number): string;
  57650. /**
  57651. * Gets the current class name e.g. "NodeMaterialBlock"
  57652. * @returns the class name
  57653. */
  57654. getClassName(): string;
  57655. /**
  57656. * Register a new input. Must be called inside a block constructor
  57657. * @param name defines the connection point name
  57658. * @param type defines the connection point type
  57659. * @param isOptional defines a boolean indicating that this input can be omitted
  57660. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57661. * @returns the current block
  57662. */
  57663. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57664. /**
  57665. * Register a new output. Must be called inside a block constructor
  57666. * @param name defines the connection point name
  57667. * @param type defines the connection point type
  57668. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57669. * @returns the current block
  57670. */
  57671. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57672. /**
  57673. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57674. * @param forOutput defines an optional connection point to check compatibility with
  57675. * @returns the first available input or null
  57676. */
  57677. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57678. /**
  57679. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57680. * @param forBlock defines an optional block to check compatibility with
  57681. * @returns the first available input or null
  57682. */
  57683. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57684. /**
  57685. * Gets the sibling of the given output
  57686. * @param current defines the current output
  57687. * @returns the next output in the list or null
  57688. */
  57689. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57690. /**
  57691. * Connect current block with another block
  57692. * @param other defines the block to connect with
  57693. * @param options define the various options to help pick the right connections
  57694. * @returns the current block
  57695. */
  57696. connectTo(other: NodeMaterialBlock, options?: {
  57697. input?: string;
  57698. output?: string;
  57699. outputSwizzle?: string;
  57700. }): this | undefined;
  57701. protected _buildBlock(state: NodeMaterialBuildState): void;
  57702. /**
  57703. * Add uniforms, samplers and uniform buffers at compilation time
  57704. * @param state defines the state to update
  57705. * @param nodeMaterial defines the node material requesting the update
  57706. * @param defines defines the material defines to update
  57707. * @param uniformBuffers defines the list of uniform buffer names
  57708. */
  57709. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57710. /**
  57711. * Add potential fallbacks if shader compilation fails
  57712. * @param mesh defines the mesh to be rendered
  57713. * @param fallbacks defines the current prioritized list of fallbacks
  57714. */
  57715. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57716. /**
  57717. * Initialize defines for shader compilation
  57718. * @param mesh defines the mesh to be rendered
  57719. * @param nodeMaterial defines the node material requesting the update
  57720. * @param defines defines the material defines to update
  57721. * @param useInstances specifies that instances should be used
  57722. */
  57723. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57724. /**
  57725. * Update defines for shader compilation
  57726. * @param mesh defines the mesh to be rendered
  57727. * @param nodeMaterial defines the node material requesting the update
  57728. * @param defines defines the material defines to update
  57729. * @param useInstances specifies that instances should be used
  57730. */
  57731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57732. /**
  57733. * Lets the block try to connect some inputs automatically
  57734. * @param material defines the hosting NodeMaterial
  57735. */
  57736. autoConfigure(material: NodeMaterial): void;
  57737. /**
  57738. * Function called when a block is declared as repeatable content generator
  57739. * @param vertexShaderState defines the current compilation state for the vertex shader
  57740. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57741. * @param mesh defines the mesh to be rendered
  57742. * @param defines defines the material defines to update
  57743. */
  57744. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57745. /**
  57746. * Checks if the block is ready
  57747. * @param mesh defines the mesh to be rendered
  57748. * @param nodeMaterial defines the node material requesting the update
  57749. * @param defines defines the material defines to update
  57750. * @param useInstances specifies that instances should be used
  57751. * @returns true if the block is ready
  57752. */
  57753. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57754. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57755. private _processBuild;
  57756. /**
  57757. * Compile the current node and generate the shader code
  57758. * @param state defines the current compilation state (uniforms, samplers, current string)
  57759. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57760. * @returns true if already built
  57761. */
  57762. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57763. protected _inputRename(name: string): string;
  57764. protected _outputRename(name: string): string;
  57765. protected _dumpPropertiesCode(): string;
  57766. /** @hidden */
  57767. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57768. /** @hidden */
  57769. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57770. /**
  57771. * Clone the current block to a new identical block
  57772. * @param scene defines the hosting scene
  57773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57774. * @returns a copy of the current block
  57775. */
  57776. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57777. /**
  57778. * Serializes this block in a JSON representation
  57779. * @returns the serialized block object
  57780. */
  57781. serialize(): any;
  57782. /** @hidden */
  57783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57784. /**
  57785. * Release resources
  57786. */
  57787. dispose(): void;
  57788. }
  57789. }
  57790. declare module BABYLON {
  57791. /**
  57792. * Enum defining the type of animations supported by InputBlock
  57793. */
  57794. export enum AnimatedInputBlockTypes {
  57795. /** No animation */
  57796. None = 0,
  57797. /** Time based animation. Will only work for floats */
  57798. Time = 1
  57799. }
  57800. }
  57801. declare module BABYLON {
  57802. /**
  57803. * Block used to expose an input value
  57804. */
  57805. export class InputBlock extends NodeMaterialBlock {
  57806. private _mode;
  57807. private _associatedVariableName;
  57808. private _storedValue;
  57809. private _valueCallback;
  57810. private _type;
  57811. private _animationType;
  57812. /** Gets or set a value used to limit the range of float values */
  57813. min: number;
  57814. /** Gets or set a value used to limit the range of float values */
  57815. max: number;
  57816. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57817. isBoolean: boolean;
  57818. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57819. matrixMode: number;
  57820. /** @hidden */
  57821. _systemValue: Nullable<NodeMaterialSystemValues>;
  57822. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57823. visibleInInspector: boolean;
  57824. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57825. isConstant: boolean;
  57826. /** Gets or sets the group to use to display this block in the Inspector */
  57827. groupInInspector: string;
  57828. /** Gets an observable raised when the value is changed */
  57829. onValueChangedObservable: Observable<InputBlock>;
  57830. /**
  57831. * Gets or sets the connection point type (default is float)
  57832. */
  57833. get type(): NodeMaterialBlockConnectionPointTypes;
  57834. /**
  57835. * Creates a new InputBlock
  57836. * @param name defines the block name
  57837. * @param target defines the target of that block (Vertex by default)
  57838. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57839. */
  57840. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57841. /**
  57842. * Gets the output component
  57843. */
  57844. get output(): NodeMaterialConnectionPoint;
  57845. /**
  57846. * Set the source of this connection point to a vertex attribute
  57847. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57848. * @returns the current connection point
  57849. */
  57850. setAsAttribute(attributeName?: string): InputBlock;
  57851. /**
  57852. * Set the source of this connection point to a system value
  57853. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57854. * @returns the current connection point
  57855. */
  57856. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57857. /**
  57858. * Gets or sets the value of that point.
  57859. * Please note that this value will be ignored if valueCallback is defined
  57860. */
  57861. get value(): any;
  57862. set value(value: any);
  57863. /**
  57864. * Gets or sets a callback used to get the value of that point.
  57865. * Please note that setting this value will force the connection point to ignore the value property
  57866. */
  57867. get valueCallback(): () => any;
  57868. set valueCallback(value: () => any);
  57869. /**
  57870. * Gets or sets the associated variable name in the shader
  57871. */
  57872. get associatedVariableName(): string;
  57873. set associatedVariableName(value: string);
  57874. /** Gets or sets the type of animation applied to the input */
  57875. get animationType(): AnimatedInputBlockTypes;
  57876. set animationType(value: AnimatedInputBlockTypes);
  57877. /**
  57878. * Gets a boolean indicating that this connection point not defined yet
  57879. */
  57880. get isUndefined(): boolean;
  57881. /**
  57882. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57883. * In this case the connection point name must be the name of the uniform to use.
  57884. * Can only be set on inputs
  57885. */
  57886. get isUniform(): boolean;
  57887. set isUniform(value: boolean);
  57888. /**
  57889. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57890. * In this case the connection point name must be the name of the attribute to use
  57891. * Can only be set on inputs
  57892. */
  57893. get isAttribute(): boolean;
  57894. set isAttribute(value: boolean);
  57895. /**
  57896. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57897. * Can only be set on exit points
  57898. */
  57899. get isVarying(): boolean;
  57900. set isVarying(value: boolean);
  57901. /**
  57902. * Gets a boolean indicating that the current connection point is a system value
  57903. */
  57904. get isSystemValue(): boolean;
  57905. /**
  57906. * Gets or sets the current well known value or null if not defined as a system value
  57907. */
  57908. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57909. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57910. /**
  57911. * Gets the current class name
  57912. * @returns the class name
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Animate the input if animationType !== None
  57917. * @param scene defines the rendering scene
  57918. */
  57919. animate(scene: Scene): void;
  57920. private _emitDefine;
  57921. initialize(state: NodeMaterialBuildState): void;
  57922. /**
  57923. * Set the input block to its default value (based on its type)
  57924. */
  57925. setDefaultValue(): void;
  57926. private _emitConstant;
  57927. private _emit;
  57928. /** @hidden */
  57929. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57930. /** @hidden */
  57931. _transmit(effect: Effect, scene: Scene): void;
  57932. protected _buildBlock(state: NodeMaterialBuildState): void;
  57933. protected _dumpPropertiesCode(): string;
  57934. dispose(): void;
  57935. serialize(): any;
  57936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57937. }
  57938. }
  57939. declare module BABYLON {
  57940. /**
  57941. * Enum used to define the compatibility state between two connection points
  57942. */
  57943. export enum NodeMaterialConnectionPointCompatibilityStates {
  57944. /** Points are compatibles */
  57945. Compatible = 0,
  57946. /** Points are incompatible because of their types */
  57947. TypeIncompatible = 1,
  57948. /** Points are incompatible because of their targets (vertex vs fragment) */
  57949. TargetIncompatible = 2
  57950. }
  57951. /**
  57952. * Defines the direction of a connection point
  57953. */
  57954. export enum NodeMaterialConnectionPointDirection {
  57955. /** Input */
  57956. Input = 0,
  57957. /** Output */
  57958. Output = 1
  57959. }
  57960. /**
  57961. * Defines a connection point for a block
  57962. */
  57963. export class NodeMaterialConnectionPoint {
  57964. /** @hidden */
  57965. _ownerBlock: NodeMaterialBlock;
  57966. /** @hidden */
  57967. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57968. private _endpoints;
  57969. private _associatedVariableName;
  57970. private _direction;
  57971. /** @hidden */
  57972. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57973. /** @hidden */
  57974. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57975. private _type;
  57976. /** @hidden */
  57977. _enforceAssociatedVariableName: boolean;
  57978. /** Gets the direction of the point */
  57979. get direction(): NodeMaterialConnectionPointDirection;
  57980. /**
  57981. * Gets or sets the additional types supported by this connection point
  57982. */
  57983. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57984. /**
  57985. * Gets or sets the additional types excluded by this connection point
  57986. */
  57987. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57988. /**
  57989. * Observable triggered when this point is connected
  57990. */
  57991. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57992. /**
  57993. * Gets or sets the associated variable name in the shader
  57994. */
  57995. get associatedVariableName(): string;
  57996. set associatedVariableName(value: string);
  57997. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  57998. get innerType(): NodeMaterialBlockConnectionPointTypes;
  57999. /**
  58000. * Gets or sets the connection point type (default is float)
  58001. */
  58002. get type(): NodeMaterialBlockConnectionPointTypes;
  58003. set type(value: NodeMaterialBlockConnectionPointTypes);
  58004. /**
  58005. * Gets or sets the connection point name
  58006. */
  58007. name: string;
  58008. /**
  58009. * Gets or sets a boolean indicating that this connection point can be omitted
  58010. */
  58011. isOptional: boolean;
  58012. /**
  58013. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58014. */
  58015. define: string;
  58016. /** @hidden */
  58017. _prioritizeVertex: boolean;
  58018. private _target;
  58019. /** Gets or sets the target of that connection point */
  58020. get target(): NodeMaterialBlockTargets;
  58021. set target(value: NodeMaterialBlockTargets);
  58022. /**
  58023. * Gets a boolean indicating that the current point is connected
  58024. */
  58025. get isConnected(): boolean;
  58026. /**
  58027. * Gets a boolean indicating that the current point is connected to an input block
  58028. */
  58029. get isConnectedToInputBlock(): boolean;
  58030. /**
  58031. * Gets a the connected input block (if any)
  58032. */
  58033. get connectInputBlock(): Nullable<InputBlock>;
  58034. /** Get the other side of the connection (if any) */
  58035. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58036. /** Get the block that owns this connection point */
  58037. get ownerBlock(): NodeMaterialBlock;
  58038. /** Get the block connected on the other side of this connection (if any) */
  58039. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58040. /** Get the block connected on the endpoints of this connection (if any) */
  58041. get connectedBlocks(): Array<NodeMaterialBlock>;
  58042. /** Gets the list of connected endpoints */
  58043. get endpoints(): NodeMaterialConnectionPoint[];
  58044. /** Gets a boolean indicating if that output point is connected to at least one input */
  58045. get hasEndpoints(): boolean;
  58046. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58047. get isConnectedInVertexShader(): boolean;
  58048. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58049. get isConnectedInFragmentShader(): boolean;
  58050. /**
  58051. * Creates a new connection point
  58052. * @param name defines the connection point name
  58053. * @param ownerBlock defines the block hosting this connection point
  58054. * @param direction defines the direction of the connection point
  58055. */
  58056. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58057. /**
  58058. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58059. * @returns the class name
  58060. */
  58061. getClassName(): string;
  58062. /**
  58063. * Gets a boolean indicating if the current point can be connected to another point
  58064. * @param connectionPoint defines the other connection point
  58065. * @returns a boolean
  58066. */
  58067. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58068. /**
  58069. * Gets a number indicating if the current point can be connected to another point
  58070. * @param connectionPoint defines the other connection point
  58071. * @returns a number defining the compatibility state
  58072. */
  58073. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58074. /**
  58075. * Connect this point to another connection point
  58076. * @param connectionPoint defines the other connection point
  58077. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58078. * @returns the current connection point
  58079. */
  58080. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58081. /**
  58082. * Disconnect this point from one of his endpoint
  58083. * @param endpoint defines the other connection point
  58084. * @returns the current connection point
  58085. */
  58086. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58087. /**
  58088. * Serializes this point in a JSON representation
  58089. * @returns the serialized point object
  58090. */
  58091. serialize(): any;
  58092. /**
  58093. * Release resources
  58094. */
  58095. dispose(): void;
  58096. }
  58097. }
  58098. declare module BABYLON {
  58099. /**
  58100. * Block used to add support for vertex skinning (bones)
  58101. */
  58102. export class BonesBlock extends NodeMaterialBlock {
  58103. /**
  58104. * Creates a new BonesBlock
  58105. * @param name defines the block name
  58106. */
  58107. constructor(name: string);
  58108. /**
  58109. * Initialize the block and prepare the context for build
  58110. * @param state defines the state that will be used for the build
  58111. */
  58112. initialize(state: NodeMaterialBuildState): void;
  58113. /**
  58114. * Gets the current class name
  58115. * @returns the class name
  58116. */
  58117. getClassName(): string;
  58118. /**
  58119. * Gets the matrix indices input component
  58120. */
  58121. get matricesIndices(): NodeMaterialConnectionPoint;
  58122. /**
  58123. * Gets the matrix weights input component
  58124. */
  58125. get matricesWeights(): NodeMaterialConnectionPoint;
  58126. /**
  58127. * Gets the extra matrix indices input component
  58128. */
  58129. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58130. /**
  58131. * Gets the extra matrix weights input component
  58132. */
  58133. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58134. /**
  58135. * Gets the world input component
  58136. */
  58137. get world(): NodeMaterialConnectionPoint;
  58138. /**
  58139. * Gets the output component
  58140. */
  58141. get output(): NodeMaterialConnectionPoint;
  58142. autoConfigure(material: NodeMaterial): void;
  58143. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. }
  58148. }
  58149. declare module BABYLON {
  58150. /**
  58151. * Block used to add support for instances
  58152. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58153. */
  58154. export class InstancesBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Creates a new InstancesBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the first world row input component
  58167. */
  58168. get world0(): NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the second world row input component
  58171. */
  58172. get world1(): NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the third world row input component
  58175. */
  58176. get world2(): NodeMaterialConnectionPoint;
  58177. /**
  58178. * Gets the forth world row input component
  58179. */
  58180. get world3(): NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the world input component
  58183. */
  58184. get world(): NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the output component
  58187. */
  58188. get output(): NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the isntanceID component
  58191. */
  58192. get instanceID(): NodeMaterialConnectionPoint;
  58193. autoConfigure(material: NodeMaterial): void;
  58194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58195. protected _buildBlock(state: NodeMaterialBuildState): this;
  58196. }
  58197. }
  58198. declare module BABYLON {
  58199. /**
  58200. * Block used to add morph targets support to vertex shader
  58201. */
  58202. export class MorphTargetsBlock extends NodeMaterialBlock {
  58203. private _repeatableContentAnchor;
  58204. /**
  58205. * Create a new MorphTargetsBlock
  58206. * @param name defines the block name
  58207. */
  58208. constructor(name: string);
  58209. /**
  58210. * Gets the current class name
  58211. * @returns the class name
  58212. */
  58213. getClassName(): string;
  58214. /**
  58215. * Gets the position input component
  58216. */
  58217. get position(): NodeMaterialConnectionPoint;
  58218. /**
  58219. * Gets the normal input component
  58220. */
  58221. get normal(): NodeMaterialConnectionPoint;
  58222. /**
  58223. * Gets the tangent input component
  58224. */
  58225. get tangent(): NodeMaterialConnectionPoint;
  58226. /**
  58227. * Gets the tangent input component
  58228. */
  58229. get uv(): NodeMaterialConnectionPoint;
  58230. /**
  58231. * Gets the position output component
  58232. */
  58233. get positionOutput(): NodeMaterialConnectionPoint;
  58234. /**
  58235. * Gets the normal output component
  58236. */
  58237. get normalOutput(): NodeMaterialConnectionPoint;
  58238. /**
  58239. * Gets the tangent output component
  58240. */
  58241. get tangentOutput(): NodeMaterialConnectionPoint;
  58242. /**
  58243. * Gets the tangent output component
  58244. */
  58245. get uvOutput(): NodeMaterialConnectionPoint;
  58246. initialize(state: NodeMaterialBuildState): void;
  58247. autoConfigure(material: NodeMaterial): void;
  58248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58250. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58251. protected _buildBlock(state: NodeMaterialBuildState): this;
  58252. }
  58253. }
  58254. declare module BABYLON {
  58255. /**
  58256. * Block used to get data information from a light
  58257. */
  58258. export class LightInformationBlock extends NodeMaterialBlock {
  58259. private _lightDataUniformName;
  58260. private _lightColorUniformName;
  58261. private _lightTypeDefineName;
  58262. /**
  58263. * Gets or sets the light associated with this block
  58264. */
  58265. light: Nullable<Light>;
  58266. /**
  58267. * Creates a new LightInformationBlock
  58268. * @param name defines the block name
  58269. */
  58270. constructor(name: string);
  58271. /**
  58272. * Gets the current class name
  58273. * @returns the class name
  58274. */
  58275. getClassName(): string;
  58276. /**
  58277. * Gets the world position input component
  58278. */
  58279. get worldPosition(): NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the direction output component
  58282. */
  58283. get direction(): NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the direction output component
  58286. */
  58287. get color(): NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the direction output component
  58290. */
  58291. get intensity(): NodeMaterialConnectionPoint;
  58292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58294. protected _buildBlock(state: NodeMaterialBuildState): this;
  58295. serialize(): any;
  58296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58297. }
  58298. }
  58299. declare module BABYLON {
  58300. /**
  58301. * Block used to add image processing support to fragment shader
  58302. */
  58303. export class ImageProcessingBlock extends NodeMaterialBlock {
  58304. /**
  58305. * Create a new ImageProcessingBlock
  58306. * @param name defines the block name
  58307. */
  58308. constructor(name: string);
  58309. /**
  58310. * Gets the current class name
  58311. * @returns the class name
  58312. */
  58313. getClassName(): string;
  58314. /**
  58315. * Gets the color input component
  58316. */
  58317. get color(): NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the output component
  58320. */
  58321. get output(): NodeMaterialConnectionPoint;
  58322. /**
  58323. * Initialize the block and prepare the context for build
  58324. * @param state defines the state that will be used for the build
  58325. */
  58326. initialize(state: NodeMaterialBuildState): void;
  58327. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58330. protected _buildBlock(state: NodeMaterialBuildState): this;
  58331. }
  58332. }
  58333. declare module BABYLON {
  58334. /**
  58335. * Block used to pertub normals based on a normal map
  58336. */
  58337. export class PerturbNormalBlock extends NodeMaterialBlock {
  58338. private _tangentSpaceParameterName;
  58339. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58340. invertX: boolean;
  58341. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58342. invertY: boolean;
  58343. /**
  58344. * Create a new PerturbNormalBlock
  58345. * @param name defines the block name
  58346. */
  58347. constructor(name: string);
  58348. /**
  58349. * Gets the current class name
  58350. * @returns the class name
  58351. */
  58352. getClassName(): string;
  58353. /**
  58354. * Gets the world position input component
  58355. */
  58356. get worldPosition(): NodeMaterialConnectionPoint;
  58357. /**
  58358. * Gets the world normal input component
  58359. */
  58360. get worldNormal(): NodeMaterialConnectionPoint;
  58361. /**
  58362. * Gets the world tangent input component
  58363. */
  58364. get worldTangent(): NodeMaterialConnectionPoint;
  58365. /**
  58366. * Gets the uv input component
  58367. */
  58368. get uv(): NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the normal map color input component
  58371. */
  58372. get normalMapColor(): NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the strength input component
  58375. */
  58376. get strength(): NodeMaterialConnectionPoint;
  58377. /**
  58378. * Gets the output component
  58379. */
  58380. get output(): NodeMaterialConnectionPoint;
  58381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58383. autoConfigure(material: NodeMaterial): void;
  58384. protected _buildBlock(state: NodeMaterialBuildState): this;
  58385. protected _dumpPropertiesCode(): string;
  58386. serialize(): any;
  58387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58388. }
  58389. }
  58390. declare module BABYLON {
  58391. /**
  58392. * Block used to discard a pixel if a value is smaller than a cutoff
  58393. */
  58394. export class DiscardBlock extends NodeMaterialBlock {
  58395. /**
  58396. * Create a new DiscardBlock
  58397. * @param name defines the block name
  58398. */
  58399. constructor(name: string);
  58400. /**
  58401. * Gets the current class name
  58402. * @returns the class name
  58403. */
  58404. getClassName(): string;
  58405. /**
  58406. * Gets the color input component
  58407. */
  58408. get value(): NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the cutoff input component
  58411. */
  58412. get cutoff(): NodeMaterialConnectionPoint;
  58413. protected _buildBlock(state: NodeMaterialBuildState): this;
  58414. }
  58415. }
  58416. declare module BABYLON {
  58417. /**
  58418. * Block used to test if the fragment shader is front facing
  58419. */
  58420. export class FrontFacingBlock extends NodeMaterialBlock {
  58421. /**
  58422. * Creates a new FrontFacingBlock
  58423. * @param name defines the block name
  58424. */
  58425. constructor(name: string);
  58426. /**
  58427. * Gets the current class name
  58428. * @returns the class name
  58429. */
  58430. getClassName(): string;
  58431. /**
  58432. * Gets the output component
  58433. */
  58434. get output(): NodeMaterialConnectionPoint;
  58435. protected _buildBlock(state: NodeMaterialBuildState): this;
  58436. }
  58437. }
  58438. declare module BABYLON {
  58439. /**
  58440. * Block used to get the derivative value on x and y of a given input
  58441. */
  58442. export class DerivativeBlock extends NodeMaterialBlock {
  58443. /**
  58444. * Create a new DerivativeBlock
  58445. * @param name defines the block name
  58446. */
  58447. constructor(name: string);
  58448. /**
  58449. * Gets the current class name
  58450. * @returns the class name
  58451. */
  58452. getClassName(): string;
  58453. /**
  58454. * Gets the input component
  58455. */
  58456. get input(): NodeMaterialConnectionPoint;
  58457. /**
  58458. * Gets the derivative output on x
  58459. */
  58460. get dx(): NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the derivative output on y
  58463. */
  58464. get dy(): NodeMaterialConnectionPoint;
  58465. protected _buildBlock(state: NodeMaterialBuildState): this;
  58466. }
  58467. }
  58468. declare module BABYLON {
  58469. /**
  58470. * Block used to add support for scene fog
  58471. */
  58472. export class FogBlock extends NodeMaterialBlock {
  58473. private _fogDistanceName;
  58474. private _fogParameters;
  58475. /**
  58476. * Create a new FogBlock
  58477. * @param name defines the block name
  58478. */
  58479. constructor(name: string);
  58480. /**
  58481. * Gets the current class name
  58482. * @returns the class name
  58483. */
  58484. getClassName(): string;
  58485. /**
  58486. * Gets the world position input component
  58487. */
  58488. get worldPosition(): NodeMaterialConnectionPoint;
  58489. /**
  58490. * Gets the view input component
  58491. */
  58492. get view(): NodeMaterialConnectionPoint;
  58493. /**
  58494. * Gets the color input component
  58495. */
  58496. get input(): NodeMaterialConnectionPoint;
  58497. /**
  58498. * Gets the fog color input component
  58499. */
  58500. get fogColor(): NodeMaterialConnectionPoint;
  58501. /**
  58502. * Gets the output component
  58503. */
  58504. get output(): NodeMaterialConnectionPoint;
  58505. autoConfigure(material: NodeMaterial): void;
  58506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58508. protected _buildBlock(state: NodeMaterialBuildState): this;
  58509. }
  58510. }
  58511. declare module BABYLON {
  58512. /**
  58513. * Block used to add light in the fragment shader
  58514. */
  58515. export class LightBlock extends NodeMaterialBlock {
  58516. private _lightId;
  58517. /**
  58518. * Gets or sets the light associated with this block
  58519. */
  58520. light: Nullable<Light>;
  58521. /**
  58522. * Create a new LightBlock
  58523. * @param name defines the block name
  58524. */
  58525. constructor(name: string);
  58526. /**
  58527. * Gets the current class name
  58528. * @returns the class name
  58529. */
  58530. getClassName(): string;
  58531. /**
  58532. * Gets the world position input component
  58533. */
  58534. get worldPosition(): NodeMaterialConnectionPoint;
  58535. /**
  58536. * Gets the world normal input component
  58537. */
  58538. get worldNormal(): NodeMaterialConnectionPoint;
  58539. /**
  58540. * Gets the camera (or eye) position component
  58541. */
  58542. get cameraPosition(): NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the glossiness component
  58545. */
  58546. get glossiness(): NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the glossinness power component
  58549. */
  58550. get glossPower(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the diffuse color component
  58553. */
  58554. get diffuseColor(): NodeMaterialConnectionPoint;
  58555. /**
  58556. * Gets the specular color component
  58557. */
  58558. get specularColor(): NodeMaterialConnectionPoint;
  58559. /**
  58560. * Gets the diffuse output component
  58561. */
  58562. get diffuseOutput(): NodeMaterialConnectionPoint;
  58563. /**
  58564. * Gets the specular output component
  58565. */
  58566. get specularOutput(): NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the shadow output component
  58569. */
  58570. get shadow(): NodeMaterialConnectionPoint;
  58571. autoConfigure(material: NodeMaterial): void;
  58572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58573. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58575. private _injectVertexCode;
  58576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58577. serialize(): any;
  58578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58579. }
  58580. }
  58581. declare module BABYLON {
  58582. /**
  58583. * Block used to multiply 2 values
  58584. */
  58585. export class MultiplyBlock extends NodeMaterialBlock {
  58586. /**
  58587. * Creates a new MultiplyBlock
  58588. * @param name defines the block name
  58589. */
  58590. constructor(name: string);
  58591. /**
  58592. * Gets the current class name
  58593. * @returns the class name
  58594. */
  58595. getClassName(): string;
  58596. /**
  58597. * Gets the left operand input component
  58598. */
  58599. get left(): NodeMaterialConnectionPoint;
  58600. /**
  58601. * Gets the right operand input component
  58602. */
  58603. get right(): NodeMaterialConnectionPoint;
  58604. /**
  58605. * Gets the output component
  58606. */
  58607. get output(): NodeMaterialConnectionPoint;
  58608. protected _buildBlock(state: NodeMaterialBuildState): this;
  58609. }
  58610. }
  58611. declare module BABYLON {
  58612. /**
  58613. * Block used to add 2 vectors
  58614. */
  58615. export class AddBlock extends NodeMaterialBlock {
  58616. /**
  58617. * Creates a new AddBlock
  58618. * @param name defines the block name
  58619. */
  58620. constructor(name: string);
  58621. /**
  58622. * Gets the current class name
  58623. * @returns the class name
  58624. */
  58625. getClassName(): string;
  58626. /**
  58627. * Gets the left operand input component
  58628. */
  58629. get left(): NodeMaterialConnectionPoint;
  58630. /**
  58631. * Gets the right operand input component
  58632. */
  58633. get right(): NodeMaterialConnectionPoint;
  58634. /**
  58635. * Gets the output component
  58636. */
  58637. get output(): NodeMaterialConnectionPoint;
  58638. protected _buildBlock(state: NodeMaterialBuildState): this;
  58639. }
  58640. }
  58641. declare module BABYLON {
  58642. /**
  58643. * Block used to scale a vector by a float
  58644. */
  58645. export class ScaleBlock extends NodeMaterialBlock {
  58646. /**
  58647. * Creates a new ScaleBlock
  58648. * @param name defines the block name
  58649. */
  58650. constructor(name: string);
  58651. /**
  58652. * Gets the current class name
  58653. * @returns the class name
  58654. */
  58655. getClassName(): string;
  58656. /**
  58657. * Gets the input component
  58658. */
  58659. get input(): NodeMaterialConnectionPoint;
  58660. /**
  58661. * Gets the factor input component
  58662. */
  58663. get factor(): NodeMaterialConnectionPoint;
  58664. /**
  58665. * Gets the output component
  58666. */
  58667. get output(): NodeMaterialConnectionPoint;
  58668. protected _buildBlock(state: NodeMaterialBuildState): this;
  58669. }
  58670. }
  58671. declare module BABYLON {
  58672. /**
  58673. * Block used to clamp a float
  58674. */
  58675. export class ClampBlock extends NodeMaterialBlock {
  58676. /** Gets or sets the minimum range */
  58677. minimum: number;
  58678. /** Gets or sets the maximum range */
  58679. maximum: number;
  58680. /**
  58681. * Creates a new ClampBlock
  58682. * @param name defines the block name
  58683. */
  58684. constructor(name: string);
  58685. /**
  58686. * Gets the current class name
  58687. * @returns the class name
  58688. */
  58689. getClassName(): string;
  58690. /**
  58691. * Gets the value input component
  58692. */
  58693. get value(): NodeMaterialConnectionPoint;
  58694. /**
  58695. * Gets the output component
  58696. */
  58697. get output(): NodeMaterialConnectionPoint;
  58698. protected _buildBlock(state: NodeMaterialBuildState): this;
  58699. protected _dumpPropertiesCode(): string;
  58700. serialize(): any;
  58701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58702. }
  58703. }
  58704. declare module BABYLON {
  58705. /**
  58706. * Block used to apply a cross product between 2 vectors
  58707. */
  58708. export class CrossBlock extends NodeMaterialBlock {
  58709. /**
  58710. * Creates a new CrossBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the left operand input component
  58721. */
  58722. get left(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the right operand input component
  58725. */
  58726. get right(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the output component
  58729. */
  58730. get output(): NodeMaterialConnectionPoint;
  58731. protected _buildBlock(state: NodeMaterialBuildState): this;
  58732. }
  58733. }
  58734. declare module BABYLON {
  58735. /**
  58736. * Block used to apply a dot product between 2 vectors
  58737. */
  58738. export class DotBlock extends NodeMaterialBlock {
  58739. /**
  58740. * Creates a new DotBlock
  58741. * @param name defines the block name
  58742. */
  58743. constructor(name: string);
  58744. /**
  58745. * Gets the current class name
  58746. * @returns the class name
  58747. */
  58748. getClassName(): string;
  58749. /**
  58750. * Gets the left operand input component
  58751. */
  58752. get left(): NodeMaterialConnectionPoint;
  58753. /**
  58754. * Gets the right operand input component
  58755. */
  58756. get right(): NodeMaterialConnectionPoint;
  58757. /**
  58758. * Gets the output component
  58759. */
  58760. get output(): NodeMaterialConnectionPoint;
  58761. protected _buildBlock(state: NodeMaterialBuildState): this;
  58762. }
  58763. }
  58764. declare module BABYLON {
  58765. /**
  58766. * Block used to remap a float from a range to a new one
  58767. */
  58768. export class RemapBlock extends NodeMaterialBlock {
  58769. /**
  58770. * Gets or sets the source range
  58771. */
  58772. sourceRange: Vector2;
  58773. /**
  58774. * Gets or sets the target range
  58775. */
  58776. targetRange: Vector2;
  58777. /**
  58778. * Creates a new RemapBlock
  58779. * @param name defines the block name
  58780. */
  58781. constructor(name: string);
  58782. /**
  58783. * Gets the current class name
  58784. * @returns the class name
  58785. */
  58786. getClassName(): string;
  58787. /**
  58788. * Gets the input component
  58789. */
  58790. get input(): NodeMaterialConnectionPoint;
  58791. /**
  58792. * Gets the source min input component
  58793. */
  58794. get sourceMin(): NodeMaterialConnectionPoint;
  58795. /**
  58796. * Gets the source max input component
  58797. */
  58798. get sourceMax(): NodeMaterialConnectionPoint;
  58799. /**
  58800. * Gets the target min input component
  58801. */
  58802. get targetMin(): NodeMaterialConnectionPoint;
  58803. /**
  58804. * Gets the target max input component
  58805. */
  58806. get targetMax(): NodeMaterialConnectionPoint;
  58807. /**
  58808. * Gets the output component
  58809. */
  58810. get output(): NodeMaterialConnectionPoint;
  58811. protected _buildBlock(state: NodeMaterialBuildState): this;
  58812. protected _dumpPropertiesCode(): string;
  58813. serialize(): any;
  58814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58815. }
  58816. }
  58817. declare module BABYLON {
  58818. /**
  58819. * Block used to normalize a vector
  58820. */
  58821. export class NormalizeBlock extends NodeMaterialBlock {
  58822. /**
  58823. * Creates a new NormalizeBlock
  58824. * @param name defines the block name
  58825. */
  58826. constructor(name: string);
  58827. /**
  58828. * Gets the current class name
  58829. * @returns the class name
  58830. */
  58831. getClassName(): string;
  58832. /**
  58833. * Gets the input component
  58834. */
  58835. get input(): NodeMaterialConnectionPoint;
  58836. /**
  58837. * Gets the output component
  58838. */
  58839. get output(): NodeMaterialConnectionPoint;
  58840. protected _buildBlock(state: NodeMaterialBuildState): this;
  58841. }
  58842. }
  58843. declare module BABYLON {
  58844. /**
  58845. * Operations supported by the Trigonometry block
  58846. */
  58847. export enum TrigonometryBlockOperations {
  58848. /** Cos */
  58849. Cos = 0,
  58850. /** Sin */
  58851. Sin = 1,
  58852. /** Abs */
  58853. Abs = 2,
  58854. /** Exp */
  58855. Exp = 3,
  58856. /** Exp2 */
  58857. Exp2 = 4,
  58858. /** Round */
  58859. Round = 5,
  58860. /** Floor */
  58861. Floor = 6,
  58862. /** Ceiling */
  58863. Ceiling = 7,
  58864. /** Square root */
  58865. Sqrt = 8,
  58866. /** Log */
  58867. Log = 9,
  58868. /** Tangent */
  58869. Tan = 10,
  58870. /** Arc tangent */
  58871. ArcTan = 11,
  58872. /** Arc cosinus */
  58873. ArcCos = 12,
  58874. /** Arc sinus */
  58875. ArcSin = 13,
  58876. /** Fraction */
  58877. Fract = 14,
  58878. /** Sign */
  58879. Sign = 15,
  58880. /** To radians (from degrees) */
  58881. Radians = 16,
  58882. /** To degrees (from radians) */
  58883. Degrees = 17
  58884. }
  58885. /**
  58886. * Block used to apply trigonometry operation to floats
  58887. */
  58888. export class TrigonometryBlock extends NodeMaterialBlock {
  58889. /**
  58890. * Gets or sets the operation applied by the block
  58891. */
  58892. operation: TrigonometryBlockOperations;
  58893. /**
  58894. * Creates a new TrigonometryBlock
  58895. * @param name defines the block name
  58896. */
  58897. constructor(name: string);
  58898. /**
  58899. * Gets the current class name
  58900. * @returns the class name
  58901. */
  58902. getClassName(): string;
  58903. /**
  58904. * Gets the input component
  58905. */
  58906. get input(): NodeMaterialConnectionPoint;
  58907. /**
  58908. * Gets the output component
  58909. */
  58910. get output(): NodeMaterialConnectionPoint;
  58911. protected _buildBlock(state: NodeMaterialBuildState): this;
  58912. serialize(): any;
  58913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58914. protected _dumpPropertiesCode(): string;
  58915. }
  58916. }
  58917. declare module BABYLON {
  58918. /**
  58919. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58920. */
  58921. export class ColorMergerBlock extends NodeMaterialBlock {
  58922. /**
  58923. * Create a new ColorMergerBlock
  58924. * @param name defines the block name
  58925. */
  58926. constructor(name: string);
  58927. /**
  58928. * Gets the current class name
  58929. * @returns the class name
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Gets the rgb component (input)
  58934. */
  58935. get rgbIn(): NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the r component (input)
  58938. */
  58939. get r(): NodeMaterialConnectionPoint;
  58940. /**
  58941. * Gets the g component (input)
  58942. */
  58943. get g(): NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the b component (input)
  58946. */
  58947. get b(): NodeMaterialConnectionPoint;
  58948. /**
  58949. * Gets the a component (input)
  58950. */
  58951. get a(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the rgba component (output)
  58954. */
  58955. get rgba(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the rgb component (output)
  58958. */
  58959. get rgbOut(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the rgb component (output)
  58962. * @deprecated Please use rgbOut instead.
  58963. */
  58964. get rgb(): NodeMaterialConnectionPoint;
  58965. protected _buildBlock(state: NodeMaterialBuildState): this;
  58966. }
  58967. }
  58968. declare module BABYLON {
  58969. /**
  58970. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58971. */
  58972. export class VectorMergerBlock extends NodeMaterialBlock {
  58973. /**
  58974. * Create a new VectorMergerBlock
  58975. * @param name defines the block name
  58976. */
  58977. constructor(name: string);
  58978. /**
  58979. * Gets the current class name
  58980. * @returns the class name
  58981. */
  58982. getClassName(): string;
  58983. /**
  58984. * Gets the xyz component (input)
  58985. */
  58986. get xyzIn(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the xy component (input)
  58989. */
  58990. get xyIn(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the x component (input)
  58993. */
  58994. get x(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the y component (input)
  58997. */
  58998. get y(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the z component (input)
  59001. */
  59002. get z(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the w component (input)
  59005. */
  59006. get w(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the xyzw component (output)
  59009. */
  59010. get xyzw(): NodeMaterialConnectionPoint;
  59011. /**
  59012. * Gets the xyz component (output)
  59013. */
  59014. get xyzOut(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the xy component (output)
  59017. */
  59018. get xyOut(): NodeMaterialConnectionPoint;
  59019. /**
  59020. * Gets the xy component (output)
  59021. * @deprecated Please use xyOut instead.
  59022. */
  59023. get xy(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the xyz component (output)
  59026. * @deprecated Please use xyzOut instead.
  59027. */
  59028. get xyz(): NodeMaterialConnectionPoint;
  59029. protected _buildBlock(state: NodeMaterialBuildState): this;
  59030. }
  59031. }
  59032. declare module BABYLON {
  59033. /**
  59034. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59035. */
  59036. export class ColorSplitterBlock extends NodeMaterialBlock {
  59037. /**
  59038. * Create a new ColorSplitterBlock
  59039. * @param name defines the block name
  59040. */
  59041. constructor(name: string);
  59042. /**
  59043. * Gets the current class name
  59044. * @returns the class name
  59045. */
  59046. getClassName(): string;
  59047. /**
  59048. * Gets the rgba component (input)
  59049. */
  59050. get rgba(): NodeMaterialConnectionPoint;
  59051. /**
  59052. * Gets the rgb component (input)
  59053. */
  59054. get rgbIn(): NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the rgb component (output)
  59057. */
  59058. get rgbOut(): NodeMaterialConnectionPoint;
  59059. /**
  59060. * Gets the r component (output)
  59061. */
  59062. get r(): NodeMaterialConnectionPoint;
  59063. /**
  59064. * Gets the g component (output)
  59065. */
  59066. get g(): NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the b component (output)
  59069. */
  59070. get b(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the a component (output)
  59073. */
  59074. get a(): NodeMaterialConnectionPoint;
  59075. protected _inputRename(name: string): string;
  59076. protected _outputRename(name: string): string;
  59077. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59078. }
  59079. }
  59080. declare module BABYLON {
  59081. /**
  59082. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59083. */
  59084. export class VectorSplitterBlock extends NodeMaterialBlock {
  59085. /**
  59086. * Create a new VectorSplitterBlock
  59087. * @param name defines the block name
  59088. */
  59089. constructor(name: string);
  59090. /**
  59091. * Gets the current class name
  59092. * @returns the class name
  59093. */
  59094. getClassName(): string;
  59095. /**
  59096. * Gets the xyzw component (input)
  59097. */
  59098. get xyzw(): NodeMaterialConnectionPoint;
  59099. /**
  59100. * Gets the xyz component (input)
  59101. */
  59102. get xyzIn(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the xy component (input)
  59105. */
  59106. get xyIn(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the xyz component (output)
  59109. */
  59110. get xyzOut(): NodeMaterialConnectionPoint;
  59111. /**
  59112. * Gets the xy component (output)
  59113. */
  59114. get xyOut(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the x component (output)
  59117. */
  59118. get x(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the y component (output)
  59121. */
  59122. get y(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the z component (output)
  59125. */
  59126. get z(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the w component (output)
  59129. */
  59130. get w(): NodeMaterialConnectionPoint;
  59131. protected _inputRename(name: string): string;
  59132. protected _outputRename(name: string): string;
  59133. protected _buildBlock(state: NodeMaterialBuildState): this;
  59134. }
  59135. }
  59136. declare module BABYLON {
  59137. /**
  59138. * Block used to lerp between 2 values
  59139. */
  59140. export class LerpBlock extends NodeMaterialBlock {
  59141. /**
  59142. * Creates a new LerpBlock
  59143. * @param name defines the block name
  59144. */
  59145. constructor(name: string);
  59146. /**
  59147. * Gets the current class name
  59148. * @returns the class name
  59149. */
  59150. getClassName(): string;
  59151. /**
  59152. * Gets the left operand input component
  59153. */
  59154. get left(): NodeMaterialConnectionPoint;
  59155. /**
  59156. * Gets the right operand input component
  59157. */
  59158. get right(): NodeMaterialConnectionPoint;
  59159. /**
  59160. * Gets the gradient operand input component
  59161. */
  59162. get gradient(): NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the output component
  59165. */
  59166. get output(): NodeMaterialConnectionPoint;
  59167. protected _buildBlock(state: NodeMaterialBuildState): this;
  59168. }
  59169. }
  59170. declare module BABYLON {
  59171. /**
  59172. * Block used to divide 2 vectors
  59173. */
  59174. export class DivideBlock extends NodeMaterialBlock {
  59175. /**
  59176. * Creates a new DivideBlock
  59177. * @param name defines the block name
  59178. */
  59179. constructor(name: string);
  59180. /**
  59181. * Gets the current class name
  59182. * @returns the class name
  59183. */
  59184. getClassName(): string;
  59185. /**
  59186. * Gets the left operand input component
  59187. */
  59188. get left(): NodeMaterialConnectionPoint;
  59189. /**
  59190. * Gets the right operand input component
  59191. */
  59192. get right(): NodeMaterialConnectionPoint;
  59193. /**
  59194. * Gets the output component
  59195. */
  59196. get output(): NodeMaterialConnectionPoint;
  59197. protected _buildBlock(state: NodeMaterialBuildState): this;
  59198. }
  59199. }
  59200. declare module BABYLON {
  59201. /**
  59202. * Block used to subtract 2 vectors
  59203. */
  59204. export class SubtractBlock extends NodeMaterialBlock {
  59205. /**
  59206. * Creates a new SubtractBlock
  59207. * @param name defines the block name
  59208. */
  59209. constructor(name: string);
  59210. /**
  59211. * Gets the current class name
  59212. * @returns the class name
  59213. */
  59214. getClassName(): string;
  59215. /**
  59216. * Gets the left operand input component
  59217. */
  59218. get left(): NodeMaterialConnectionPoint;
  59219. /**
  59220. * Gets the right operand input component
  59221. */
  59222. get right(): NodeMaterialConnectionPoint;
  59223. /**
  59224. * Gets the output component
  59225. */
  59226. get output(): NodeMaterialConnectionPoint;
  59227. protected _buildBlock(state: NodeMaterialBuildState): this;
  59228. }
  59229. }
  59230. declare module BABYLON {
  59231. /**
  59232. * Block used to step a value
  59233. */
  59234. export class StepBlock extends NodeMaterialBlock {
  59235. /**
  59236. * Creates a new StepBlock
  59237. * @param name defines the block name
  59238. */
  59239. constructor(name: string);
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the value operand input component
  59247. */
  59248. get value(): NodeMaterialConnectionPoint;
  59249. /**
  59250. * Gets the edge operand input component
  59251. */
  59252. get edge(): NodeMaterialConnectionPoint;
  59253. /**
  59254. * Gets the output component
  59255. */
  59256. get output(): NodeMaterialConnectionPoint;
  59257. protected _buildBlock(state: NodeMaterialBuildState): this;
  59258. }
  59259. }
  59260. declare module BABYLON {
  59261. /**
  59262. * Block used to get the opposite (1 - x) of a value
  59263. */
  59264. export class OneMinusBlock extends NodeMaterialBlock {
  59265. /**
  59266. * Creates a new OneMinusBlock
  59267. * @param name defines the block name
  59268. */
  59269. constructor(name: string);
  59270. /**
  59271. * Gets the current class name
  59272. * @returns the class name
  59273. */
  59274. getClassName(): string;
  59275. /**
  59276. * Gets the input component
  59277. */
  59278. get input(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the output component
  59281. */
  59282. get output(): NodeMaterialConnectionPoint;
  59283. protected _buildBlock(state: NodeMaterialBuildState): this;
  59284. }
  59285. }
  59286. declare module BABYLON {
  59287. /**
  59288. * Block used to get the view direction
  59289. */
  59290. export class ViewDirectionBlock extends NodeMaterialBlock {
  59291. /**
  59292. * Creates a new ViewDirectionBlock
  59293. * @param name defines the block name
  59294. */
  59295. constructor(name: string);
  59296. /**
  59297. * Gets the current class name
  59298. * @returns the class name
  59299. */
  59300. getClassName(): string;
  59301. /**
  59302. * Gets the world position component
  59303. */
  59304. get worldPosition(): NodeMaterialConnectionPoint;
  59305. /**
  59306. * Gets the camera position component
  59307. */
  59308. get cameraPosition(): NodeMaterialConnectionPoint;
  59309. /**
  59310. * Gets the output component
  59311. */
  59312. get output(): NodeMaterialConnectionPoint;
  59313. autoConfigure(material: NodeMaterial): void;
  59314. protected _buildBlock(state: NodeMaterialBuildState): this;
  59315. }
  59316. }
  59317. declare module BABYLON {
  59318. /**
  59319. * Block used to compute fresnel value
  59320. */
  59321. export class FresnelBlock extends NodeMaterialBlock {
  59322. /**
  59323. * Create a new FresnelBlock
  59324. * @param name defines the block name
  59325. */
  59326. constructor(name: string);
  59327. /**
  59328. * Gets the current class name
  59329. * @returns the class name
  59330. */
  59331. getClassName(): string;
  59332. /**
  59333. * Gets the world normal input component
  59334. */
  59335. get worldNormal(): NodeMaterialConnectionPoint;
  59336. /**
  59337. * Gets the view direction input component
  59338. */
  59339. get viewDirection(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the bias input component
  59342. */
  59343. get bias(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the camera (or eye) position component
  59346. */
  59347. get power(): NodeMaterialConnectionPoint;
  59348. /**
  59349. * Gets the fresnel output component
  59350. */
  59351. get fresnel(): NodeMaterialConnectionPoint;
  59352. autoConfigure(material: NodeMaterial): void;
  59353. protected _buildBlock(state: NodeMaterialBuildState): this;
  59354. }
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * Block used to get the max of 2 values
  59359. */
  59360. export class MaxBlock extends NodeMaterialBlock {
  59361. /**
  59362. * Creates a new MaxBlock
  59363. * @param name defines the block name
  59364. */
  59365. constructor(name: string);
  59366. /**
  59367. * Gets the current class name
  59368. * @returns the class name
  59369. */
  59370. getClassName(): string;
  59371. /**
  59372. * Gets the left operand input component
  59373. */
  59374. get left(): NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the right operand input component
  59377. */
  59378. get right(): NodeMaterialConnectionPoint;
  59379. /**
  59380. * Gets the output component
  59381. */
  59382. get output(): NodeMaterialConnectionPoint;
  59383. protected _buildBlock(state: NodeMaterialBuildState): this;
  59384. }
  59385. }
  59386. declare module BABYLON {
  59387. /**
  59388. * Block used to get the min of 2 values
  59389. */
  59390. export class MinBlock extends NodeMaterialBlock {
  59391. /**
  59392. * Creates a new MinBlock
  59393. * @param name defines the block name
  59394. */
  59395. constructor(name: string);
  59396. /**
  59397. * Gets the current class name
  59398. * @returns the class name
  59399. */
  59400. getClassName(): string;
  59401. /**
  59402. * Gets the left operand input component
  59403. */
  59404. get left(): NodeMaterialConnectionPoint;
  59405. /**
  59406. * Gets the right operand input component
  59407. */
  59408. get right(): NodeMaterialConnectionPoint;
  59409. /**
  59410. * Gets the output component
  59411. */
  59412. get output(): NodeMaterialConnectionPoint;
  59413. protected _buildBlock(state: NodeMaterialBuildState): this;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /**
  59418. * Block used to get the distance between 2 values
  59419. */
  59420. export class DistanceBlock extends NodeMaterialBlock {
  59421. /**
  59422. * Creates a new DistanceBlock
  59423. * @param name defines the block name
  59424. */
  59425. constructor(name: string);
  59426. /**
  59427. * Gets the current class name
  59428. * @returns the class name
  59429. */
  59430. getClassName(): string;
  59431. /**
  59432. * Gets the left operand input component
  59433. */
  59434. get left(): NodeMaterialConnectionPoint;
  59435. /**
  59436. * Gets the right operand input component
  59437. */
  59438. get right(): NodeMaterialConnectionPoint;
  59439. /**
  59440. * Gets the output component
  59441. */
  59442. get output(): NodeMaterialConnectionPoint;
  59443. protected _buildBlock(state: NodeMaterialBuildState): this;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * Block used to get the length of a vector
  59449. */
  59450. export class LengthBlock extends NodeMaterialBlock {
  59451. /**
  59452. * Creates a new LengthBlock
  59453. * @param name defines the block name
  59454. */
  59455. constructor(name: string);
  59456. /**
  59457. * Gets the current class name
  59458. * @returns the class name
  59459. */
  59460. getClassName(): string;
  59461. /**
  59462. * Gets the value input component
  59463. */
  59464. get value(): NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the output component
  59467. */
  59468. get output(): NodeMaterialConnectionPoint;
  59469. protected _buildBlock(state: NodeMaterialBuildState): this;
  59470. }
  59471. }
  59472. declare module BABYLON {
  59473. /**
  59474. * Block used to get negative version of a value (i.e. x * -1)
  59475. */
  59476. export class NegateBlock extends NodeMaterialBlock {
  59477. /**
  59478. * Creates a new NegateBlock
  59479. * @param name defines the block name
  59480. */
  59481. constructor(name: string);
  59482. /**
  59483. * Gets the current class name
  59484. * @returns the class name
  59485. */
  59486. getClassName(): string;
  59487. /**
  59488. * Gets the value input component
  59489. */
  59490. get value(): NodeMaterialConnectionPoint;
  59491. /**
  59492. * Gets the output component
  59493. */
  59494. get output(): NodeMaterialConnectionPoint;
  59495. protected _buildBlock(state: NodeMaterialBuildState): this;
  59496. }
  59497. }
  59498. declare module BABYLON {
  59499. /**
  59500. * Block used to get the value of the first parameter raised to the power of the second
  59501. */
  59502. export class PowBlock extends NodeMaterialBlock {
  59503. /**
  59504. * Creates a new PowBlock
  59505. * @param name defines the block name
  59506. */
  59507. constructor(name: string);
  59508. /**
  59509. * Gets the current class name
  59510. * @returns the class name
  59511. */
  59512. getClassName(): string;
  59513. /**
  59514. * Gets the value operand input component
  59515. */
  59516. get value(): NodeMaterialConnectionPoint;
  59517. /**
  59518. * Gets the power operand input component
  59519. */
  59520. get power(): NodeMaterialConnectionPoint;
  59521. /**
  59522. * Gets the output component
  59523. */
  59524. get output(): NodeMaterialConnectionPoint;
  59525. protected _buildBlock(state: NodeMaterialBuildState): this;
  59526. }
  59527. }
  59528. declare module BABYLON {
  59529. /**
  59530. * Block used to get a random number
  59531. */
  59532. export class RandomNumberBlock extends NodeMaterialBlock {
  59533. /**
  59534. * Creates a new RandomNumberBlock
  59535. * @param name defines the block name
  59536. */
  59537. constructor(name: string);
  59538. /**
  59539. * Gets the current class name
  59540. * @returns the class name
  59541. */
  59542. getClassName(): string;
  59543. /**
  59544. * Gets the seed input component
  59545. */
  59546. get seed(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the output component
  59549. */
  59550. get output(): NodeMaterialConnectionPoint;
  59551. protected _buildBlock(state: NodeMaterialBuildState): this;
  59552. }
  59553. }
  59554. declare module BABYLON {
  59555. /**
  59556. * Block used to compute arc tangent of 2 values
  59557. */
  59558. export class ArcTan2Block extends NodeMaterialBlock {
  59559. /**
  59560. * Creates a new ArcTan2Block
  59561. * @param name defines the block name
  59562. */
  59563. constructor(name: string);
  59564. /**
  59565. * Gets the current class name
  59566. * @returns the class name
  59567. */
  59568. getClassName(): string;
  59569. /**
  59570. * Gets the x operand input component
  59571. */
  59572. get x(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the y operand input component
  59575. */
  59576. get y(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the output component
  59579. */
  59580. get output(): NodeMaterialConnectionPoint;
  59581. protected _buildBlock(state: NodeMaterialBuildState): this;
  59582. }
  59583. }
  59584. declare module BABYLON {
  59585. /**
  59586. * Block used to smooth step a value
  59587. */
  59588. export class SmoothStepBlock extends NodeMaterialBlock {
  59589. /**
  59590. * Creates a new SmoothStepBlock
  59591. * @param name defines the block name
  59592. */
  59593. constructor(name: string);
  59594. /**
  59595. * Gets the current class name
  59596. * @returns the class name
  59597. */
  59598. getClassName(): string;
  59599. /**
  59600. * Gets the value operand input component
  59601. */
  59602. get value(): NodeMaterialConnectionPoint;
  59603. /**
  59604. * Gets the first edge operand input component
  59605. */
  59606. get edge0(): NodeMaterialConnectionPoint;
  59607. /**
  59608. * Gets the second edge operand input component
  59609. */
  59610. get edge1(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the output component
  59613. */
  59614. get output(): NodeMaterialConnectionPoint;
  59615. protected _buildBlock(state: NodeMaterialBuildState): this;
  59616. }
  59617. }
  59618. declare module BABYLON {
  59619. /**
  59620. * Block used to get the reciprocal (1 / x) of a value
  59621. */
  59622. export class ReciprocalBlock extends NodeMaterialBlock {
  59623. /**
  59624. * Creates a new ReciprocalBlock
  59625. * @param name defines the block name
  59626. */
  59627. constructor(name: string);
  59628. /**
  59629. * Gets the current class name
  59630. * @returns the class name
  59631. */
  59632. getClassName(): string;
  59633. /**
  59634. * Gets the input component
  59635. */
  59636. get input(): NodeMaterialConnectionPoint;
  59637. /**
  59638. * Gets the output component
  59639. */
  59640. get output(): NodeMaterialConnectionPoint;
  59641. protected _buildBlock(state: NodeMaterialBuildState): this;
  59642. }
  59643. }
  59644. declare module BABYLON {
  59645. /**
  59646. * Block used to replace a color by another one
  59647. */
  59648. export class ReplaceColorBlock extends NodeMaterialBlock {
  59649. /**
  59650. * Creates a new ReplaceColorBlock
  59651. * @param name defines the block name
  59652. */
  59653. constructor(name: string);
  59654. /**
  59655. * Gets the current class name
  59656. * @returns the class name
  59657. */
  59658. getClassName(): string;
  59659. /**
  59660. * Gets the value input component
  59661. */
  59662. get value(): NodeMaterialConnectionPoint;
  59663. /**
  59664. * Gets the reference input component
  59665. */
  59666. get reference(): NodeMaterialConnectionPoint;
  59667. /**
  59668. * Gets the distance input component
  59669. */
  59670. get distance(): NodeMaterialConnectionPoint;
  59671. /**
  59672. * Gets the replacement input component
  59673. */
  59674. get replacement(): NodeMaterialConnectionPoint;
  59675. /**
  59676. * Gets the output component
  59677. */
  59678. get output(): NodeMaterialConnectionPoint;
  59679. protected _buildBlock(state: NodeMaterialBuildState): this;
  59680. }
  59681. }
  59682. declare module BABYLON {
  59683. /**
  59684. * Block used to posterize a value
  59685. * @see https://en.wikipedia.org/wiki/Posterization
  59686. */
  59687. export class PosterizeBlock extends NodeMaterialBlock {
  59688. /**
  59689. * Creates a new PosterizeBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the value input component
  59700. */
  59701. get value(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the steps input component
  59704. */
  59705. get steps(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the output component
  59708. */
  59709. get output(): NodeMaterialConnectionPoint;
  59710. protected _buildBlock(state: NodeMaterialBuildState): this;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * Operations supported by the Wave block
  59716. */
  59717. export enum WaveBlockKind {
  59718. /** SawTooth */
  59719. SawTooth = 0,
  59720. /** Square */
  59721. Square = 1,
  59722. /** Triangle */
  59723. Triangle = 2
  59724. }
  59725. /**
  59726. * Block used to apply wave operation to floats
  59727. */
  59728. export class WaveBlock extends NodeMaterialBlock {
  59729. /**
  59730. * Gets or sets the kibnd of wave to be applied by the block
  59731. */
  59732. kind: WaveBlockKind;
  59733. /**
  59734. * Creates a new WaveBlock
  59735. * @param name defines the block name
  59736. */
  59737. constructor(name: string);
  59738. /**
  59739. * Gets the current class name
  59740. * @returns the class name
  59741. */
  59742. getClassName(): string;
  59743. /**
  59744. * Gets the input component
  59745. */
  59746. get input(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the output component
  59749. */
  59750. get output(): NodeMaterialConnectionPoint;
  59751. protected _buildBlock(state: NodeMaterialBuildState): this;
  59752. serialize(): any;
  59753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59754. }
  59755. }
  59756. declare module BABYLON {
  59757. /**
  59758. * Class used to store a color step for the GradientBlock
  59759. */
  59760. export class GradientBlockColorStep {
  59761. /**
  59762. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59763. */
  59764. step: number;
  59765. /**
  59766. * Gets or sets the color associated with this step
  59767. */
  59768. color: Color3;
  59769. /**
  59770. * Creates a new GradientBlockColorStep
  59771. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59772. * @param color defines the color associated with this step
  59773. */
  59774. constructor(
  59775. /**
  59776. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59777. */
  59778. step: number,
  59779. /**
  59780. * Gets or sets the color associated with this step
  59781. */
  59782. color: Color3);
  59783. }
  59784. /**
  59785. * Block used to return a color from a gradient based on an input value between 0 and 1
  59786. */
  59787. export class GradientBlock extends NodeMaterialBlock {
  59788. /**
  59789. * Gets or sets the list of color steps
  59790. */
  59791. colorSteps: GradientBlockColorStep[];
  59792. /**
  59793. * Creates a new GradientBlock
  59794. * @param name defines the block name
  59795. */
  59796. constructor(name: string);
  59797. /**
  59798. * Gets the current class name
  59799. * @returns the class name
  59800. */
  59801. getClassName(): string;
  59802. /**
  59803. * Gets the gradient input component
  59804. */
  59805. get gradient(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the output component
  59808. */
  59809. get output(): NodeMaterialConnectionPoint;
  59810. private _writeColorConstant;
  59811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59812. serialize(): any;
  59813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59814. protected _dumpPropertiesCode(): string;
  59815. }
  59816. }
  59817. declare module BABYLON {
  59818. /**
  59819. * Block used to normalize lerp between 2 values
  59820. */
  59821. export class NLerpBlock extends NodeMaterialBlock {
  59822. /**
  59823. * Creates a new NLerpBlock
  59824. * @param name defines the block name
  59825. */
  59826. constructor(name: string);
  59827. /**
  59828. * Gets the current class name
  59829. * @returns the class name
  59830. */
  59831. getClassName(): string;
  59832. /**
  59833. * Gets the left operand input component
  59834. */
  59835. get left(): NodeMaterialConnectionPoint;
  59836. /**
  59837. * Gets the right operand input component
  59838. */
  59839. get right(): NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the gradient operand input component
  59842. */
  59843. get gradient(): NodeMaterialConnectionPoint;
  59844. /**
  59845. * Gets the output component
  59846. */
  59847. get output(): NodeMaterialConnectionPoint;
  59848. protected _buildBlock(state: NodeMaterialBuildState): this;
  59849. }
  59850. }
  59851. declare module BABYLON {
  59852. /**
  59853. * block used to Generate a Worley Noise 3D Noise Pattern
  59854. */
  59855. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59856. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59857. manhattanDistance: boolean;
  59858. /**
  59859. * Creates a new WorleyNoise3DBlock
  59860. * @param name defines the block name
  59861. */
  59862. constructor(name: string);
  59863. /**
  59864. * Gets the current class name
  59865. * @returns the class name
  59866. */
  59867. getClassName(): string;
  59868. /**
  59869. * Gets the seed input component
  59870. */
  59871. get seed(): NodeMaterialConnectionPoint;
  59872. /**
  59873. * Gets the jitter input component
  59874. */
  59875. get jitter(): NodeMaterialConnectionPoint;
  59876. /**
  59877. * Gets the output component
  59878. */
  59879. get output(): NodeMaterialConnectionPoint;
  59880. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59881. /**
  59882. * Exposes the properties to the UI?
  59883. */
  59884. protected _dumpPropertiesCode(): string;
  59885. /**
  59886. * Exposes the properties to the Seralize?
  59887. */
  59888. serialize(): any;
  59889. /**
  59890. * Exposes the properties to the deseralize?
  59891. */
  59892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59893. }
  59894. }
  59895. declare module BABYLON {
  59896. /**
  59897. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59898. */
  59899. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59900. /**
  59901. * Creates a new SimplexPerlin3DBlock
  59902. * @param name defines the block name
  59903. */
  59904. constructor(name: string);
  59905. /**
  59906. * Gets the current class name
  59907. * @returns the class name
  59908. */
  59909. getClassName(): string;
  59910. /**
  59911. * Gets the seed operand input component
  59912. */
  59913. get seed(): NodeMaterialConnectionPoint;
  59914. /**
  59915. * Gets the output component
  59916. */
  59917. get output(): NodeMaterialConnectionPoint;
  59918. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59919. }
  59920. }
  59921. declare module BABYLON {
  59922. /**
  59923. * Block used to blend normals
  59924. */
  59925. export class NormalBlendBlock extends NodeMaterialBlock {
  59926. /**
  59927. * Creates a new NormalBlendBlock
  59928. * @param name defines the block name
  59929. */
  59930. constructor(name: string);
  59931. /**
  59932. * Gets the current class name
  59933. * @returns the class name
  59934. */
  59935. getClassName(): string;
  59936. /**
  59937. * Gets the first input component
  59938. */
  59939. get normalMap0(): NodeMaterialConnectionPoint;
  59940. /**
  59941. * Gets the second input component
  59942. */
  59943. get normalMap1(): NodeMaterialConnectionPoint;
  59944. /**
  59945. * Gets the output component
  59946. */
  59947. get output(): NodeMaterialConnectionPoint;
  59948. protected _buildBlock(state: NodeMaterialBuildState): this;
  59949. }
  59950. }
  59951. declare module BABYLON {
  59952. /**
  59953. * Block used to rotate a 2d vector by a given angle
  59954. */
  59955. export class Rotate2dBlock extends NodeMaterialBlock {
  59956. /**
  59957. * Creates a new Rotate2dBlock
  59958. * @param name defines the block name
  59959. */
  59960. constructor(name: string);
  59961. /**
  59962. * Gets the current class name
  59963. * @returns the class name
  59964. */
  59965. getClassName(): string;
  59966. /**
  59967. * Gets the input vector
  59968. */
  59969. get input(): NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the input angle
  59972. */
  59973. get angle(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the output component
  59976. */
  59977. get output(): NodeMaterialConnectionPoint;
  59978. autoConfigure(material: NodeMaterial): void;
  59979. protected _buildBlock(state: NodeMaterialBuildState): this;
  59980. }
  59981. }
  59982. declare module BABYLON {
  59983. /**
  59984. * Block used to get the reflected vector from a direction and a normal
  59985. */
  59986. export class ReflectBlock extends NodeMaterialBlock {
  59987. /**
  59988. * Creates a new ReflectBlock
  59989. * @param name defines the block name
  59990. */
  59991. constructor(name: string);
  59992. /**
  59993. * Gets the current class name
  59994. * @returns the class name
  59995. */
  59996. getClassName(): string;
  59997. /**
  59998. * Gets the incident component
  59999. */
  60000. get incident(): NodeMaterialConnectionPoint;
  60001. /**
  60002. * Gets the normal component
  60003. */
  60004. get normal(): NodeMaterialConnectionPoint;
  60005. /**
  60006. * Gets the output component
  60007. */
  60008. get output(): NodeMaterialConnectionPoint;
  60009. protected _buildBlock(state: NodeMaterialBuildState): this;
  60010. }
  60011. }
  60012. declare module BABYLON {
  60013. /**
  60014. * Block used to get the refracted vector from a direction and a normal
  60015. */
  60016. export class RefractBlock extends NodeMaterialBlock {
  60017. /**
  60018. * Creates a new RefractBlock
  60019. * @param name defines the block name
  60020. */
  60021. constructor(name: string);
  60022. /**
  60023. * Gets the current class name
  60024. * @returns the class name
  60025. */
  60026. getClassName(): string;
  60027. /**
  60028. * Gets the incident component
  60029. */
  60030. get incident(): NodeMaterialConnectionPoint;
  60031. /**
  60032. * Gets the normal component
  60033. */
  60034. get normal(): NodeMaterialConnectionPoint;
  60035. /**
  60036. * Gets the index of refraction component
  60037. */
  60038. get ior(): NodeMaterialConnectionPoint;
  60039. /**
  60040. * Gets the output component
  60041. */
  60042. get output(): NodeMaterialConnectionPoint;
  60043. protected _buildBlock(state: NodeMaterialBuildState): this;
  60044. }
  60045. }
  60046. declare module BABYLON {
  60047. /**
  60048. * Block used to desaturate a color
  60049. */
  60050. export class DesaturateBlock extends NodeMaterialBlock {
  60051. /**
  60052. * Creates a new DesaturateBlock
  60053. * @param name defines the block name
  60054. */
  60055. constructor(name: string);
  60056. /**
  60057. * Gets the current class name
  60058. * @returns the class name
  60059. */
  60060. getClassName(): string;
  60061. /**
  60062. * Gets the color operand input component
  60063. */
  60064. get color(): NodeMaterialConnectionPoint;
  60065. /**
  60066. * Gets the level operand input component
  60067. */
  60068. get level(): NodeMaterialConnectionPoint;
  60069. /**
  60070. * Gets the output component
  60071. */
  60072. get output(): NodeMaterialConnectionPoint;
  60073. protected _buildBlock(state: NodeMaterialBuildState): this;
  60074. }
  60075. }
  60076. declare module BABYLON {
  60077. /**
  60078. * Effect Render Options
  60079. */
  60080. export interface IEffectRendererOptions {
  60081. /**
  60082. * Defines the vertices positions.
  60083. */
  60084. positions?: number[];
  60085. /**
  60086. * Defines the indices.
  60087. */
  60088. indices?: number[];
  60089. }
  60090. /**
  60091. * Helper class to render one or more effects
  60092. */
  60093. export class EffectRenderer {
  60094. private engine;
  60095. private static _DefaultOptions;
  60096. private _vertexBuffers;
  60097. private _indexBuffer;
  60098. private _ringBufferIndex;
  60099. private _ringScreenBuffer;
  60100. private _fullscreenViewport;
  60101. private _getNextFrameBuffer;
  60102. /**
  60103. * Creates an effect renderer
  60104. * @param engine the engine to use for rendering
  60105. * @param options defines the options of the effect renderer
  60106. */
  60107. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60108. /**
  60109. * Sets the current viewport in normalized coordinates 0-1
  60110. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60111. */
  60112. setViewport(viewport?: Viewport): void;
  60113. /**
  60114. * Binds the embedded attributes buffer to the effect.
  60115. * @param effect Defines the effect to bind the attributes for
  60116. */
  60117. bindBuffers(effect: Effect): void;
  60118. /**
  60119. * Sets the current effect wrapper to use during draw.
  60120. * The effect needs to be ready before calling this api.
  60121. * This also sets the default full screen position attribute.
  60122. * @param effectWrapper Defines the effect to draw with
  60123. */
  60124. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60125. /**
  60126. * Draws a full screen quad.
  60127. */
  60128. draw(): void;
  60129. /**
  60130. * renders one or more effects to a specified texture
  60131. * @param effectWrappers list of effects to renderer
  60132. * @param outputTexture texture to draw to, if null it will render to the screen
  60133. */
  60134. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60135. /**
  60136. * Disposes of the effect renderer
  60137. */
  60138. dispose(): void;
  60139. }
  60140. /**
  60141. * Options to create an EffectWrapper
  60142. */
  60143. interface EffectWrapperCreationOptions {
  60144. /**
  60145. * Engine to use to create the effect
  60146. */
  60147. engine: ThinEngine;
  60148. /**
  60149. * Fragment shader for the effect
  60150. */
  60151. fragmentShader: string;
  60152. /**
  60153. * Vertex shader for the effect
  60154. */
  60155. vertexShader?: string;
  60156. /**
  60157. * Attributes to use in the shader
  60158. */
  60159. attributeNames?: Array<string>;
  60160. /**
  60161. * Uniforms to use in the shader
  60162. */
  60163. uniformNames?: Array<string>;
  60164. /**
  60165. * Texture sampler names to use in the shader
  60166. */
  60167. samplerNames?: Array<string>;
  60168. /**
  60169. * The friendly name of the effect displayed in Spector.
  60170. */
  60171. name?: string;
  60172. }
  60173. /**
  60174. * Wraps an effect to be used for rendering
  60175. */
  60176. export class EffectWrapper {
  60177. /**
  60178. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60179. */
  60180. onApplyObservable: Observable<{}>;
  60181. /**
  60182. * The underlying effect
  60183. */
  60184. effect: Effect;
  60185. /**
  60186. * Creates an effect to be renderer
  60187. * @param creationOptions options to create the effect
  60188. */
  60189. constructor(creationOptions: EffectWrapperCreationOptions);
  60190. /**
  60191. * Disposes of the effect wrapper
  60192. */
  60193. dispose(): void;
  60194. }
  60195. }
  60196. declare module BABYLON {
  60197. /**
  60198. * Helper class to push actions to a pool of workers.
  60199. */
  60200. export class WorkerPool implements IDisposable {
  60201. private _workerInfos;
  60202. private _pendingActions;
  60203. /**
  60204. * Constructor
  60205. * @param workers Array of workers to use for actions
  60206. */
  60207. constructor(workers: Array<Worker>);
  60208. /**
  60209. * Terminates all workers and clears any pending actions.
  60210. */
  60211. dispose(): void;
  60212. /**
  60213. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60214. * pended until a worker has completed its action.
  60215. * @param action The action to perform. Call onComplete when the action is complete.
  60216. */
  60217. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60218. private _execute;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Configuration for Draco compression
  60224. */
  60225. export interface IDracoCompressionConfiguration {
  60226. /**
  60227. * Configuration for the decoder.
  60228. */
  60229. decoder: {
  60230. /**
  60231. * The url to the WebAssembly module.
  60232. */
  60233. wasmUrl?: string;
  60234. /**
  60235. * The url to the WebAssembly binary.
  60236. */
  60237. wasmBinaryUrl?: string;
  60238. /**
  60239. * The url to the fallback JavaScript module.
  60240. */
  60241. fallbackUrl?: string;
  60242. };
  60243. }
  60244. /**
  60245. * Draco compression (https://google.github.io/draco/)
  60246. *
  60247. * This class wraps the Draco module.
  60248. *
  60249. * **Encoder**
  60250. *
  60251. * The encoder is not currently implemented.
  60252. *
  60253. * **Decoder**
  60254. *
  60255. * 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.
  60256. *
  60257. * To update the configuration, use the following code:
  60258. * ```javascript
  60259. * DracoCompression.Configuration = {
  60260. * decoder: {
  60261. * wasmUrl: "<url to the WebAssembly library>",
  60262. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60263. * fallbackUrl: "<url to the fallback JavaScript library>",
  60264. * }
  60265. * };
  60266. * ```
  60267. *
  60268. * 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.
  60269. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60270. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60271. *
  60272. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60273. * ```javascript
  60274. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60275. * ```
  60276. *
  60277. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60278. */
  60279. export class DracoCompression implements IDisposable {
  60280. private _workerPoolPromise?;
  60281. private _decoderModulePromise?;
  60282. /**
  60283. * The configuration. Defaults to the following urls:
  60284. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60285. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60286. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60287. */
  60288. static Configuration: IDracoCompressionConfiguration;
  60289. /**
  60290. * Returns true if the decoder configuration is available.
  60291. */
  60292. static get DecoderAvailable(): boolean;
  60293. /**
  60294. * Default number of workers to create when creating the draco compression object.
  60295. */
  60296. static DefaultNumWorkers: number;
  60297. private static GetDefaultNumWorkers;
  60298. private static _Default;
  60299. /**
  60300. * Default instance for the draco compression object.
  60301. */
  60302. static get Default(): DracoCompression;
  60303. /**
  60304. * Constructor
  60305. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60306. */
  60307. constructor(numWorkers?: number);
  60308. /**
  60309. * Stop all async operations and release resources.
  60310. */
  60311. dispose(): void;
  60312. /**
  60313. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60314. * @returns a promise that resolves when ready
  60315. */
  60316. whenReadyAsync(): Promise<void>;
  60317. /**
  60318. * Decode Draco compressed mesh data to vertex data.
  60319. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60320. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60321. * @returns A promise that resolves with the decoded vertex data
  60322. */
  60323. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60324. [kind: string]: number;
  60325. }): Promise<VertexData>;
  60326. }
  60327. }
  60328. declare module BABYLON {
  60329. /**
  60330. * Class for building Constructive Solid Geometry
  60331. */
  60332. export class CSG {
  60333. private polygons;
  60334. /**
  60335. * The world matrix
  60336. */
  60337. matrix: Matrix;
  60338. /**
  60339. * Stores the position
  60340. */
  60341. position: Vector3;
  60342. /**
  60343. * Stores the rotation
  60344. */
  60345. rotation: Vector3;
  60346. /**
  60347. * Stores the rotation quaternion
  60348. */
  60349. rotationQuaternion: Nullable<Quaternion>;
  60350. /**
  60351. * Stores the scaling vector
  60352. */
  60353. scaling: Vector3;
  60354. /**
  60355. * Convert the Mesh to CSG
  60356. * @param mesh The Mesh to convert to CSG
  60357. * @returns A new CSG from the Mesh
  60358. */
  60359. static FromMesh(mesh: Mesh): CSG;
  60360. /**
  60361. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60362. * @param polygons Polygons used to construct a CSG solid
  60363. */
  60364. private static FromPolygons;
  60365. /**
  60366. * Clones, or makes a deep copy, of the CSG
  60367. * @returns A new CSG
  60368. */
  60369. clone(): CSG;
  60370. /**
  60371. * Unions this CSG with another CSG
  60372. * @param csg The CSG to union against this CSG
  60373. * @returns The unioned CSG
  60374. */
  60375. union(csg: CSG): CSG;
  60376. /**
  60377. * Unions this CSG with another CSG in place
  60378. * @param csg The CSG to union against this CSG
  60379. */
  60380. unionInPlace(csg: CSG): void;
  60381. /**
  60382. * Subtracts this CSG with another CSG
  60383. * @param csg The CSG to subtract against this CSG
  60384. * @returns A new CSG
  60385. */
  60386. subtract(csg: CSG): CSG;
  60387. /**
  60388. * Subtracts this CSG with another CSG in place
  60389. * @param csg The CSG to subtact against this CSG
  60390. */
  60391. subtractInPlace(csg: CSG): void;
  60392. /**
  60393. * Intersect this CSG with another CSG
  60394. * @param csg The CSG to intersect against this CSG
  60395. * @returns A new CSG
  60396. */
  60397. intersect(csg: CSG): CSG;
  60398. /**
  60399. * Intersects this CSG with another CSG in place
  60400. * @param csg The CSG to intersect against this CSG
  60401. */
  60402. intersectInPlace(csg: CSG): void;
  60403. /**
  60404. * Return a new CSG solid with solid and empty space switched. This solid is
  60405. * not modified.
  60406. * @returns A new CSG solid with solid and empty space switched
  60407. */
  60408. inverse(): CSG;
  60409. /**
  60410. * Inverses the CSG in place
  60411. */
  60412. inverseInPlace(): void;
  60413. /**
  60414. * This is used to keep meshes transformations so they can be restored
  60415. * when we build back a Babylon Mesh
  60416. * NB : All CSG operations are performed in world coordinates
  60417. * @param csg The CSG to copy the transform attributes from
  60418. * @returns This CSG
  60419. */
  60420. copyTransformAttributes(csg: CSG): CSG;
  60421. /**
  60422. * Build Raw mesh from CSG
  60423. * Coordinates here are in world space
  60424. * @param name The name of the mesh geometry
  60425. * @param scene The Scene
  60426. * @param keepSubMeshes Specifies if the submeshes should be kept
  60427. * @returns A new Mesh
  60428. */
  60429. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60430. /**
  60431. * Build Mesh from CSG taking material and transforms into account
  60432. * @param name The name of the Mesh
  60433. * @param material The material of the Mesh
  60434. * @param scene The Scene
  60435. * @param keepSubMeshes Specifies if submeshes should be kept
  60436. * @returns The new Mesh
  60437. */
  60438. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60439. }
  60440. }
  60441. declare module BABYLON {
  60442. /**
  60443. * Class used to create a trail following a mesh
  60444. */
  60445. export class TrailMesh extends Mesh {
  60446. private _generator;
  60447. private _autoStart;
  60448. private _running;
  60449. private _diameter;
  60450. private _length;
  60451. private _sectionPolygonPointsCount;
  60452. private _sectionVectors;
  60453. private _sectionNormalVectors;
  60454. private _beforeRenderObserver;
  60455. /**
  60456. * @constructor
  60457. * @param name The value used by scene.getMeshByName() to do a lookup.
  60458. * @param generator The mesh or transform node to generate a trail.
  60459. * @param scene The scene to add this mesh to.
  60460. * @param diameter Diameter of trailing mesh. Default is 1.
  60461. * @param length Length of trailing mesh. Default is 60.
  60462. * @param autoStart Automatically start trailing mesh. Default true.
  60463. */
  60464. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60465. /**
  60466. * "TrailMesh"
  60467. * @returns "TrailMesh"
  60468. */
  60469. getClassName(): string;
  60470. private _createMesh;
  60471. /**
  60472. * Start trailing mesh.
  60473. */
  60474. start(): void;
  60475. /**
  60476. * Stop trailing mesh.
  60477. */
  60478. stop(): void;
  60479. /**
  60480. * Update trailing mesh geometry.
  60481. */
  60482. update(): void;
  60483. /**
  60484. * Returns a new TrailMesh object.
  60485. * @param name is a string, the name given to the new mesh
  60486. * @param newGenerator use new generator object for cloned trail mesh
  60487. * @returns a new mesh
  60488. */
  60489. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60490. /**
  60491. * Serializes this trail mesh
  60492. * @param serializationObject object to write serialization to
  60493. */
  60494. serialize(serializationObject: any): void;
  60495. /**
  60496. * Parses a serialized trail mesh
  60497. * @param parsedMesh the serialized mesh
  60498. * @param scene the scene to create the trail mesh in
  60499. * @returns the created trail mesh
  60500. */
  60501. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60502. }
  60503. }
  60504. declare module BABYLON {
  60505. /**
  60506. * Class containing static functions to help procedurally build meshes
  60507. */
  60508. export class TiledBoxBuilder {
  60509. /**
  60510. * Creates a box mesh
  60511. * 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)
  60512. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60514. * * 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
  60515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60516. * @param name defines the name of the mesh
  60517. * @param options defines the options used to create the mesh
  60518. * @param scene defines the hosting scene
  60519. * @returns the box mesh
  60520. */
  60521. static CreateTiledBox(name: string, options: {
  60522. pattern?: number;
  60523. width?: number;
  60524. height?: number;
  60525. depth?: number;
  60526. tileSize?: number;
  60527. tileWidth?: number;
  60528. tileHeight?: number;
  60529. alignHorizontal?: number;
  60530. alignVertical?: number;
  60531. faceUV?: Vector4[];
  60532. faceColors?: Color4[];
  60533. sideOrientation?: number;
  60534. updatable?: boolean;
  60535. }, scene?: Nullable<Scene>): Mesh;
  60536. }
  60537. }
  60538. declare module BABYLON {
  60539. /**
  60540. * Class containing static functions to help procedurally build meshes
  60541. */
  60542. export class TorusKnotBuilder {
  60543. /**
  60544. * Creates a torus knot mesh
  60545. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60546. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60547. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60548. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60550. * * 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
  60551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60552. * @param name defines the name of the mesh
  60553. * @param options defines the options used to create the mesh
  60554. * @param scene defines the hosting scene
  60555. * @returns the torus knot mesh
  60556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60557. */
  60558. static CreateTorusKnot(name: string, options: {
  60559. radius?: number;
  60560. tube?: number;
  60561. radialSegments?: number;
  60562. tubularSegments?: number;
  60563. p?: number;
  60564. q?: number;
  60565. updatable?: boolean;
  60566. sideOrientation?: number;
  60567. frontUVs?: Vector4;
  60568. backUVs?: Vector4;
  60569. }, scene: any): Mesh;
  60570. }
  60571. }
  60572. declare module BABYLON {
  60573. /**
  60574. * Polygon
  60575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60576. */
  60577. export class Polygon {
  60578. /**
  60579. * Creates a rectangle
  60580. * @param xmin bottom X coord
  60581. * @param ymin bottom Y coord
  60582. * @param xmax top X coord
  60583. * @param ymax top Y coord
  60584. * @returns points that make the resulting rectation
  60585. */
  60586. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60587. /**
  60588. * Creates a circle
  60589. * @param radius radius of circle
  60590. * @param cx scale in x
  60591. * @param cy scale in y
  60592. * @param numberOfSides number of sides that make up the circle
  60593. * @returns points that make the resulting circle
  60594. */
  60595. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60596. /**
  60597. * Creates a polygon from input string
  60598. * @param input Input polygon data
  60599. * @returns the parsed points
  60600. */
  60601. static Parse(input: string): Vector2[];
  60602. /**
  60603. * Starts building a polygon from x and y coordinates
  60604. * @param x x coordinate
  60605. * @param y y coordinate
  60606. * @returns the started path2
  60607. */
  60608. static StartingAt(x: number, y: number): Path2;
  60609. }
  60610. /**
  60611. * Builds a polygon
  60612. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60613. */
  60614. export class PolygonMeshBuilder {
  60615. private _points;
  60616. private _outlinepoints;
  60617. private _holes;
  60618. private _name;
  60619. private _scene;
  60620. private _epoints;
  60621. private _eholes;
  60622. private _addToepoint;
  60623. /**
  60624. * Babylon reference to the earcut plugin.
  60625. */
  60626. bjsEarcut: any;
  60627. /**
  60628. * Creates a PolygonMeshBuilder
  60629. * @param name name of the builder
  60630. * @param contours Path of the polygon
  60631. * @param scene scene to add to when creating the mesh
  60632. * @param earcutInjection can be used to inject your own earcut reference
  60633. */
  60634. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60635. /**
  60636. * Adds a whole within the polygon
  60637. * @param hole Array of points defining the hole
  60638. * @returns this
  60639. */
  60640. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60641. /**
  60642. * Creates the polygon
  60643. * @param updatable If the mesh should be updatable
  60644. * @param depth The depth of the mesh created
  60645. * @returns the created mesh
  60646. */
  60647. build(updatable?: boolean, depth?: number): Mesh;
  60648. /**
  60649. * Creates the polygon
  60650. * @param depth The depth of the mesh created
  60651. * @returns the created VertexData
  60652. */
  60653. buildVertexData(depth?: number): VertexData;
  60654. /**
  60655. * Adds a side to the polygon
  60656. * @param positions points that make the polygon
  60657. * @param normals normals of the polygon
  60658. * @param uvs uvs of the polygon
  60659. * @param indices indices of the polygon
  60660. * @param bounds bounds of the polygon
  60661. * @param points points of the polygon
  60662. * @param depth depth of the polygon
  60663. * @param flip flip of the polygon
  60664. */
  60665. private addSide;
  60666. }
  60667. }
  60668. declare module BABYLON {
  60669. /**
  60670. * Class containing static functions to help procedurally build meshes
  60671. */
  60672. export class PolygonBuilder {
  60673. /**
  60674. * Creates a polygon mesh
  60675. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60676. * * 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
  60677. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60679. * * 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)
  60680. * * Remember you can only change the shape positions, not their number when updating a polygon
  60681. * @param name defines the name of the mesh
  60682. * @param options defines the options used to create the mesh
  60683. * @param scene defines the hosting scene
  60684. * @param earcutInjection can be used to inject your own earcut reference
  60685. * @returns the polygon mesh
  60686. */
  60687. static CreatePolygon(name: string, options: {
  60688. shape: Vector3[];
  60689. holes?: Vector3[][];
  60690. depth?: number;
  60691. faceUV?: Vector4[];
  60692. faceColors?: Color4[];
  60693. updatable?: boolean;
  60694. sideOrientation?: number;
  60695. frontUVs?: Vector4;
  60696. backUVs?: Vector4;
  60697. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60698. /**
  60699. * Creates an extruded polygon mesh, with depth in the Y direction.
  60700. * * 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)
  60701. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60702. * @param name defines the name of the mesh
  60703. * @param options defines the options used to create the mesh
  60704. * @param scene defines the hosting scene
  60705. * @param earcutInjection can be used to inject your own earcut reference
  60706. * @returns the polygon mesh
  60707. */
  60708. static ExtrudePolygon(name: string, options: {
  60709. shape: Vector3[];
  60710. holes?: Vector3[][];
  60711. depth?: number;
  60712. faceUV?: Vector4[];
  60713. faceColors?: Color4[];
  60714. updatable?: boolean;
  60715. sideOrientation?: number;
  60716. frontUVs?: Vector4;
  60717. backUVs?: Vector4;
  60718. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60719. }
  60720. }
  60721. declare module BABYLON {
  60722. /**
  60723. * Class containing static functions to help procedurally build meshes
  60724. */
  60725. export class LatheBuilder {
  60726. /**
  60727. * Creates lathe mesh.
  60728. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60729. * * 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
  60730. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60731. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60732. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60733. * * 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
  60734. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60735. * * 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
  60736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60737. * * 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
  60738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60740. * @param name defines the name of the mesh
  60741. * @param options defines the options used to create the mesh
  60742. * @param scene defines the hosting scene
  60743. * @returns the lathe mesh
  60744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60745. */
  60746. static CreateLathe(name: string, options: {
  60747. shape: Vector3[];
  60748. radius?: number;
  60749. tessellation?: number;
  60750. clip?: number;
  60751. arc?: number;
  60752. closed?: boolean;
  60753. updatable?: boolean;
  60754. sideOrientation?: number;
  60755. frontUVs?: Vector4;
  60756. backUVs?: Vector4;
  60757. cap?: number;
  60758. invertUV?: boolean;
  60759. }, scene?: Nullable<Scene>): Mesh;
  60760. }
  60761. }
  60762. declare module BABYLON {
  60763. /**
  60764. * Class containing static functions to help procedurally build meshes
  60765. */
  60766. export class TiledPlaneBuilder {
  60767. /**
  60768. * Creates a tiled plane mesh
  60769. * * The parameter `pattern` will, depending on value, do nothing or
  60770. * * * flip (reflect about central vertical) alternate tiles across and up
  60771. * * * flip every tile on alternate rows
  60772. * * * rotate (180 degs) alternate tiles across and up
  60773. * * * rotate every tile on alternate rows
  60774. * * * flip and rotate alternate tiles across and up
  60775. * * * flip and rotate every tile on alternate rows
  60776. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60777. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60778. * * 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
  60779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60780. * * 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)
  60781. * * 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)
  60782. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60783. * @param name defines the name of the mesh
  60784. * @param options defines the options used to create the mesh
  60785. * @param scene defines the hosting scene
  60786. * @returns the box mesh
  60787. */
  60788. static CreateTiledPlane(name: string, options: {
  60789. pattern?: number;
  60790. tileSize?: number;
  60791. tileWidth?: number;
  60792. tileHeight?: number;
  60793. size?: number;
  60794. width?: number;
  60795. height?: number;
  60796. alignHorizontal?: number;
  60797. alignVertical?: number;
  60798. sideOrientation?: number;
  60799. frontUVs?: Vector4;
  60800. backUVs?: Vector4;
  60801. updatable?: boolean;
  60802. }, scene?: Nullable<Scene>): Mesh;
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * Class containing static functions to help procedurally build meshes
  60808. */
  60809. export class TubeBuilder {
  60810. /**
  60811. * Creates a tube mesh.
  60812. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60813. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60814. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60815. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60816. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60817. * * 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)
  60818. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60819. * * 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
  60820. * * 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
  60821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60822. * * 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
  60823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60825. * @param name defines the name of the mesh
  60826. * @param options defines the options used to create the mesh
  60827. * @param scene defines the hosting scene
  60828. * @returns the tube mesh
  60829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60830. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60831. */
  60832. static CreateTube(name: string, options: {
  60833. path: Vector3[];
  60834. radius?: number;
  60835. tessellation?: number;
  60836. radiusFunction?: {
  60837. (i: number, distance: number): number;
  60838. };
  60839. cap?: number;
  60840. arc?: number;
  60841. updatable?: boolean;
  60842. sideOrientation?: number;
  60843. frontUVs?: Vector4;
  60844. backUVs?: Vector4;
  60845. instance?: Mesh;
  60846. invertUV?: boolean;
  60847. }, scene?: Nullable<Scene>): Mesh;
  60848. }
  60849. }
  60850. declare module BABYLON {
  60851. /**
  60852. * Class containing static functions to help procedurally build meshes
  60853. */
  60854. export class IcoSphereBuilder {
  60855. /**
  60856. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60857. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60858. * * 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`)
  60859. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60860. * * 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
  60861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60862. * * 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
  60863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60864. * @param name defines the name of the mesh
  60865. * @param options defines the options used to create the mesh
  60866. * @param scene defines the hosting scene
  60867. * @returns the icosahedron mesh
  60868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60869. */
  60870. static CreateIcoSphere(name: string, options: {
  60871. radius?: number;
  60872. radiusX?: number;
  60873. radiusY?: number;
  60874. radiusZ?: number;
  60875. flat?: boolean;
  60876. subdivisions?: number;
  60877. sideOrientation?: number;
  60878. frontUVs?: Vector4;
  60879. backUVs?: Vector4;
  60880. updatable?: boolean;
  60881. }, scene?: Nullable<Scene>): Mesh;
  60882. }
  60883. }
  60884. declare module BABYLON {
  60885. /**
  60886. * Class containing static functions to help procedurally build meshes
  60887. */
  60888. export class DecalBuilder {
  60889. /**
  60890. * Creates a decal mesh.
  60891. * 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
  60892. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60893. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60894. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60895. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60896. * @param name defines the name of the mesh
  60897. * @param sourceMesh defines the mesh where the decal must be applied
  60898. * @param options defines the options used to create the mesh
  60899. * @param scene defines the hosting scene
  60900. * @returns the decal mesh
  60901. * @see https://doc.babylonjs.com/how_to/decals
  60902. */
  60903. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60904. position?: Vector3;
  60905. normal?: Vector3;
  60906. size?: Vector3;
  60907. angle?: number;
  60908. }): Mesh;
  60909. }
  60910. }
  60911. declare module BABYLON {
  60912. /**
  60913. * Class containing static functions to help procedurally build meshes
  60914. */
  60915. export class MeshBuilder {
  60916. /**
  60917. * Creates a box mesh
  60918. * * The parameter `size` sets the size (float) of each box side (default 1)
  60919. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60920. * * 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)
  60921. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60923. * * 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
  60924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60925. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60926. * @param name defines the name of the mesh
  60927. * @param options defines the options used to create the mesh
  60928. * @param scene defines the hosting scene
  60929. * @returns the box mesh
  60930. */
  60931. static CreateBox(name: string, options: {
  60932. size?: number;
  60933. width?: number;
  60934. height?: number;
  60935. depth?: number;
  60936. faceUV?: Vector4[];
  60937. faceColors?: Color4[];
  60938. sideOrientation?: number;
  60939. frontUVs?: Vector4;
  60940. backUVs?: Vector4;
  60941. updatable?: boolean;
  60942. }, scene?: Nullable<Scene>): Mesh;
  60943. /**
  60944. * Creates a tiled box mesh
  60945. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60947. * @param name defines the name of the mesh
  60948. * @param options defines the options used to create the mesh
  60949. * @param scene defines the hosting scene
  60950. * @returns the tiled box mesh
  60951. */
  60952. static CreateTiledBox(name: string, options: {
  60953. pattern?: number;
  60954. size?: number;
  60955. width?: number;
  60956. height?: number;
  60957. depth: number;
  60958. tileSize?: number;
  60959. tileWidth?: number;
  60960. tileHeight?: number;
  60961. faceUV?: Vector4[];
  60962. faceColors?: Color4[];
  60963. alignHorizontal?: number;
  60964. alignVertical?: number;
  60965. sideOrientation?: number;
  60966. updatable?: boolean;
  60967. }, scene?: Nullable<Scene>): Mesh;
  60968. /**
  60969. * Creates a sphere mesh
  60970. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60971. * * 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`)
  60972. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60973. * * 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
  60974. * * 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)
  60975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60976. * * 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
  60977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60978. * @param name defines the name of the mesh
  60979. * @param options defines the options used to create the mesh
  60980. * @param scene defines the hosting scene
  60981. * @returns the sphere mesh
  60982. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60983. */
  60984. static CreateSphere(name: string, options: {
  60985. segments?: number;
  60986. diameter?: number;
  60987. diameterX?: number;
  60988. diameterY?: number;
  60989. diameterZ?: number;
  60990. arc?: number;
  60991. slice?: number;
  60992. sideOrientation?: number;
  60993. frontUVs?: Vector4;
  60994. backUVs?: Vector4;
  60995. updatable?: boolean;
  60996. }, scene?: Nullable<Scene>): Mesh;
  60997. /**
  60998. * Creates a plane polygonal mesh. By default, this is a disc
  60999. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61000. * * 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
  61001. * * 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
  61002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61003. * * 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
  61004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61005. * @param name defines the name of the mesh
  61006. * @param options defines the options used to create the mesh
  61007. * @param scene defines the hosting scene
  61008. * @returns the plane polygonal mesh
  61009. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61010. */
  61011. static CreateDisc(name: string, options: {
  61012. radius?: number;
  61013. tessellation?: number;
  61014. arc?: number;
  61015. updatable?: boolean;
  61016. sideOrientation?: number;
  61017. frontUVs?: Vector4;
  61018. backUVs?: Vector4;
  61019. }, scene?: Nullable<Scene>): Mesh;
  61020. /**
  61021. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61022. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61023. * * 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`)
  61024. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61025. * * 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
  61026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61027. * * 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
  61028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61029. * @param name defines the name of the mesh
  61030. * @param options defines the options used to create the mesh
  61031. * @param scene defines the hosting scene
  61032. * @returns the icosahedron mesh
  61033. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61034. */
  61035. static CreateIcoSphere(name: string, options: {
  61036. radius?: number;
  61037. radiusX?: number;
  61038. radiusY?: number;
  61039. radiusZ?: number;
  61040. flat?: boolean;
  61041. subdivisions?: number;
  61042. sideOrientation?: number;
  61043. frontUVs?: Vector4;
  61044. backUVs?: Vector4;
  61045. updatable?: boolean;
  61046. }, scene?: Nullable<Scene>): Mesh;
  61047. /**
  61048. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61049. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61050. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61051. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61052. * * 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
  61053. * * 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
  61054. * * 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
  61055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61056. * * 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
  61057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61058. * * 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
  61059. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61060. * * 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
  61061. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61063. * @param name defines the name of the mesh
  61064. * @param options defines the options used to create the mesh
  61065. * @param scene defines the hosting scene
  61066. * @returns the ribbon mesh
  61067. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61068. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61069. */
  61070. static CreateRibbon(name: string, options: {
  61071. pathArray: Vector3[][];
  61072. closeArray?: boolean;
  61073. closePath?: boolean;
  61074. offset?: number;
  61075. updatable?: boolean;
  61076. sideOrientation?: number;
  61077. frontUVs?: Vector4;
  61078. backUVs?: Vector4;
  61079. instance?: Mesh;
  61080. invertUV?: boolean;
  61081. uvs?: Vector2[];
  61082. colors?: Color4[];
  61083. }, scene?: Nullable<Scene>): Mesh;
  61084. /**
  61085. * Creates a cylinder or a cone mesh
  61086. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61087. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61088. * * 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.
  61089. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61090. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61091. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61092. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61093. * * 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).
  61094. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61095. * * 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).
  61096. * * 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
  61097. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61098. * * 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
  61099. * * 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.
  61100. * * If `enclose` is false, a ring surface is one element.
  61101. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61102. * * 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
  61103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61104. * * 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
  61105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61106. * @param name defines the name of the mesh
  61107. * @param options defines the options used to create the mesh
  61108. * @param scene defines the hosting scene
  61109. * @returns the cylinder mesh
  61110. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61111. */
  61112. static CreateCylinder(name: string, options: {
  61113. height?: number;
  61114. diameterTop?: number;
  61115. diameterBottom?: number;
  61116. diameter?: number;
  61117. tessellation?: number;
  61118. subdivisions?: number;
  61119. arc?: number;
  61120. faceColors?: Color4[];
  61121. faceUV?: Vector4[];
  61122. updatable?: boolean;
  61123. hasRings?: boolean;
  61124. enclose?: boolean;
  61125. cap?: number;
  61126. sideOrientation?: number;
  61127. frontUVs?: Vector4;
  61128. backUVs?: Vector4;
  61129. }, scene?: Nullable<Scene>): Mesh;
  61130. /**
  61131. * Creates a torus mesh
  61132. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61133. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61134. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61136. * * 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
  61137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61138. * @param name defines the name of the mesh
  61139. * @param options defines the options used to create the mesh
  61140. * @param scene defines the hosting scene
  61141. * @returns the torus mesh
  61142. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61143. */
  61144. static CreateTorus(name: string, options: {
  61145. diameter?: number;
  61146. thickness?: number;
  61147. tessellation?: number;
  61148. updatable?: boolean;
  61149. sideOrientation?: number;
  61150. frontUVs?: Vector4;
  61151. backUVs?: Vector4;
  61152. }, scene?: Nullable<Scene>): Mesh;
  61153. /**
  61154. * Creates a torus knot mesh
  61155. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61156. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61157. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61158. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61160. * * 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
  61161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61162. * @param name defines the name of the mesh
  61163. * @param options defines the options used to create the mesh
  61164. * @param scene defines the hosting scene
  61165. * @returns the torus knot mesh
  61166. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61167. */
  61168. static CreateTorusKnot(name: string, options: {
  61169. radius?: number;
  61170. tube?: number;
  61171. radialSegments?: number;
  61172. tubularSegments?: number;
  61173. p?: number;
  61174. q?: number;
  61175. updatable?: boolean;
  61176. sideOrientation?: number;
  61177. frontUVs?: Vector4;
  61178. backUVs?: Vector4;
  61179. }, scene?: Nullable<Scene>): Mesh;
  61180. /**
  61181. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61182. * * 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
  61183. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61184. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61185. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61186. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61187. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61188. * * 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
  61189. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61192. * @param name defines the name of the new line system
  61193. * @param options defines the options used to create the line system
  61194. * @param scene defines the hosting scene
  61195. * @returns a new line system mesh
  61196. */
  61197. static CreateLineSystem(name: string, options: {
  61198. lines: Vector3[][];
  61199. updatable?: boolean;
  61200. instance?: Nullable<LinesMesh>;
  61201. colors?: Nullable<Color4[][]>;
  61202. useVertexAlpha?: boolean;
  61203. }, scene: Nullable<Scene>): LinesMesh;
  61204. /**
  61205. * Creates a line mesh
  61206. * 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
  61207. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61208. * * The parameter `points` is an array successive Vector3
  61209. * * 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
  61210. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61211. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61212. * * When updating an instance, remember that only point positions can change, not the number of points
  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#lines
  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 mesh
  61219. */
  61220. static CreateLines(name: string, options: {
  61221. points: Vector3[];
  61222. updatable?: boolean;
  61223. instance?: Nullable<LinesMesh>;
  61224. colors?: Color4[];
  61225. useVertexAlpha?: boolean;
  61226. }, scene?: Nullable<Scene>): LinesMesh;
  61227. /**
  61228. * Creates a dashed line mesh
  61229. * * 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
  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 parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61233. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61234. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61235. * * 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
  61236. * * When updating an instance, remember that only point positions can change, not the number of points
  61237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61238. * @param name defines the name of the mesh
  61239. * @param options defines the options used to create the mesh
  61240. * @param scene defines the hosting scene
  61241. * @returns the dashed line mesh
  61242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61243. */
  61244. static CreateDashedLines(name: string, options: {
  61245. points: Vector3[];
  61246. dashSize?: number;
  61247. gapSize?: number;
  61248. dashNb?: number;
  61249. updatable?: boolean;
  61250. instance?: LinesMesh;
  61251. }, scene?: Nullable<Scene>): LinesMesh;
  61252. /**
  61253. * 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.
  61254. * * 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.
  61255. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61256. * * 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.
  61257. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61258. * * 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
  61259. * * 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
  61260. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61262. * * 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
  61263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61265. * @param name defines the name of the mesh
  61266. * @param options defines the options used to create the mesh
  61267. * @param scene defines the hosting scene
  61268. * @returns the extruded shape mesh
  61269. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61271. */
  61272. static ExtrudeShape(name: string, options: {
  61273. shape: Vector3[];
  61274. path: Vector3[];
  61275. scale?: number;
  61276. rotation?: number;
  61277. cap?: number;
  61278. updatable?: boolean;
  61279. sideOrientation?: number;
  61280. frontUVs?: Vector4;
  61281. backUVs?: Vector4;
  61282. instance?: Mesh;
  61283. invertUV?: boolean;
  61284. }, scene?: Nullable<Scene>): Mesh;
  61285. /**
  61286. * Creates an custom extruded shape mesh.
  61287. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61288. * * 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.
  61289. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61290. * * 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
  61291. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61292. * * 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
  61293. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61294. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61295. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61296. * * 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
  61297. * * 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
  61298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61300. * * 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
  61301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61303. * @param name defines the name of the mesh
  61304. * @param options defines the options used to create the mesh
  61305. * @param scene defines the hosting scene
  61306. * @returns the custom extruded shape mesh
  61307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61310. */
  61311. static ExtrudeShapeCustom(name: string, options: {
  61312. shape: Vector3[];
  61313. path: Vector3[];
  61314. scaleFunction?: any;
  61315. rotationFunction?: any;
  61316. ribbonCloseArray?: boolean;
  61317. ribbonClosePath?: boolean;
  61318. cap?: number;
  61319. updatable?: boolean;
  61320. sideOrientation?: number;
  61321. frontUVs?: Vector4;
  61322. backUVs?: Vector4;
  61323. instance?: Mesh;
  61324. invertUV?: boolean;
  61325. }, scene?: Nullable<Scene>): Mesh;
  61326. /**
  61327. * Creates lathe mesh.
  61328. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61329. * * 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
  61330. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61331. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61332. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61333. * * 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
  61334. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61335. * * 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
  61336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61337. * * 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
  61338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61340. * @param name defines the name of the mesh
  61341. * @param options defines the options used to create the mesh
  61342. * @param scene defines the hosting scene
  61343. * @returns the lathe mesh
  61344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61345. */
  61346. static CreateLathe(name: string, options: {
  61347. shape: Vector3[];
  61348. radius?: number;
  61349. tessellation?: number;
  61350. clip?: number;
  61351. arc?: number;
  61352. closed?: boolean;
  61353. updatable?: boolean;
  61354. sideOrientation?: number;
  61355. frontUVs?: Vector4;
  61356. backUVs?: Vector4;
  61357. cap?: number;
  61358. invertUV?: boolean;
  61359. }, scene?: Nullable<Scene>): Mesh;
  61360. /**
  61361. * Creates a tiled plane mesh
  61362. * * You can set a limited pattern arrangement with the tiles
  61363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61364. * * 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
  61365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61366. * @param name defines the name of the mesh
  61367. * @param options defines the options used to create the mesh
  61368. * @param scene defines the hosting scene
  61369. * @returns the plane mesh
  61370. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61371. */
  61372. static CreateTiledPlane(name: string, options: {
  61373. pattern?: number;
  61374. tileSize?: number;
  61375. tileWidth?: number;
  61376. tileHeight?: number;
  61377. size?: number;
  61378. width?: number;
  61379. height?: number;
  61380. alignHorizontal?: number;
  61381. alignVertical?: number;
  61382. sideOrientation?: number;
  61383. frontUVs?: Vector4;
  61384. backUVs?: Vector4;
  61385. updatable?: boolean;
  61386. }, scene?: Nullable<Scene>): Mesh;
  61387. /**
  61388. * Creates a plane mesh
  61389. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61390. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61391. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61393. * * 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
  61394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61395. * @param name defines the name of the mesh
  61396. * @param options defines the options used to create the mesh
  61397. * @param scene defines the hosting scene
  61398. * @returns the plane mesh
  61399. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61400. */
  61401. static CreatePlane(name: string, options: {
  61402. size?: number;
  61403. width?: number;
  61404. height?: number;
  61405. sideOrientation?: number;
  61406. frontUVs?: Vector4;
  61407. backUVs?: Vector4;
  61408. updatable?: boolean;
  61409. sourcePlane?: Plane;
  61410. }, scene?: Nullable<Scene>): Mesh;
  61411. /**
  61412. * Creates a ground mesh
  61413. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61414. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61416. * @param name defines the name of the mesh
  61417. * @param options defines the options used to create the mesh
  61418. * @param scene defines the hosting scene
  61419. * @returns the ground mesh
  61420. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61421. */
  61422. static CreateGround(name: string, options: {
  61423. width?: number;
  61424. height?: number;
  61425. subdivisions?: number;
  61426. subdivisionsX?: number;
  61427. subdivisionsY?: number;
  61428. updatable?: boolean;
  61429. }, scene?: Nullable<Scene>): Mesh;
  61430. /**
  61431. * Creates a tiled ground mesh
  61432. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61433. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61434. * * 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
  61435. * * 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
  61436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61437. * @param name defines the name of the mesh
  61438. * @param options defines the options used to create the mesh
  61439. * @param scene defines the hosting scene
  61440. * @returns the tiled ground mesh
  61441. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61442. */
  61443. static CreateTiledGround(name: string, options: {
  61444. xmin: number;
  61445. zmin: number;
  61446. xmax: number;
  61447. zmax: number;
  61448. subdivisions?: {
  61449. w: number;
  61450. h: number;
  61451. };
  61452. precision?: {
  61453. w: number;
  61454. h: number;
  61455. };
  61456. updatable?: boolean;
  61457. }, scene?: Nullable<Scene>): Mesh;
  61458. /**
  61459. * Creates a ground mesh from a height map
  61460. * * The parameter `url` sets the URL of the height map image resource.
  61461. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61462. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61463. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61464. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61465. * * 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.
  61466. * * 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).
  61467. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61469. * @param name defines the name of the mesh
  61470. * @param url defines the url to the height map
  61471. * @param options defines the options used to create the mesh
  61472. * @param scene defines the hosting scene
  61473. * @returns the ground mesh
  61474. * @see https://doc.babylonjs.com/babylon101/height_map
  61475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61476. */
  61477. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61478. width?: number;
  61479. height?: number;
  61480. subdivisions?: number;
  61481. minHeight?: number;
  61482. maxHeight?: number;
  61483. colorFilter?: Color3;
  61484. alphaFilter?: number;
  61485. updatable?: boolean;
  61486. onReady?: (mesh: GroundMesh) => void;
  61487. }, scene?: Nullable<Scene>): GroundMesh;
  61488. /**
  61489. * Creates a polygon mesh
  61490. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61491. * * 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
  61492. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61494. * * 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)
  61495. * * Remember you can only change the shape positions, not their number when updating a polygon
  61496. * @param name defines the name of the mesh
  61497. * @param options defines the options used to create the mesh
  61498. * @param scene defines the hosting scene
  61499. * @param earcutInjection can be used to inject your own earcut reference
  61500. * @returns the polygon mesh
  61501. */
  61502. static CreatePolygon(name: string, options: {
  61503. shape: Vector3[];
  61504. holes?: Vector3[][];
  61505. depth?: number;
  61506. faceUV?: Vector4[];
  61507. faceColors?: Color4[];
  61508. updatable?: boolean;
  61509. sideOrientation?: number;
  61510. frontUVs?: Vector4;
  61511. backUVs?: Vector4;
  61512. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61513. /**
  61514. * Creates an extruded polygon mesh, with depth in the Y direction.
  61515. * * 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)
  61516. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61517. * @param name defines the name of the mesh
  61518. * @param options defines the options used to create the mesh
  61519. * @param scene defines the hosting scene
  61520. * @param earcutInjection can be used to inject your own earcut reference
  61521. * @returns the polygon mesh
  61522. */
  61523. static ExtrudePolygon(name: string, options: {
  61524. shape: Vector3[];
  61525. holes?: Vector3[][];
  61526. depth?: number;
  61527. faceUV?: Vector4[];
  61528. faceColors?: Color4[];
  61529. updatable?: boolean;
  61530. sideOrientation?: number;
  61531. frontUVs?: Vector4;
  61532. backUVs?: Vector4;
  61533. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61534. /**
  61535. * Creates a tube mesh.
  61536. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61537. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61538. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61539. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61540. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61541. * * 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)
  61542. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61543. * * 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
  61544. * * 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
  61545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61546. * * 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
  61547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61549. * @param name defines the name of the mesh
  61550. * @param options defines the options used to create the mesh
  61551. * @param scene defines the hosting scene
  61552. * @returns the tube mesh
  61553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61554. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61555. */
  61556. static CreateTube(name: string, options: {
  61557. path: Vector3[];
  61558. radius?: number;
  61559. tessellation?: number;
  61560. radiusFunction?: {
  61561. (i: number, distance: number): number;
  61562. };
  61563. cap?: number;
  61564. arc?: number;
  61565. updatable?: boolean;
  61566. sideOrientation?: number;
  61567. frontUVs?: Vector4;
  61568. backUVs?: Vector4;
  61569. instance?: Mesh;
  61570. invertUV?: boolean;
  61571. }, scene?: Nullable<Scene>): Mesh;
  61572. /**
  61573. * Creates a polyhedron mesh
  61574. * * 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
  61575. * * The parameter `size` (positive float, default 1) sets the polygon size
  61576. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61577. * * 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`
  61578. * * 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
  61579. * * 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)`)
  61580. * * 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
  61581. * * 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
  61582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61583. * * 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
  61584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61585. * @param name defines the name of the mesh
  61586. * @param options defines the options used to create the mesh
  61587. * @param scene defines the hosting scene
  61588. * @returns the polyhedron mesh
  61589. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61590. */
  61591. static CreatePolyhedron(name: string, options: {
  61592. type?: number;
  61593. size?: number;
  61594. sizeX?: number;
  61595. sizeY?: number;
  61596. sizeZ?: number;
  61597. custom?: any;
  61598. faceUV?: Vector4[];
  61599. faceColors?: Color4[];
  61600. flat?: boolean;
  61601. updatable?: boolean;
  61602. sideOrientation?: number;
  61603. frontUVs?: Vector4;
  61604. backUVs?: Vector4;
  61605. }, scene?: Nullable<Scene>): Mesh;
  61606. /**
  61607. * Creates a decal mesh.
  61608. * 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
  61609. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61610. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61611. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61612. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61613. * @param name defines the name of the mesh
  61614. * @param sourceMesh defines the mesh where the decal must be applied
  61615. * @param options defines the options used to create the mesh
  61616. * @param scene defines the hosting scene
  61617. * @returns the decal mesh
  61618. * @see https://doc.babylonjs.com/how_to/decals
  61619. */
  61620. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61621. position?: Vector3;
  61622. normal?: Vector3;
  61623. size?: Vector3;
  61624. angle?: number;
  61625. }): Mesh;
  61626. }
  61627. }
  61628. declare module BABYLON {
  61629. /**
  61630. * A simplifier interface for future simplification implementations
  61631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61632. */
  61633. export interface ISimplifier {
  61634. /**
  61635. * Simplification of a given mesh according to the given settings.
  61636. * Since this requires computation, it is assumed that the function runs async.
  61637. * @param settings The settings of the simplification, including quality and distance
  61638. * @param successCallback A callback that will be called after the mesh was simplified.
  61639. * @param errorCallback in case of an error, this callback will be called. optional.
  61640. */
  61641. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61642. }
  61643. /**
  61644. * Expected simplification settings.
  61645. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61646. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61647. */
  61648. export interface ISimplificationSettings {
  61649. /**
  61650. * Gets or sets the expected quality
  61651. */
  61652. quality: number;
  61653. /**
  61654. * Gets or sets the distance when this optimized version should be used
  61655. */
  61656. distance: number;
  61657. /**
  61658. * Gets an already optimized mesh
  61659. */
  61660. optimizeMesh?: boolean;
  61661. }
  61662. /**
  61663. * Class used to specify simplification options
  61664. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61665. */
  61666. export class SimplificationSettings implements ISimplificationSettings {
  61667. /** expected quality */
  61668. quality: number;
  61669. /** distance when this optimized version should be used */
  61670. distance: number;
  61671. /** already optimized mesh */
  61672. optimizeMesh?: boolean | undefined;
  61673. /**
  61674. * Creates a SimplificationSettings
  61675. * @param quality expected quality
  61676. * @param distance distance when this optimized version should be used
  61677. * @param optimizeMesh already optimized mesh
  61678. */
  61679. constructor(
  61680. /** expected quality */
  61681. quality: number,
  61682. /** distance when this optimized version should be used */
  61683. distance: number,
  61684. /** already optimized mesh */
  61685. optimizeMesh?: boolean | undefined);
  61686. }
  61687. /**
  61688. * Interface used to define a simplification task
  61689. */
  61690. export interface ISimplificationTask {
  61691. /**
  61692. * Array of settings
  61693. */
  61694. settings: Array<ISimplificationSettings>;
  61695. /**
  61696. * Simplification type
  61697. */
  61698. simplificationType: SimplificationType;
  61699. /**
  61700. * Mesh to simplify
  61701. */
  61702. mesh: Mesh;
  61703. /**
  61704. * Callback called on success
  61705. */
  61706. successCallback?: () => void;
  61707. /**
  61708. * Defines if parallel processing can be used
  61709. */
  61710. parallelProcessing: boolean;
  61711. }
  61712. /**
  61713. * Queue used to order the simplification tasks
  61714. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61715. */
  61716. export class SimplificationQueue {
  61717. private _simplificationArray;
  61718. /**
  61719. * Gets a boolean indicating that the process is still running
  61720. */
  61721. running: boolean;
  61722. /**
  61723. * Creates a new queue
  61724. */
  61725. constructor();
  61726. /**
  61727. * Adds a new simplification task
  61728. * @param task defines a task to add
  61729. */
  61730. addTask(task: ISimplificationTask): void;
  61731. /**
  61732. * Execute next task
  61733. */
  61734. executeNext(): void;
  61735. /**
  61736. * Execute a simplification task
  61737. * @param task defines the task to run
  61738. */
  61739. runSimplification(task: ISimplificationTask): void;
  61740. private getSimplifier;
  61741. }
  61742. /**
  61743. * The implemented types of simplification
  61744. * At the moment only Quadratic Error Decimation is implemented
  61745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61746. */
  61747. export enum SimplificationType {
  61748. /** Quadratic error decimation */
  61749. QUADRATIC = 0
  61750. }
  61751. }
  61752. declare module BABYLON {
  61753. interface Scene {
  61754. /** @hidden (Backing field) */
  61755. _simplificationQueue: SimplificationQueue;
  61756. /**
  61757. * Gets or sets the simplification queue attached to the scene
  61758. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61759. */
  61760. simplificationQueue: SimplificationQueue;
  61761. }
  61762. interface Mesh {
  61763. /**
  61764. * Simplify the mesh according to the given array of settings.
  61765. * Function will return immediately and will simplify async
  61766. * @param settings a collection of simplification settings
  61767. * @param parallelProcessing should all levels calculate parallel or one after the other
  61768. * @param simplificationType the type of simplification to run
  61769. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61770. * @returns the current mesh
  61771. */
  61772. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61773. }
  61774. /**
  61775. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61776. * created in a scene
  61777. */
  61778. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61779. /**
  61780. * The component name helpfull to identify the component in the list of scene components.
  61781. */
  61782. readonly name: string;
  61783. /**
  61784. * The scene the component belongs to.
  61785. */
  61786. scene: Scene;
  61787. /**
  61788. * Creates a new instance of the component for the given scene
  61789. * @param scene Defines the scene to register the component in
  61790. */
  61791. constructor(scene: Scene);
  61792. /**
  61793. * Registers the component in a given scene
  61794. */
  61795. register(): void;
  61796. /**
  61797. * Rebuilds the elements related to this component in case of
  61798. * context lost for instance.
  61799. */
  61800. rebuild(): void;
  61801. /**
  61802. * Disposes the component and the associated ressources
  61803. */
  61804. dispose(): void;
  61805. private _beforeCameraUpdate;
  61806. }
  61807. }
  61808. declare module BABYLON {
  61809. /**
  61810. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61811. */
  61812. export interface INavigationEnginePlugin {
  61813. /**
  61814. * plugin name
  61815. */
  61816. name: string;
  61817. /**
  61818. * Creates a navigation mesh
  61819. * @param meshes array of all the geometry used to compute the navigatio mesh
  61820. * @param parameters bunch of parameters used to filter geometry
  61821. */
  61822. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61823. /**
  61824. * Create a navigation mesh debug mesh
  61825. * @param scene is where the mesh will be added
  61826. * @returns debug display mesh
  61827. */
  61828. createDebugNavMesh(scene: Scene): Mesh;
  61829. /**
  61830. * Get a navigation mesh constrained position, closest to the parameter position
  61831. * @param position world position
  61832. * @returns the closest point to position constrained by the navigation mesh
  61833. */
  61834. getClosestPoint(position: Vector3): Vector3;
  61835. /**
  61836. * Get a navigation mesh constrained position, within a particular radius
  61837. * @param position world position
  61838. * @param maxRadius the maximum distance to the constrained world position
  61839. * @returns the closest point to position constrained by the navigation mesh
  61840. */
  61841. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61842. /**
  61843. * Compute the final position from a segment made of destination-position
  61844. * @param position world position
  61845. * @param destination world position
  61846. * @returns the resulting point along the navmesh
  61847. */
  61848. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61849. /**
  61850. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61851. * @param start world position
  61852. * @param end world position
  61853. * @returns array containing world position composing the path
  61854. */
  61855. computePath(start: Vector3, end: Vector3): Vector3[];
  61856. /**
  61857. * If this plugin is supported
  61858. * @returns true if plugin is supported
  61859. */
  61860. isSupported(): boolean;
  61861. /**
  61862. * Create a new Crowd so you can add agents
  61863. * @param maxAgents the maximum agent count in the crowd
  61864. * @param maxAgentRadius the maximum radius an agent can have
  61865. * @param scene to attach the crowd to
  61866. * @returns the crowd you can add agents to
  61867. */
  61868. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61869. /**
  61870. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61871. * The queries will try to find a solution within those bounds
  61872. * default is (1,1,1)
  61873. * @param extent x,y,z value that define the extent around the queries point of reference
  61874. */
  61875. setDefaultQueryExtent(extent: Vector3): void;
  61876. /**
  61877. * Get the Bounding box extent specified by setDefaultQueryExtent
  61878. * @returns the box extent values
  61879. */
  61880. getDefaultQueryExtent(): Vector3;
  61881. /**
  61882. * Release all resources
  61883. */
  61884. dispose(): void;
  61885. }
  61886. /**
  61887. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61888. */
  61889. export interface ICrowd {
  61890. /**
  61891. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61892. * You can attach anything to that node. The node position is updated in the scene update tick.
  61893. * @param pos world position that will be constrained by the navigation mesh
  61894. * @param parameters agent parameters
  61895. * @param transform hooked to the agent that will be update by the scene
  61896. * @returns agent index
  61897. */
  61898. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61899. /**
  61900. * Returns the agent position in world space
  61901. * @param index agent index returned by addAgent
  61902. * @returns world space position
  61903. */
  61904. getAgentPosition(index: number): Vector3;
  61905. /**
  61906. * Gets the agent velocity in world space
  61907. * @param index agent index returned by addAgent
  61908. * @returns world space velocity
  61909. */
  61910. getAgentVelocity(index: number): Vector3;
  61911. /**
  61912. * remove a particular agent previously created
  61913. * @param index agent index returned by addAgent
  61914. */
  61915. removeAgent(index: number): void;
  61916. /**
  61917. * get the list of all agents attached to this crowd
  61918. * @returns list of agent indices
  61919. */
  61920. getAgents(): number[];
  61921. /**
  61922. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61923. * @param deltaTime in seconds
  61924. */
  61925. update(deltaTime: number): void;
  61926. /**
  61927. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61928. * @param index agent index returned by addAgent
  61929. * @param destination targeted world position
  61930. */
  61931. agentGoto(index: number, destination: Vector3): void;
  61932. /**
  61933. * Teleport the agent to a new position
  61934. * @param index agent index returned by addAgent
  61935. * @param destination targeted world position
  61936. */
  61937. agentTeleport(index: number, destination: Vector3): void;
  61938. /**
  61939. * Update agent parameters
  61940. * @param index agent index returned by addAgent
  61941. * @param parameters agent parameters
  61942. */
  61943. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61944. /**
  61945. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61946. * The queries will try to find a solution within those bounds
  61947. * default is (1,1,1)
  61948. * @param extent x,y,z value that define the extent around the queries point of reference
  61949. */
  61950. setDefaultQueryExtent(extent: Vector3): void;
  61951. /**
  61952. * Get the Bounding box extent specified by setDefaultQueryExtent
  61953. * @returns the box extent values
  61954. */
  61955. getDefaultQueryExtent(): Vector3;
  61956. /**
  61957. * Release all resources
  61958. */
  61959. dispose(): void;
  61960. }
  61961. /**
  61962. * Configures an agent
  61963. */
  61964. export interface IAgentParameters {
  61965. /**
  61966. * Agent radius. [Limit: >= 0]
  61967. */
  61968. radius: number;
  61969. /**
  61970. * Agent height. [Limit: > 0]
  61971. */
  61972. height: number;
  61973. /**
  61974. * Maximum allowed acceleration. [Limit: >= 0]
  61975. */
  61976. maxAcceleration: number;
  61977. /**
  61978. * Maximum allowed speed. [Limit: >= 0]
  61979. */
  61980. maxSpeed: number;
  61981. /**
  61982. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61983. */
  61984. collisionQueryRange: number;
  61985. /**
  61986. * The path visibility optimization range. [Limit: > 0]
  61987. */
  61988. pathOptimizationRange: number;
  61989. /**
  61990. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61991. */
  61992. separationWeight: number;
  61993. }
  61994. /**
  61995. * Configures the navigation mesh creation
  61996. */
  61997. export interface INavMeshParameters {
  61998. /**
  61999. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62000. */
  62001. cs: number;
  62002. /**
  62003. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62004. */
  62005. ch: number;
  62006. /**
  62007. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62008. */
  62009. walkableSlopeAngle: number;
  62010. /**
  62011. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62012. * be considered walkable. [Limit: >= 3] [Units: vx]
  62013. */
  62014. walkableHeight: number;
  62015. /**
  62016. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62017. */
  62018. walkableClimb: number;
  62019. /**
  62020. * The distance to erode/shrink the walkable area of the heightfield away from
  62021. * obstructions. [Limit: >=0] [Units: vx]
  62022. */
  62023. walkableRadius: number;
  62024. /**
  62025. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62026. */
  62027. maxEdgeLen: number;
  62028. /**
  62029. * The maximum distance a simplfied contour's border edges should deviate
  62030. * the original raw contour. [Limit: >=0] [Units: vx]
  62031. */
  62032. maxSimplificationError: number;
  62033. /**
  62034. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62035. */
  62036. minRegionArea: number;
  62037. /**
  62038. * Any regions with a span count smaller than this value will, if possible,
  62039. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62040. */
  62041. mergeRegionArea: number;
  62042. /**
  62043. * The maximum number of vertices allowed for polygons generated during the
  62044. * contour to polygon conversion process. [Limit: >= 3]
  62045. */
  62046. maxVertsPerPoly: number;
  62047. /**
  62048. * Sets the sampling distance to use when generating the detail mesh.
  62049. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62050. */
  62051. detailSampleDist: number;
  62052. /**
  62053. * The maximum distance the detail mesh surface should deviate from heightfield
  62054. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62055. */
  62056. detailSampleMaxError: number;
  62057. }
  62058. }
  62059. declare module BABYLON {
  62060. /**
  62061. * RecastJS navigation plugin
  62062. */
  62063. export class RecastJSPlugin implements INavigationEnginePlugin {
  62064. /**
  62065. * Reference to the Recast library
  62066. */
  62067. bjsRECAST: any;
  62068. /**
  62069. * plugin name
  62070. */
  62071. name: string;
  62072. /**
  62073. * the first navmesh created. We might extend this to support multiple navmeshes
  62074. */
  62075. navMesh: any;
  62076. /**
  62077. * Initializes the recastJS plugin
  62078. * @param recastInjection can be used to inject your own recast reference
  62079. */
  62080. constructor(recastInjection?: any);
  62081. /**
  62082. * Creates a navigation mesh
  62083. * @param meshes array of all the geometry used to compute the navigatio mesh
  62084. * @param parameters bunch of parameters used to filter geometry
  62085. */
  62086. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62087. /**
  62088. * Create a navigation mesh debug mesh
  62089. * @param scene is where the mesh will be added
  62090. * @returns debug display mesh
  62091. */
  62092. createDebugNavMesh(scene: Scene): Mesh;
  62093. /**
  62094. * Get a navigation mesh constrained position, closest to the parameter position
  62095. * @param position world position
  62096. * @returns the closest point to position constrained by the navigation mesh
  62097. */
  62098. getClosestPoint(position: Vector3): Vector3;
  62099. /**
  62100. * Get a navigation mesh constrained position, within a particular radius
  62101. * @param position world position
  62102. * @param maxRadius the maximum distance to the constrained world position
  62103. * @returns the closest point to position constrained by the navigation mesh
  62104. */
  62105. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62106. /**
  62107. * Compute the final position from a segment made of destination-position
  62108. * @param position world position
  62109. * @param destination world position
  62110. * @returns the resulting point along the navmesh
  62111. */
  62112. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62113. /**
  62114. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62115. * @param start world position
  62116. * @param end world position
  62117. * @returns array containing world position composing the path
  62118. */
  62119. computePath(start: Vector3, end: Vector3): Vector3[];
  62120. /**
  62121. * Create a new Crowd so you can add agents
  62122. * @param maxAgents the maximum agent count in the crowd
  62123. * @param maxAgentRadius the maximum radius an agent can have
  62124. * @param scene to attach the crowd to
  62125. * @returns the crowd you can add agents to
  62126. */
  62127. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62128. /**
  62129. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62130. * The queries will try to find a solution within those bounds
  62131. * default is (1,1,1)
  62132. * @param extent x,y,z value that define the extent around the queries point of reference
  62133. */
  62134. setDefaultQueryExtent(extent: Vector3): void;
  62135. /**
  62136. * Get the Bounding box extent specified by setDefaultQueryExtent
  62137. * @returns the box extent values
  62138. */
  62139. getDefaultQueryExtent(): Vector3;
  62140. /**
  62141. * Disposes
  62142. */
  62143. dispose(): void;
  62144. /**
  62145. * If this plugin is supported
  62146. * @returns true if plugin is supported
  62147. */
  62148. isSupported(): boolean;
  62149. }
  62150. /**
  62151. * Recast detour crowd implementation
  62152. */
  62153. export class RecastJSCrowd implements ICrowd {
  62154. /**
  62155. * Recast/detour plugin
  62156. */
  62157. bjsRECASTPlugin: RecastJSPlugin;
  62158. /**
  62159. * Link to the detour crowd
  62160. */
  62161. recastCrowd: any;
  62162. /**
  62163. * One transform per agent
  62164. */
  62165. transforms: TransformNode[];
  62166. /**
  62167. * All agents created
  62168. */
  62169. agents: number[];
  62170. /**
  62171. * Link to the scene is kept to unregister the crowd from the scene
  62172. */
  62173. private _scene;
  62174. /**
  62175. * Observer for crowd updates
  62176. */
  62177. private _onBeforeAnimationsObserver;
  62178. /**
  62179. * Constructor
  62180. * @param plugin recastJS plugin
  62181. * @param maxAgents the maximum agent count in the crowd
  62182. * @param maxAgentRadius the maximum radius an agent can have
  62183. * @param scene to attach the crowd to
  62184. * @returns the crowd you can add agents to
  62185. */
  62186. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62187. /**
  62188. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62189. * You can attach anything to that node. The node position is updated in the scene update tick.
  62190. * @param pos world position that will be constrained by the navigation mesh
  62191. * @param parameters agent parameters
  62192. * @param transform hooked to the agent that will be update by the scene
  62193. * @returns agent index
  62194. */
  62195. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62196. /**
  62197. * Returns the agent position in world space
  62198. * @param index agent index returned by addAgent
  62199. * @returns world space position
  62200. */
  62201. getAgentPosition(index: number): Vector3;
  62202. /**
  62203. * Returns the agent velocity in world space
  62204. * @param index agent index returned by addAgent
  62205. * @returns world space velocity
  62206. */
  62207. getAgentVelocity(index: number): Vector3;
  62208. /**
  62209. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62210. * @param index agent index returned by addAgent
  62211. * @param destination targeted world position
  62212. */
  62213. agentGoto(index: number, destination: Vector3): void;
  62214. /**
  62215. * Teleport the agent to a new position
  62216. * @param index agent index returned by addAgent
  62217. * @param destination targeted world position
  62218. */
  62219. agentTeleport(index: number, destination: Vector3): void;
  62220. /**
  62221. * Update agent parameters
  62222. * @param index agent index returned by addAgent
  62223. * @param parameters agent parameters
  62224. */
  62225. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62226. /**
  62227. * remove a particular agent previously created
  62228. * @param index agent index returned by addAgent
  62229. */
  62230. removeAgent(index: number): void;
  62231. /**
  62232. * get the list of all agents attached to this crowd
  62233. * @returns list of agent indices
  62234. */
  62235. getAgents(): number[];
  62236. /**
  62237. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62238. * @param deltaTime in seconds
  62239. */
  62240. update(deltaTime: number): void;
  62241. /**
  62242. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62243. * The queries will try to find a solution within those bounds
  62244. * default is (1,1,1)
  62245. * @param extent x,y,z value that define the extent around the queries point of reference
  62246. */
  62247. setDefaultQueryExtent(extent: Vector3): void;
  62248. /**
  62249. * Get the Bounding box extent specified by setDefaultQueryExtent
  62250. * @returns the box extent values
  62251. */
  62252. getDefaultQueryExtent(): Vector3;
  62253. /**
  62254. * Release all resources
  62255. */
  62256. dispose(): void;
  62257. }
  62258. }
  62259. declare module BABYLON {
  62260. /**
  62261. * Class used to enable access to IndexedDB
  62262. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62263. */
  62264. export class Database implements IOfflineProvider {
  62265. private _callbackManifestChecked;
  62266. private _currentSceneUrl;
  62267. private _db;
  62268. private _enableSceneOffline;
  62269. private _enableTexturesOffline;
  62270. private _manifestVersionFound;
  62271. private _mustUpdateRessources;
  62272. private _hasReachedQuota;
  62273. private _isSupported;
  62274. private _idbFactory;
  62275. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62276. private static IsUASupportingBlobStorage;
  62277. /**
  62278. * Gets a boolean indicating if Database storate is enabled (off by default)
  62279. */
  62280. static IDBStorageEnabled: boolean;
  62281. /**
  62282. * Gets a boolean indicating if scene must be saved in the database
  62283. */
  62284. get enableSceneOffline(): boolean;
  62285. /**
  62286. * Gets a boolean indicating if textures must be saved in the database
  62287. */
  62288. get enableTexturesOffline(): boolean;
  62289. /**
  62290. * Creates a new Database
  62291. * @param urlToScene defines the url to load the scene
  62292. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62293. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62294. */
  62295. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62296. private static _ParseURL;
  62297. private static _ReturnFullUrlLocation;
  62298. private _checkManifestFile;
  62299. /**
  62300. * Open the database and make it available
  62301. * @param successCallback defines the callback to call on success
  62302. * @param errorCallback defines the callback to call on error
  62303. */
  62304. open(successCallback: () => void, errorCallback: () => void): void;
  62305. /**
  62306. * Loads an image from the database
  62307. * @param url defines the url to load from
  62308. * @param image defines the target DOM image
  62309. */
  62310. loadImage(url: string, image: HTMLImageElement): void;
  62311. private _loadImageFromDBAsync;
  62312. private _saveImageIntoDBAsync;
  62313. private _checkVersionFromDB;
  62314. private _loadVersionFromDBAsync;
  62315. private _saveVersionIntoDBAsync;
  62316. /**
  62317. * Loads a file from database
  62318. * @param url defines the URL to load from
  62319. * @param sceneLoaded defines a callback to call on success
  62320. * @param progressCallBack defines a callback to call when progress changed
  62321. * @param errorCallback defines a callback to call on error
  62322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62323. */
  62324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62325. private _loadFileAsync;
  62326. private _saveFileAsync;
  62327. /**
  62328. * Validates if xhr data is correct
  62329. * @param xhr defines the request to validate
  62330. * @param dataType defines the expected data type
  62331. * @returns true if data is correct
  62332. */
  62333. private static _ValidateXHRData;
  62334. }
  62335. }
  62336. declare module BABYLON {
  62337. /** @hidden */
  62338. export var gpuUpdateParticlesPixelShader: {
  62339. name: string;
  62340. shader: string;
  62341. };
  62342. }
  62343. declare module BABYLON {
  62344. /** @hidden */
  62345. export var gpuUpdateParticlesVertexShader: {
  62346. name: string;
  62347. shader: string;
  62348. };
  62349. }
  62350. declare module BABYLON {
  62351. /** @hidden */
  62352. export var clipPlaneFragmentDeclaration2: {
  62353. name: string;
  62354. shader: string;
  62355. };
  62356. }
  62357. declare module BABYLON {
  62358. /** @hidden */
  62359. export var gpuRenderParticlesPixelShader: {
  62360. name: string;
  62361. shader: string;
  62362. };
  62363. }
  62364. declare module BABYLON {
  62365. /** @hidden */
  62366. export var clipPlaneVertexDeclaration2: {
  62367. name: string;
  62368. shader: string;
  62369. };
  62370. }
  62371. declare module BABYLON {
  62372. /** @hidden */
  62373. export var gpuRenderParticlesVertexShader: {
  62374. name: string;
  62375. shader: string;
  62376. };
  62377. }
  62378. declare module BABYLON {
  62379. /**
  62380. * This represents a GPU particle system in Babylon
  62381. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62382. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62383. */
  62384. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62385. /**
  62386. * The layer mask we are rendering the particles through.
  62387. */
  62388. layerMask: number;
  62389. private _capacity;
  62390. private _activeCount;
  62391. private _currentActiveCount;
  62392. private _accumulatedCount;
  62393. private _renderEffect;
  62394. private _updateEffect;
  62395. private _buffer0;
  62396. private _buffer1;
  62397. private _spriteBuffer;
  62398. private _updateVAO;
  62399. private _renderVAO;
  62400. private _targetIndex;
  62401. private _sourceBuffer;
  62402. private _targetBuffer;
  62403. private _engine;
  62404. private _currentRenderId;
  62405. private _started;
  62406. private _stopped;
  62407. private _timeDelta;
  62408. private _randomTexture;
  62409. private _randomTexture2;
  62410. private _attributesStrideSize;
  62411. private _updateEffectOptions;
  62412. private _randomTextureSize;
  62413. private _actualFrame;
  62414. private readonly _rawTextureWidth;
  62415. /**
  62416. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62417. */
  62418. static get IsSupported(): boolean;
  62419. /**
  62420. * An event triggered when the system is disposed.
  62421. */
  62422. onDisposeObservable: Observable<GPUParticleSystem>;
  62423. /**
  62424. * Gets the maximum number of particles active at the same time.
  62425. * @returns The max number of active particles.
  62426. */
  62427. getCapacity(): number;
  62428. /**
  62429. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62430. * to override the particles.
  62431. */
  62432. forceDepthWrite: boolean;
  62433. /**
  62434. * Gets or set the number of active particles
  62435. */
  62436. get activeParticleCount(): number;
  62437. set activeParticleCount(value: number);
  62438. private _preWarmDone;
  62439. /**
  62440. * Specifies if the particles are updated in emitter local space or world space.
  62441. * This is always false for GPU particles
  62442. */
  62443. get isLocal(): boolean;
  62444. set isLocal(value: boolean);
  62445. /**
  62446. * Is this system ready to be used/rendered
  62447. * @return true if the system is ready
  62448. */
  62449. isReady(): boolean;
  62450. /**
  62451. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62452. * @returns True if it has been started, otherwise false.
  62453. */
  62454. isStarted(): boolean;
  62455. /**
  62456. * Starts the particle system and begins to emit
  62457. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62458. */
  62459. start(delay?: number): void;
  62460. /**
  62461. * Stops the particle system.
  62462. */
  62463. stop(): void;
  62464. /**
  62465. * Remove all active particles
  62466. */
  62467. reset(): void;
  62468. /**
  62469. * Returns the string "GPUParticleSystem"
  62470. * @returns a string containing the class name
  62471. */
  62472. getClassName(): string;
  62473. private _colorGradientsTexture;
  62474. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62475. /**
  62476. * Adds a new color gradient
  62477. * @param gradient defines the gradient to use (between 0 and 1)
  62478. * @param color1 defines the color to affect to the specified gradient
  62479. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62480. * @returns the current particle system
  62481. */
  62482. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62483. /**
  62484. * Remove a specific color gradient
  62485. * @param gradient defines the gradient to remove
  62486. * @returns the current particle system
  62487. */
  62488. removeColorGradient(gradient: number): GPUParticleSystem;
  62489. private _angularSpeedGradientsTexture;
  62490. private _sizeGradientsTexture;
  62491. private _velocityGradientsTexture;
  62492. private _limitVelocityGradientsTexture;
  62493. private _dragGradientsTexture;
  62494. private _addFactorGradient;
  62495. /**
  62496. * Adds a new size gradient
  62497. * @param gradient defines the gradient to use (between 0 and 1)
  62498. * @param factor defines the size factor to affect to the specified gradient
  62499. * @returns the current particle system
  62500. */
  62501. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62502. /**
  62503. * Remove a specific size gradient
  62504. * @param gradient defines the gradient to remove
  62505. * @returns the current particle system
  62506. */
  62507. removeSizeGradient(gradient: number): GPUParticleSystem;
  62508. /**
  62509. * Adds a new angular speed gradient
  62510. * @param gradient defines the gradient to use (between 0 and 1)
  62511. * @param factor defines the angular speed to affect to the specified gradient
  62512. * @returns the current particle system
  62513. */
  62514. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62515. /**
  62516. * Remove a specific angular speed gradient
  62517. * @param gradient defines the gradient to remove
  62518. * @returns the current particle system
  62519. */
  62520. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62521. /**
  62522. * Adds a new velocity gradient
  62523. * @param gradient defines the gradient to use (between 0 and 1)
  62524. * @param factor defines the velocity to affect to the specified gradient
  62525. * @returns the current particle system
  62526. */
  62527. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62528. /**
  62529. * Remove a specific velocity gradient
  62530. * @param gradient defines the gradient to remove
  62531. * @returns the current particle system
  62532. */
  62533. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62534. /**
  62535. * Adds a new limit velocity gradient
  62536. * @param gradient defines the gradient to use (between 0 and 1)
  62537. * @param factor defines the limit velocity value to affect to the specified gradient
  62538. * @returns the current particle system
  62539. */
  62540. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62541. /**
  62542. * Remove a specific limit velocity gradient
  62543. * @param gradient defines the gradient to remove
  62544. * @returns the current particle system
  62545. */
  62546. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62547. /**
  62548. * Adds a new drag gradient
  62549. * @param gradient defines the gradient to use (between 0 and 1)
  62550. * @param factor defines the drag value to affect to the specified gradient
  62551. * @returns the current particle system
  62552. */
  62553. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62554. /**
  62555. * Remove a specific drag gradient
  62556. * @param gradient defines the gradient to remove
  62557. * @returns the current particle system
  62558. */
  62559. removeDragGradient(gradient: number): GPUParticleSystem;
  62560. /**
  62561. * Not supported by GPUParticleSystem
  62562. * @param gradient defines the gradient to use (between 0 and 1)
  62563. * @param factor defines the emit rate value to affect to the specified gradient
  62564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62565. * @returns the current particle system
  62566. */
  62567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62568. /**
  62569. * Not supported by GPUParticleSystem
  62570. * @param gradient defines the gradient to remove
  62571. * @returns the current particle system
  62572. */
  62573. removeEmitRateGradient(gradient: number): IParticleSystem;
  62574. /**
  62575. * Not supported by GPUParticleSystem
  62576. * @param gradient defines the gradient to use (between 0 and 1)
  62577. * @param factor defines the start size value to affect to the specified gradient
  62578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62579. * @returns the current particle system
  62580. */
  62581. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62582. /**
  62583. * Not supported by GPUParticleSystem
  62584. * @param gradient defines the gradient to remove
  62585. * @returns the current particle system
  62586. */
  62587. removeStartSizeGradient(gradient: number): IParticleSystem;
  62588. /**
  62589. * Not supported by GPUParticleSystem
  62590. * @param gradient defines the gradient to use (between 0 and 1)
  62591. * @param min defines the color remap minimal range
  62592. * @param max defines the color remap maximal range
  62593. * @returns the current particle system
  62594. */
  62595. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62596. /**
  62597. * Not supported by GPUParticleSystem
  62598. * @param gradient defines the gradient to remove
  62599. * @returns the current particle system
  62600. */
  62601. removeColorRemapGradient(): IParticleSystem;
  62602. /**
  62603. * Not supported by GPUParticleSystem
  62604. * @param gradient defines the gradient to use (between 0 and 1)
  62605. * @param min defines the alpha remap minimal range
  62606. * @param max defines the alpha remap maximal range
  62607. * @returns the current particle system
  62608. */
  62609. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62610. /**
  62611. * Not supported by GPUParticleSystem
  62612. * @param gradient defines the gradient to remove
  62613. * @returns the current particle system
  62614. */
  62615. removeAlphaRemapGradient(): IParticleSystem;
  62616. /**
  62617. * Not supported by GPUParticleSystem
  62618. * @param gradient defines the gradient to use (between 0 and 1)
  62619. * @param color defines the color to affect to the specified gradient
  62620. * @returns the current particle system
  62621. */
  62622. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62623. /**
  62624. * Not supported by GPUParticleSystem
  62625. * @param gradient defines the gradient to remove
  62626. * @returns the current particle system
  62627. */
  62628. removeRampGradient(): IParticleSystem;
  62629. /**
  62630. * Not supported by GPUParticleSystem
  62631. * @returns the list of ramp gradients
  62632. */
  62633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62634. /**
  62635. * Not supported by GPUParticleSystem
  62636. * Gets or sets a boolean indicating that ramp gradients must be used
  62637. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62638. */
  62639. get useRampGradients(): boolean;
  62640. set useRampGradients(value: boolean);
  62641. /**
  62642. * Not supported by GPUParticleSystem
  62643. * @param gradient defines the gradient to use (between 0 and 1)
  62644. * @param factor defines the life time factor to affect to the specified gradient
  62645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62646. * @returns the current particle system
  62647. */
  62648. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62649. /**
  62650. * Not supported by GPUParticleSystem
  62651. * @param gradient defines the gradient to remove
  62652. * @returns the current particle system
  62653. */
  62654. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62655. /**
  62656. * Instantiates a GPU particle system.
  62657. * 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.
  62658. * @param name The name of the particle system
  62659. * @param options The options used to create the system
  62660. * @param scene The scene the particle system belongs to
  62661. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62662. */
  62663. constructor(name: string, options: Partial<{
  62664. capacity: number;
  62665. randomTextureSize: number;
  62666. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62667. protected _reset(): void;
  62668. private _createUpdateVAO;
  62669. private _createRenderVAO;
  62670. private _initialize;
  62671. /** @hidden */
  62672. _recreateUpdateEffect(): void;
  62673. /** @hidden */
  62674. _recreateRenderEffect(): void;
  62675. /**
  62676. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62677. * @param preWarm defines if we are in the pre-warmimg phase
  62678. */
  62679. animate(preWarm?: boolean): void;
  62680. private _createFactorGradientTexture;
  62681. private _createSizeGradientTexture;
  62682. private _createAngularSpeedGradientTexture;
  62683. private _createVelocityGradientTexture;
  62684. private _createLimitVelocityGradientTexture;
  62685. private _createDragGradientTexture;
  62686. private _createColorGradientTexture;
  62687. /**
  62688. * Renders the particle system in its current state
  62689. * @param preWarm defines if the system should only update the particles but not render them
  62690. * @returns the current number of particles
  62691. */
  62692. render(preWarm?: boolean): number;
  62693. /**
  62694. * Rebuilds the particle system
  62695. */
  62696. rebuild(): void;
  62697. private _releaseBuffers;
  62698. private _releaseVAOs;
  62699. /**
  62700. * Disposes the particle system and free the associated resources
  62701. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62702. */
  62703. dispose(disposeTexture?: boolean): void;
  62704. /**
  62705. * Clones the particle system.
  62706. * @param name The name of the cloned object
  62707. * @param newEmitter The new emitter to use
  62708. * @returns the cloned particle system
  62709. */
  62710. clone(name: string, newEmitter: any): GPUParticleSystem;
  62711. /**
  62712. * Serializes the particle system to a JSON object.
  62713. * @returns the JSON object
  62714. */
  62715. serialize(): any;
  62716. /**
  62717. * Parses a JSON object to create a GPU particle system.
  62718. * @param parsedParticleSystem The JSON object to parse
  62719. * @param scene The scene to create the particle system in
  62720. * @param rootUrl The root url to use to load external dependencies like texture
  62721. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62722. * @returns the parsed GPU particle system
  62723. */
  62724. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62725. }
  62726. }
  62727. declare module BABYLON {
  62728. /**
  62729. * Represents a set of particle systems working together to create a specific effect
  62730. */
  62731. export class ParticleSystemSet implements IDisposable {
  62732. /**
  62733. * Gets or sets base Assets URL
  62734. */
  62735. static BaseAssetsUrl: string;
  62736. private _emitterCreationOptions;
  62737. private _emitterNode;
  62738. /**
  62739. * Gets the particle system list
  62740. */
  62741. systems: IParticleSystem[];
  62742. /**
  62743. * Gets the emitter node used with this set
  62744. */
  62745. get emitterNode(): Nullable<TransformNode>;
  62746. /**
  62747. * Creates a new emitter mesh as a sphere
  62748. * @param options defines the options used to create the sphere
  62749. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62750. * @param scene defines the hosting scene
  62751. */
  62752. setEmitterAsSphere(options: {
  62753. diameter: number;
  62754. segments: number;
  62755. color: Color3;
  62756. }, renderingGroupId: number, scene: Scene): void;
  62757. /**
  62758. * Starts all particle systems of the set
  62759. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62760. */
  62761. start(emitter?: AbstractMesh): void;
  62762. /**
  62763. * Release all associated resources
  62764. */
  62765. dispose(): void;
  62766. /**
  62767. * Serialize the set into a JSON compatible object
  62768. * @returns a JSON compatible representation of the set
  62769. */
  62770. serialize(): any;
  62771. /**
  62772. * Parse a new ParticleSystemSet from a serialized source
  62773. * @param data defines a JSON compatible representation of the set
  62774. * @param scene defines the hosting scene
  62775. * @param gpu defines if we want GPU particles or CPU particles
  62776. * @returns a new ParticleSystemSet
  62777. */
  62778. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62779. }
  62780. }
  62781. declare module BABYLON {
  62782. /**
  62783. * This class is made for on one-liner static method to help creating particle system set.
  62784. */
  62785. export class ParticleHelper {
  62786. /**
  62787. * Gets or sets base Assets URL
  62788. */
  62789. static BaseAssetsUrl: string;
  62790. /**
  62791. * Create a default particle system that you can tweak
  62792. * @param emitter defines the emitter to use
  62793. * @param capacity defines the system capacity (default is 500 particles)
  62794. * @param scene defines the hosting scene
  62795. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62796. * @returns the new Particle system
  62797. */
  62798. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62799. /**
  62800. * This is the main static method (one-liner) of this helper to create different particle systems
  62801. * @param type This string represents the type to the particle system to create
  62802. * @param scene The scene where the particle system should live
  62803. * @param gpu If the system will use gpu
  62804. * @returns the ParticleSystemSet created
  62805. */
  62806. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62807. /**
  62808. * Static function used to export a particle system to a ParticleSystemSet variable.
  62809. * Please note that the emitter shape is not exported
  62810. * @param systems defines the particle systems to export
  62811. * @returns the created particle system set
  62812. */
  62813. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62814. }
  62815. }
  62816. declare module BABYLON {
  62817. interface Engine {
  62818. /**
  62819. * Create an effect to use with particle systems.
  62820. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62821. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62822. * @param uniformsNames defines a list of attribute names
  62823. * @param samplers defines an array of string used to represent textures
  62824. * @param defines defines the string containing the defines to use to compile the shaders
  62825. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62826. * @param onCompiled defines a function to call when the effect creation is successful
  62827. * @param onError defines a function to call when the effect creation has failed
  62828. * @returns the new Effect
  62829. */
  62830. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62831. }
  62832. interface Mesh {
  62833. /**
  62834. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62835. * @returns an array of IParticleSystem
  62836. */
  62837. getEmittedParticleSystems(): IParticleSystem[];
  62838. /**
  62839. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62840. * @returns an array of IParticleSystem
  62841. */
  62842. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62843. }
  62844. /**
  62845. * @hidden
  62846. */
  62847. export var _IDoNeedToBeInTheBuild: number;
  62848. }
  62849. declare module BABYLON {
  62850. /** Defines the 4 color options */
  62851. export enum PointColor {
  62852. /** color value */
  62853. Color = 2,
  62854. /** uv value */
  62855. UV = 1,
  62856. /** random value */
  62857. Random = 0,
  62858. /** stated value */
  62859. Stated = 3
  62860. }
  62861. /**
  62862. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62863. * 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.
  62864. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62865. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62866. *
  62867. * Full documentation here : TO BE ENTERED
  62868. */
  62869. export class PointsCloudSystem implements IDisposable {
  62870. /**
  62871. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62872. * Example : var p = SPS.particles[i];
  62873. */
  62874. particles: CloudPoint[];
  62875. /**
  62876. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62877. */
  62878. nbParticles: number;
  62879. /**
  62880. * This a counter for your own usage. It's not set by any SPS functions.
  62881. */
  62882. counter: number;
  62883. /**
  62884. * The PCS name. This name is also given to the underlying mesh.
  62885. */
  62886. name: string;
  62887. /**
  62888. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62889. */
  62890. mesh: Mesh;
  62891. /**
  62892. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62893. * Please read :
  62894. */
  62895. vars: any;
  62896. /**
  62897. * @hidden
  62898. */
  62899. _size: number;
  62900. private _scene;
  62901. private _promises;
  62902. private _positions;
  62903. private _indices;
  62904. private _normals;
  62905. private _colors;
  62906. private _uvs;
  62907. private _indices32;
  62908. private _positions32;
  62909. private _colors32;
  62910. private _uvs32;
  62911. private _updatable;
  62912. private _isVisibilityBoxLocked;
  62913. private _alwaysVisible;
  62914. private _groups;
  62915. private _groupCounter;
  62916. private _computeParticleColor;
  62917. private _computeParticleTexture;
  62918. private _computeParticleRotation;
  62919. private _computeBoundingBox;
  62920. private _isReady;
  62921. /**
  62922. * Creates a PCS (Points Cloud System) object
  62923. * @param name (String) is the PCS name, this will be the underlying mesh name
  62924. * @param pointSize (number) is the size for each point
  62925. * @param scene (Scene) is the scene in which the PCS is added
  62926. * @param options defines the options of the PCS e.g.
  62927. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62928. */
  62929. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62930. updatable?: boolean;
  62931. });
  62932. /**
  62933. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62934. * If no points were added to the PCS, the returned mesh is just a single point.
  62935. * @returns a promise for the created mesh
  62936. */
  62937. buildMeshAsync(): Promise<Mesh>;
  62938. /**
  62939. * @hidden
  62940. */
  62941. private _buildMesh;
  62942. private _addParticle;
  62943. private _randomUnitVector;
  62944. private _getColorIndicesForCoord;
  62945. private _setPointsColorOrUV;
  62946. private _colorFromTexture;
  62947. private _calculateDensity;
  62948. /**
  62949. * Adds points to the PCS in random positions within a unit sphere
  62950. * @param nb (positive integer) the number of particles to be created from this model
  62951. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62952. * @returns the number of groups in the system
  62953. */
  62954. addPoints(nb: number, pointFunction?: any): number;
  62955. /**
  62956. * Adds points to the PCS from the surface of the model shape
  62957. * @param mesh is any Mesh object that will be used as a surface model for the points
  62958. * @param nb (positive integer) the number of particles to be created from this model
  62959. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62960. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62961. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62962. * @returns the number of groups in the system
  62963. */
  62964. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62965. /**
  62966. * Adds points to the PCS inside the model shape
  62967. * @param mesh is any Mesh object that will be used as a surface model for the points
  62968. * @param nb (positive integer) the number of particles to be created from this model
  62969. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62970. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62971. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62972. * @returns the number of groups in the system
  62973. */
  62974. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62975. /**
  62976. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62977. * This method calls `updateParticle()` for each particle of the SPS.
  62978. * For an animated SPS, it is usually called within the render loop.
  62979. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62980. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62981. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62982. * @returns the PCS.
  62983. */
  62984. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62985. /**
  62986. * Disposes the PCS.
  62987. */
  62988. dispose(): void;
  62989. /**
  62990. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62991. * doc :
  62992. * @returns the PCS.
  62993. */
  62994. refreshVisibleSize(): PointsCloudSystem;
  62995. /**
  62996. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62997. * @param size the size (float) of the visibility box
  62998. * note : this doesn't lock the PCS mesh bounding box.
  62999. * doc :
  63000. */
  63001. setVisibilityBox(size: number): void;
  63002. /**
  63003. * Gets whether the PCS is always visible or not
  63004. * doc :
  63005. */
  63006. get isAlwaysVisible(): boolean;
  63007. /**
  63008. * Sets the PCS as always visible or not
  63009. * doc :
  63010. */
  63011. set isAlwaysVisible(val: boolean);
  63012. /**
  63013. * Tells to `setParticles()` to compute the particle rotations or not
  63014. * Default value : false. The PCS is faster when it's set to false
  63015. * Note : particle rotations are only applied to parent particles
  63016. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63017. */
  63018. set computeParticleRotation(val: boolean);
  63019. /**
  63020. * Tells to `setParticles()` to compute the particle colors or not.
  63021. * Default value : true. The PCS is faster when it's set to false.
  63022. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63023. */
  63024. set computeParticleColor(val: boolean);
  63025. set computeParticleTexture(val: boolean);
  63026. /**
  63027. * Gets if `setParticles()` computes the particle colors or not.
  63028. * Default value : false. The PCS is faster when it's set to false.
  63029. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63030. */
  63031. get computeParticleColor(): boolean;
  63032. /**
  63033. * Gets if `setParticles()` computes the particle textures or not.
  63034. * Default value : false. The PCS is faster when it's set to false.
  63035. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63036. */
  63037. get computeParticleTexture(): boolean;
  63038. /**
  63039. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63040. */
  63041. set computeBoundingBox(val: boolean);
  63042. /**
  63043. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63044. */
  63045. get computeBoundingBox(): boolean;
  63046. /**
  63047. * This function does nothing. It may be overwritten to set all the particle first values.
  63048. * The PCS doesn't call this function, you may have to call it by your own.
  63049. * doc :
  63050. */
  63051. initParticles(): void;
  63052. /**
  63053. * This function does nothing. It may be overwritten to recycle a particle
  63054. * The PCS doesn't call this function, you can to call it
  63055. * doc :
  63056. * @param particle The particle to recycle
  63057. * @returns the recycled particle
  63058. */
  63059. recycleParticle(particle: CloudPoint): CloudPoint;
  63060. /**
  63061. * Updates a particle : this function should be overwritten by the user.
  63062. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63063. * doc :
  63064. * @example : just set a particle position or velocity and recycle conditions
  63065. * @param particle The particle to update
  63066. * @returns the updated particle
  63067. */
  63068. updateParticle(particle: CloudPoint): CloudPoint;
  63069. /**
  63070. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63071. * This does nothing and may be overwritten by the user.
  63072. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63073. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63074. * @param update the boolean update value actually passed to setParticles()
  63075. */
  63076. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63077. /**
  63078. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63079. * This will be passed three parameters.
  63080. * This does nothing and may be overwritten by the user.
  63081. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63082. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63083. * @param update the boolean update value actually passed to setParticles()
  63084. */
  63085. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Represents one particle of a points cloud system.
  63091. */
  63092. export class CloudPoint {
  63093. /**
  63094. * particle global index
  63095. */
  63096. idx: number;
  63097. /**
  63098. * The color of the particle
  63099. */
  63100. color: Nullable<Color4>;
  63101. /**
  63102. * The world space position of the particle.
  63103. */
  63104. position: Vector3;
  63105. /**
  63106. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63107. */
  63108. rotation: Vector3;
  63109. /**
  63110. * The world space rotation quaternion of the particle.
  63111. */
  63112. rotationQuaternion: Nullable<Quaternion>;
  63113. /**
  63114. * The uv of the particle.
  63115. */
  63116. uv: Nullable<Vector2>;
  63117. /**
  63118. * The current speed of the particle.
  63119. */
  63120. velocity: Vector3;
  63121. /**
  63122. * The pivot point in the particle local space.
  63123. */
  63124. pivot: Vector3;
  63125. /**
  63126. * Must the particle be translated from its pivot point in its local space ?
  63127. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63128. * Default : false
  63129. */
  63130. translateFromPivot: boolean;
  63131. /**
  63132. * Index of this particle in the global "positions" array (Internal use)
  63133. * @hidden
  63134. */
  63135. _pos: number;
  63136. /**
  63137. * @hidden Index of this particle in the global "indices" array (Internal use)
  63138. */
  63139. _ind: number;
  63140. /**
  63141. * Group this particle belongs to
  63142. */
  63143. _group: PointsGroup;
  63144. /**
  63145. * Group id of this particle
  63146. */
  63147. groupId: number;
  63148. /**
  63149. * Index of the particle in its group id (Internal use)
  63150. */
  63151. idxInGroup: number;
  63152. /**
  63153. * @hidden Particle BoundingInfo object (Internal use)
  63154. */
  63155. _boundingInfo: BoundingInfo;
  63156. /**
  63157. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63158. */
  63159. _pcs: PointsCloudSystem;
  63160. /**
  63161. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63162. */
  63163. _stillInvisible: boolean;
  63164. /**
  63165. * @hidden Last computed particle rotation matrix
  63166. */
  63167. _rotationMatrix: number[];
  63168. /**
  63169. * Parent particle Id, if any.
  63170. * Default null.
  63171. */
  63172. parentId: Nullable<number>;
  63173. /**
  63174. * @hidden Internal global position in the PCS.
  63175. */
  63176. _globalPosition: Vector3;
  63177. /**
  63178. * Creates a Point Cloud object.
  63179. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63180. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63181. * @param group (PointsGroup) is the group the particle belongs to
  63182. * @param groupId (integer) is the group identifier in the PCS.
  63183. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63184. * @param pcs defines the PCS it is associated to
  63185. */
  63186. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63187. /**
  63188. * get point size
  63189. */
  63190. get size(): Vector3;
  63191. /**
  63192. * Set point size
  63193. */
  63194. set size(scale: Vector3);
  63195. /**
  63196. * Legacy support, changed quaternion to rotationQuaternion
  63197. */
  63198. get quaternion(): Nullable<Quaternion>;
  63199. /**
  63200. * Legacy support, changed quaternion to rotationQuaternion
  63201. */
  63202. set quaternion(q: Nullable<Quaternion>);
  63203. /**
  63204. * Returns a boolean. True if the particle intersects a mesh, else false
  63205. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63206. * @param target is the object (point or mesh) what the intersection is computed against
  63207. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63208. * @returns true if it intersects
  63209. */
  63210. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63211. /**
  63212. * get the rotation matrix of the particle
  63213. * @hidden
  63214. */
  63215. getRotationMatrix(m: Matrix): void;
  63216. }
  63217. /**
  63218. * Represents a group of points in a points cloud system
  63219. * * PCS internal tool, don't use it manually.
  63220. */
  63221. export class PointsGroup {
  63222. /**
  63223. * The group id
  63224. * @hidden
  63225. */
  63226. groupID: number;
  63227. /**
  63228. * image data for group (internal use)
  63229. * @hidden
  63230. */
  63231. _groupImageData: Nullable<ArrayBufferView>;
  63232. /**
  63233. * Image Width (internal use)
  63234. * @hidden
  63235. */
  63236. _groupImgWidth: number;
  63237. /**
  63238. * Image Height (internal use)
  63239. * @hidden
  63240. */
  63241. _groupImgHeight: number;
  63242. /**
  63243. * Custom position function (internal use)
  63244. * @hidden
  63245. */
  63246. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63247. /**
  63248. * density per facet for surface points
  63249. * @hidden
  63250. */
  63251. _groupDensity: number[];
  63252. /**
  63253. * Only when points are colored by texture carries pointer to texture list array
  63254. * @hidden
  63255. */
  63256. _textureNb: number;
  63257. /**
  63258. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63259. * PCS internal tool, don't use it manually.
  63260. * @hidden
  63261. */
  63262. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63263. }
  63264. }
  63265. declare module BABYLON {
  63266. interface Scene {
  63267. /** @hidden (Backing field) */
  63268. _physicsEngine: Nullable<IPhysicsEngine>;
  63269. /** @hidden */
  63270. _physicsTimeAccumulator: number;
  63271. /**
  63272. * Gets the current physics engine
  63273. * @returns a IPhysicsEngine or null if none attached
  63274. */
  63275. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63276. /**
  63277. * Enables physics to the current scene
  63278. * @param gravity defines the scene's gravity for the physics engine
  63279. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63280. * @return a boolean indicating if the physics engine was initialized
  63281. */
  63282. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63283. /**
  63284. * Disables and disposes the physics engine associated with the scene
  63285. */
  63286. disablePhysicsEngine(): void;
  63287. /**
  63288. * Gets a boolean indicating if there is an active physics engine
  63289. * @returns a boolean indicating if there is an active physics engine
  63290. */
  63291. isPhysicsEnabled(): boolean;
  63292. /**
  63293. * Deletes a physics compound impostor
  63294. * @param compound defines the compound to delete
  63295. */
  63296. deleteCompoundImpostor(compound: any): void;
  63297. /**
  63298. * An event triggered when physic simulation is about to be run
  63299. */
  63300. onBeforePhysicsObservable: Observable<Scene>;
  63301. /**
  63302. * An event triggered when physic simulation has been done
  63303. */
  63304. onAfterPhysicsObservable: Observable<Scene>;
  63305. }
  63306. interface AbstractMesh {
  63307. /** @hidden */
  63308. _physicsImpostor: Nullable<PhysicsImpostor>;
  63309. /**
  63310. * Gets or sets impostor used for physic simulation
  63311. * @see http://doc.babylonjs.com/features/physics_engine
  63312. */
  63313. physicsImpostor: Nullable<PhysicsImpostor>;
  63314. /**
  63315. * Gets the current physics impostor
  63316. * @see http://doc.babylonjs.com/features/physics_engine
  63317. * @returns a physics impostor or null
  63318. */
  63319. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63320. /** Apply a physic impulse to the mesh
  63321. * @param force defines the force to apply
  63322. * @param contactPoint defines where to apply the force
  63323. * @returns the current mesh
  63324. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63325. */
  63326. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63327. /**
  63328. * Creates a physic joint between two meshes
  63329. * @param otherMesh defines the other mesh to use
  63330. * @param pivot1 defines the pivot to use on this mesh
  63331. * @param pivot2 defines the pivot to use on the other mesh
  63332. * @param options defines additional options (can be plugin dependent)
  63333. * @returns the current mesh
  63334. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63335. */
  63336. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63337. /** @hidden */
  63338. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63339. }
  63340. /**
  63341. * Defines the physics engine scene component responsible to manage a physics engine
  63342. */
  63343. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63344. /**
  63345. * The component name helpful to identify the component in the list of scene components.
  63346. */
  63347. readonly name: string;
  63348. /**
  63349. * The scene the component belongs to.
  63350. */
  63351. scene: Scene;
  63352. /**
  63353. * Creates a new instance of the component for the given scene
  63354. * @param scene Defines the scene to register the component in
  63355. */
  63356. constructor(scene: Scene);
  63357. /**
  63358. * Registers the component in a given scene
  63359. */
  63360. register(): void;
  63361. /**
  63362. * Rebuilds the elements related to this component in case of
  63363. * context lost for instance.
  63364. */
  63365. rebuild(): void;
  63366. /**
  63367. * Disposes the component and the associated ressources
  63368. */
  63369. dispose(): void;
  63370. }
  63371. }
  63372. declare module BABYLON {
  63373. /**
  63374. * A helper for physics simulations
  63375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63376. */
  63377. export class PhysicsHelper {
  63378. private _scene;
  63379. private _physicsEngine;
  63380. /**
  63381. * Initializes the Physics helper
  63382. * @param scene Babylon.js scene
  63383. */
  63384. constructor(scene: Scene);
  63385. /**
  63386. * Applies a radial explosion impulse
  63387. * @param origin the origin of the explosion
  63388. * @param radiusOrEventOptions the radius or the options of radial explosion
  63389. * @param strength the explosion strength
  63390. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63391. * @returns A physics radial explosion event, or null
  63392. */
  63393. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63394. /**
  63395. * Applies a radial explosion force
  63396. * @param origin the origin of the explosion
  63397. * @param radiusOrEventOptions the radius or the options of radial explosion
  63398. * @param strength the explosion strength
  63399. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63400. * @returns A physics radial explosion event, or null
  63401. */
  63402. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63403. /**
  63404. * Creates a gravitational field
  63405. * @param origin the origin of the explosion
  63406. * @param radiusOrEventOptions the radius or the options of radial explosion
  63407. * @param strength the explosion strength
  63408. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63409. * @returns A physics gravitational field event, or null
  63410. */
  63411. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63412. /**
  63413. * Creates a physics updraft event
  63414. * @param origin the origin of the updraft
  63415. * @param radiusOrEventOptions the radius or the options of the updraft
  63416. * @param strength the strength of the updraft
  63417. * @param height the height of the updraft
  63418. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63419. * @returns A physics updraft event, or null
  63420. */
  63421. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63422. /**
  63423. * Creates a physics vortex event
  63424. * @param origin the of the vortex
  63425. * @param radiusOrEventOptions the radius or the options of the vortex
  63426. * @param strength the strength of the vortex
  63427. * @param height the height of the vortex
  63428. * @returns a Physics vortex event, or null
  63429. * A physics vortex event or null
  63430. */
  63431. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63432. }
  63433. /**
  63434. * Represents a physics radial explosion event
  63435. */
  63436. class PhysicsRadialExplosionEvent {
  63437. private _scene;
  63438. private _options;
  63439. private _sphere;
  63440. private _dataFetched;
  63441. /**
  63442. * Initializes a radial explosioin event
  63443. * @param _scene BabylonJS scene
  63444. * @param _options The options for the vortex event
  63445. */
  63446. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63447. /**
  63448. * Returns the data related to the radial explosion event (sphere).
  63449. * @returns The radial explosion event data
  63450. */
  63451. getData(): PhysicsRadialExplosionEventData;
  63452. /**
  63453. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63454. * @param impostor A physics imposter
  63455. * @param origin the origin of the explosion
  63456. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63457. */
  63458. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63459. /**
  63460. * Triggers affecterd impostors callbacks
  63461. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63462. */
  63463. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63464. /**
  63465. * Disposes the sphere.
  63466. * @param force Specifies if the sphere should be disposed by force
  63467. */
  63468. dispose(force?: boolean): void;
  63469. /*** Helpers ***/
  63470. private _prepareSphere;
  63471. private _intersectsWithSphere;
  63472. }
  63473. /**
  63474. * Represents a gravitational field event
  63475. */
  63476. class PhysicsGravitationalFieldEvent {
  63477. private _physicsHelper;
  63478. private _scene;
  63479. private _origin;
  63480. private _options;
  63481. private _tickCallback;
  63482. private _sphere;
  63483. private _dataFetched;
  63484. /**
  63485. * Initializes the physics gravitational field event
  63486. * @param _physicsHelper A physics helper
  63487. * @param _scene BabylonJS scene
  63488. * @param _origin The origin position of the gravitational field event
  63489. * @param _options The options for the vortex event
  63490. */
  63491. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63492. /**
  63493. * Returns the data related to the gravitational field event (sphere).
  63494. * @returns A gravitational field event
  63495. */
  63496. getData(): PhysicsGravitationalFieldEventData;
  63497. /**
  63498. * Enables the gravitational field.
  63499. */
  63500. enable(): void;
  63501. /**
  63502. * Disables the gravitational field.
  63503. */
  63504. disable(): void;
  63505. /**
  63506. * Disposes the sphere.
  63507. * @param force The force to dispose from the gravitational field event
  63508. */
  63509. dispose(force?: boolean): void;
  63510. private _tick;
  63511. }
  63512. /**
  63513. * Represents a physics updraft event
  63514. */
  63515. class PhysicsUpdraftEvent {
  63516. private _scene;
  63517. private _origin;
  63518. private _options;
  63519. private _physicsEngine;
  63520. private _originTop;
  63521. private _originDirection;
  63522. private _tickCallback;
  63523. private _cylinder;
  63524. private _cylinderPosition;
  63525. private _dataFetched;
  63526. /**
  63527. * Initializes the physics updraft event
  63528. * @param _scene BabylonJS scene
  63529. * @param _origin The origin position of the updraft
  63530. * @param _options The options for the updraft event
  63531. */
  63532. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63533. /**
  63534. * Returns the data related to the updraft event (cylinder).
  63535. * @returns A physics updraft event
  63536. */
  63537. getData(): PhysicsUpdraftEventData;
  63538. /**
  63539. * Enables the updraft.
  63540. */
  63541. enable(): void;
  63542. /**
  63543. * Disables the updraft.
  63544. */
  63545. disable(): void;
  63546. /**
  63547. * Disposes the cylinder.
  63548. * @param force Specifies if the updraft should be disposed by force
  63549. */
  63550. dispose(force?: boolean): void;
  63551. private getImpostorHitData;
  63552. private _tick;
  63553. /*** Helpers ***/
  63554. private _prepareCylinder;
  63555. private _intersectsWithCylinder;
  63556. }
  63557. /**
  63558. * Represents a physics vortex event
  63559. */
  63560. class PhysicsVortexEvent {
  63561. private _scene;
  63562. private _origin;
  63563. private _options;
  63564. private _physicsEngine;
  63565. private _originTop;
  63566. private _tickCallback;
  63567. private _cylinder;
  63568. private _cylinderPosition;
  63569. private _dataFetched;
  63570. /**
  63571. * Initializes the physics vortex event
  63572. * @param _scene The BabylonJS scene
  63573. * @param _origin The origin position of the vortex
  63574. * @param _options The options for the vortex event
  63575. */
  63576. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63577. /**
  63578. * Returns the data related to the vortex event (cylinder).
  63579. * @returns The physics vortex event data
  63580. */
  63581. getData(): PhysicsVortexEventData;
  63582. /**
  63583. * Enables the vortex.
  63584. */
  63585. enable(): void;
  63586. /**
  63587. * Disables the cortex.
  63588. */
  63589. disable(): void;
  63590. /**
  63591. * Disposes the sphere.
  63592. * @param force
  63593. */
  63594. dispose(force?: boolean): void;
  63595. private getImpostorHitData;
  63596. private _tick;
  63597. /*** Helpers ***/
  63598. private _prepareCylinder;
  63599. private _intersectsWithCylinder;
  63600. }
  63601. /**
  63602. * Options fot the radial explosion event
  63603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63604. */
  63605. export class PhysicsRadialExplosionEventOptions {
  63606. /**
  63607. * The radius of the sphere for the radial explosion.
  63608. */
  63609. radius: number;
  63610. /**
  63611. * The strenth of the explosion.
  63612. */
  63613. strength: number;
  63614. /**
  63615. * The strenght of the force in correspondence to the distance of the affected object
  63616. */
  63617. falloff: PhysicsRadialImpulseFalloff;
  63618. /**
  63619. * Sphere options for the radial explosion.
  63620. */
  63621. sphere: {
  63622. segments: number;
  63623. diameter: number;
  63624. };
  63625. /**
  63626. * Sphere options for the radial explosion.
  63627. */
  63628. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63629. }
  63630. /**
  63631. * Options fot the updraft event
  63632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63633. */
  63634. export class PhysicsUpdraftEventOptions {
  63635. /**
  63636. * The radius of the cylinder for the vortex
  63637. */
  63638. radius: number;
  63639. /**
  63640. * The strenth of the updraft.
  63641. */
  63642. strength: number;
  63643. /**
  63644. * The height of the cylinder for the updraft.
  63645. */
  63646. height: number;
  63647. /**
  63648. * The mode for the the updraft.
  63649. */
  63650. updraftMode: PhysicsUpdraftMode;
  63651. }
  63652. /**
  63653. * Options fot the vortex event
  63654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63655. */
  63656. export class PhysicsVortexEventOptions {
  63657. /**
  63658. * The radius of the cylinder for the vortex
  63659. */
  63660. radius: number;
  63661. /**
  63662. * The strenth of the vortex.
  63663. */
  63664. strength: number;
  63665. /**
  63666. * The height of the cylinder for the vortex.
  63667. */
  63668. height: number;
  63669. /**
  63670. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63671. */
  63672. centripetalForceThreshold: number;
  63673. /**
  63674. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63675. */
  63676. centripetalForceMultiplier: number;
  63677. /**
  63678. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63679. */
  63680. centrifugalForceMultiplier: number;
  63681. /**
  63682. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63683. */
  63684. updraftForceMultiplier: number;
  63685. }
  63686. /**
  63687. * The strenght of the force in correspondence to the distance of the affected object
  63688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63689. */
  63690. export enum PhysicsRadialImpulseFalloff {
  63691. /** Defines that impulse is constant in strength across it's whole radius */
  63692. Constant = 0,
  63693. /** Defines that impulse gets weaker if it's further from the origin */
  63694. Linear = 1
  63695. }
  63696. /**
  63697. * The strength of the force in correspondence to the distance of the affected object
  63698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63699. */
  63700. export enum PhysicsUpdraftMode {
  63701. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63702. Center = 0,
  63703. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63704. Perpendicular = 1
  63705. }
  63706. /**
  63707. * Interface for a physics hit data
  63708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63709. */
  63710. export interface PhysicsHitData {
  63711. /**
  63712. * The force applied at the contact point
  63713. */
  63714. force: Vector3;
  63715. /**
  63716. * The contact point
  63717. */
  63718. contactPoint: Vector3;
  63719. /**
  63720. * The distance from the origin to the contact point
  63721. */
  63722. distanceFromOrigin: number;
  63723. }
  63724. /**
  63725. * Interface for radial explosion event data
  63726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63727. */
  63728. export interface PhysicsRadialExplosionEventData {
  63729. /**
  63730. * A sphere used for the radial explosion event
  63731. */
  63732. sphere: Mesh;
  63733. }
  63734. /**
  63735. * Interface for gravitational field event data
  63736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63737. */
  63738. export interface PhysicsGravitationalFieldEventData {
  63739. /**
  63740. * A sphere mesh used for the gravitational field event
  63741. */
  63742. sphere: Mesh;
  63743. }
  63744. /**
  63745. * Interface for updraft event data
  63746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63747. */
  63748. export interface PhysicsUpdraftEventData {
  63749. /**
  63750. * A cylinder used for the updraft event
  63751. */
  63752. cylinder: Mesh;
  63753. }
  63754. /**
  63755. * Interface for vortex event data
  63756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63757. */
  63758. export interface PhysicsVortexEventData {
  63759. /**
  63760. * A cylinder used for the vortex event
  63761. */
  63762. cylinder: Mesh;
  63763. }
  63764. /**
  63765. * Interface for an affected physics impostor
  63766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63767. */
  63768. export interface PhysicsAffectedImpostorWithData {
  63769. /**
  63770. * The impostor affected by the effect
  63771. */
  63772. impostor: PhysicsImpostor;
  63773. /**
  63774. * The data about the hit/horce from the explosion
  63775. */
  63776. hitData: PhysicsHitData;
  63777. }
  63778. }
  63779. declare module BABYLON {
  63780. /** @hidden */
  63781. export var blackAndWhitePixelShader: {
  63782. name: string;
  63783. shader: string;
  63784. };
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * Post process used to render in black and white
  63789. */
  63790. export class BlackAndWhitePostProcess extends PostProcess {
  63791. /**
  63792. * Linear about to convert he result to black and white (default: 1)
  63793. */
  63794. degree: number;
  63795. /**
  63796. * Creates a black and white post process
  63797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63798. * @param name The name of the effect.
  63799. * @param options The required width/height ratio to downsize to before computing the render pass.
  63800. * @param camera The camera to apply the render pass to.
  63801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63802. * @param engine The engine which the post process will be applied. (default: current engine)
  63803. * @param reusable If the post process can be reused on the same frame. (default: false)
  63804. */
  63805. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63806. }
  63807. }
  63808. declare module BABYLON {
  63809. /**
  63810. * This represents a set of one or more post processes in Babylon.
  63811. * A post process can be used to apply a shader to a texture after it is rendered.
  63812. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63813. */
  63814. export class PostProcessRenderEffect {
  63815. private _postProcesses;
  63816. private _getPostProcesses;
  63817. private _singleInstance;
  63818. private _cameras;
  63819. private _indicesForCamera;
  63820. /**
  63821. * Name of the effect
  63822. * @hidden
  63823. */
  63824. _name: string;
  63825. /**
  63826. * Instantiates a post process render effect.
  63827. * A post process can be used to apply a shader to a texture after it is rendered.
  63828. * @param engine The engine the effect is tied to
  63829. * @param name The name of the effect
  63830. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63831. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63832. */
  63833. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63834. /**
  63835. * Checks if all the post processes in the effect are supported.
  63836. */
  63837. get isSupported(): boolean;
  63838. /**
  63839. * Updates the current state of the effect
  63840. * @hidden
  63841. */
  63842. _update(): void;
  63843. /**
  63844. * Attaches the effect on cameras
  63845. * @param cameras The camera to attach to.
  63846. * @hidden
  63847. */
  63848. _attachCameras(cameras: Camera): void;
  63849. /**
  63850. * Attaches the effect on cameras
  63851. * @param cameras The camera to attach to.
  63852. * @hidden
  63853. */
  63854. _attachCameras(cameras: Camera[]): void;
  63855. /**
  63856. * Detaches the effect on cameras
  63857. * @param cameras The camera to detatch from.
  63858. * @hidden
  63859. */
  63860. _detachCameras(cameras: Camera): void;
  63861. /**
  63862. * Detatches the effect on cameras
  63863. * @param cameras The camera to detatch from.
  63864. * @hidden
  63865. */
  63866. _detachCameras(cameras: Camera[]): void;
  63867. /**
  63868. * Enables the effect on given cameras
  63869. * @param cameras The camera to enable.
  63870. * @hidden
  63871. */
  63872. _enable(cameras: Camera): void;
  63873. /**
  63874. * Enables the effect on given cameras
  63875. * @param cameras The camera to enable.
  63876. * @hidden
  63877. */
  63878. _enable(cameras: Nullable<Camera[]>): void;
  63879. /**
  63880. * Disables the effect on the given cameras
  63881. * @param cameras The camera to disable.
  63882. * @hidden
  63883. */
  63884. _disable(cameras: Camera): void;
  63885. /**
  63886. * Disables the effect on the given cameras
  63887. * @param cameras The camera to disable.
  63888. * @hidden
  63889. */
  63890. _disable(cameras: Nullable<Camera[]>): void;
  63891. /**
  63892. * Gets a list of the post processes contained in the effect.
  63893. * @param camera The camera to get the post processes on.
  63894. * @returns The list of the post processes in the effect.
  63895. */
  63896. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /** @hidden */
  63901. export var extractHighlightsPixelShader: {
  63902. name: string;
  63903. shader: string;
  63904. };
  63905. }
  63906. declare module BABYLON {
  63907. /**
  63908. * 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.
  63909. */
  63910. export class ExtractHighlightsPostProcess extends PostProcess {
  63911. /**
  63912. * The luminance threshold, pixels below this value will be set to black.
  63913. */
  63914. threshold: number;
  63915. /** @hidden */
  63916. _exposure: number;
  63917. /**
  63918. * Post process which has the input texture to be used when performing highlight extraction
  63919. * @hidden
  63920. */
  63921. _inputPostProcess: Nullable<PostProcess>;
  63922. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63923. }
  63924. }
  63925. declare module BABYLON {
  63926. /** @hidden */
  63927. export var bloomMergePixelShader: {
  63928. name: string;
  63929. shader: string;
  63930. };
  63931. }
  63932. declare module BABYLON {
  63933. /**
  63934. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63935. */
  63936. export class BloomMergePostProcess extends PostProcess {
  63937. /** Weight of the bloom to be added to the original input. */
  63938. weight: number;
  63939. /**
  63940. * Creates a new instance of @see BloomMergePostProcess
  63941. * @param name The name of the effect.
  63942. * @param originalFromInput Post process which's input will be used for the merge.
  63943. * @param blurred Blurred highlights post process which's output will be used.
  63944. * @param weight Weight of the bloom to be added to the original input.
  63945. * @param options The required width/height ratio to downsize to before computing the render pass.
  63946. * @param camera The camera to apply the render pass to.
  63947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63948. * @param engine The engine which the post process will be applied. (default: current engine)
  63949. * @param reusable If the post process can be reused on the same frame. (default: false)
  63950. * @param textureType Type of textures used when performing the post process. (default: 0)
  63951. * @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)
  63952. */
  63953. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63954. /** Weight of the bloom to be added to the original input. */
  63955. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63956. }
  63957. }
  63958. declare module BABYLON {
  63959. /**
  63960. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63961. */
  63962. export class BloomEffect extends PostProcessRenderEffect {
  63963. private bloomScale;
  63964. /**
  63965. * @hidden Internal
  63966. */
  63967. _effects: Array<PostProcess>;
  63968. /**
  63969. * @hidden Internal
  63970. */
  63971. _downscale: ExtractHighlightsPostProcess;
  63972. private _blurX;
  63973. private _blurY;
  63974. private _merge;
  63975. /**
  63976. * The luminance threshold to find bright areas of the image to bloom.
  63977. */
  63978. get threshold(): number;
  63979. set threshold(value: number);
  63980. /**
  63981. * The strength of the bloom.
  63982. */
  63983. get weight(): number;
  63984. set weight(value: number);
  63985. /**
  63986. * Specifies the size of the bloom blur kernel, relative to the final output size
  63987. */
  63988. get kernel(): number;
  63989. set kernel(value: number);
  63990. /**
  63991. * Creates a new instance of @see BloomEffect
  63992. * @param scene The scene the effect belongs to.
  63993. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63994. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63995. * @param bloomWeight The the strength of bloom.
  63996. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63997. * @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)
  63998. */
  63999. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64000. /**
  64001. * Disposes each of the internal effects for a given camera.
  64002. * @param camera The camera to dispose the effect on.
  64003. */
  64004. disposeEffects(camera: Camera): void;
  64005. /**
  64006. * @hidden Internal
  64007. */
  64008. _updateEffects(): void;
  64009. /**
  64010. * Internal
  64011. * @returns if all the contained post processes are ready.
  64012. * @hidden
  64013. */
  64014. _isReady(): boolean;
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /** @hidden */
  64019. export var chromaticAberrationPixelShader: {
  64020. name: string;
  64021. shader: string;
  64022. };
  64023. }
  64024. declare module BABYLON {
  64025. /**
  64026. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64027. */
  64028. export class ChromaticAberrationPostProcess extends PostProcess {
  64029. /**
  64030. * The amount of seperation of rgb channels (default: 30)
  64031. */
  64032. aberrationAmount: number;
  64033. /**
  64034. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64035. */
  64036. radialIntensity: number;
  64037. /**
  64038. * 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))
  64039. */
  64040. direction: Vector2;
  64041. /**
  64042. * 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))
  64043. */
  64044. centerPosition: Vector2;
  64045. /**
  64046. * Creates a new instance ChromaticAberrationPostProcess
  64047. * @param name The name of the effect.
  64048. * @param screenWidth The width of the screen to apply the effect on.
  64049. * @param screenHeight The height of the screen to apply the effect on.
  64050. * @param options The required width/height ratio to downsize to before computing the render pass.
  64051. * @param camera The camera to apply the render pass to.
  64052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64053. * @param engine The engine which the post process will be applied. (default: current engine)
  64054. * @param reusable If the post process can be reused on the same frame. (default: false)
  64055. * @param textureType Type of textures used when performing the post process. (default: 0)
  64056. * @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)
  64057. */
  64058. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64059. }
  64060. }
  64061. declare module BABYLON {
  64062. /** @hidden */
  64063. export var circleOfConfusionPixelShader: {
  64064. name: string;
  64065. shader: string;
  64066. };
  64067. }
  64068. declare module BABYLON {
  64069. /**
  64070. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64071. */
  64072. export class CircleOfConfusionPostProcess extends PostProcess {
  64073. /**
  64074. * 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.
  64075. */
  64076. lensSize: number;
  64077. /**
  64078. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64079. */
  64080. fStop: number;
  64081. /**
  64082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64083. */
  64084. focusDistance: number;
  64085. /**
  64086. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64087. */
  64088. focalLength: number;
  64089. private _depthTexture;
  64090. /**
  64091. * Creates a new instance CircleOfConfusionPostProcess
  64092. * @param name The name of the effect.
  64093. * @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.
  64094. * @param options The required width/height ratio to downsize to before computing the render pass.
  64095. * @param camera The camera to apply the render pass to.
  64096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64097. * @param engine The engine which the post process will be applied. (default: current engine)
  64098. * @param reusable If the post process can be reused on the same frame. (default: false)
  64099. * @param textureType Type of textures used when performing the post process. (default: 0)
  64100. * @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)
  64101. */
  64102. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64103. /**
  64104. * 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.
  64105. */
  64106. set depthTexture(value: RenderTargetTexture);
  64107. }
  64108. }
  64109. declare module BABYLON {
  64110. /** @hidden */
  64111. export var colorCorrectionPixelShader: {
  64112. name: string;
  64113. shader: string;
  64114. };
  64115. }
  64116. declare module BABYLON {
  64117. /**
  64118. *
  64119. * This post-process allows the modification of rendered colors by using
  64120. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64121. *
  64122. * The object needs to be provided an url to a texture containing the color
  64123. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64124. * Use an image editing software to tweak the LUT to match your needs.
  64125. *
  64126. * For an example of a color LUT, see here:
  64127. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64128. * For explanations on color grading, see here:
  64129. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64130. *
  64131. */
  64132. export class ColorCorrectionPostProcess extends PostProcess {
  64133. private _colorTableTexture;
  64134. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64135. }
  64136. }
  64137. declare module BABYLON {
  64138. /** @hidden */
  64139. export var convolutionPixelShader: {
  64140. name: string;
  64141. shader: string;
  64142. };
  64143. }
  64144. declare module BABYLON {
  64145. /**
  64146. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64147. * input texture to perform effects such as edge detection or sharpening
  64148. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64149. */
  64150. export class ConvolutionPostProcess extends PostProcess {
  64151. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64152. kernel: number[];
  64153. /**
  64154. * Creates a new instance ConvolutionPostProcess
  64155. * @param name The name of the effect.
  64156. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64157. * @param options The required width/height ratio to downsize to before computing the render pass.
  64158. * @param camera The camera to apply the render pass to.
  64159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64160. * @param engine The engine which the post process will be applied. (default: current engine)
  64161. * @param reusable If the post process can be reused on the same frame. (default: false)
  64162. * @param textureType Type of textures used when performing the post process. (default: 0)
  64163. */
  64164. constructor(name: string,
  64165. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64166. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64167. /**
  64168. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64169. */
  64170. static EdgeDetect0Kernel: number[];
  64171. /**
  64172. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64173. */
  64174. static EdgeDetect1Kernel: number[];
  64175. /**
  64176. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64177. */
  64178. static EdgeDetect2Kernel: number[];
  64179. /**
  64180. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64181. */
  64182. static SharpenKernel: number[];
  64183. /**
  64184. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64185. */
  64186. static EmbossKernel: number[];
  64187. /**
  64188. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64189. */
  64190. static GaussianKernel: number[];
  64191. }
  64192. }
  64193. declare module BABYLON {
  64194. /**
  64195. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64196. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64197. * based on samples that have a large difference in distance than the center pixel.
  64198. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64199. */
  64200. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64201. direction: Vector2;
  64202. /**
  64203. * Creates a new instance CircleOfConfusionPostProcess
  64204. * @param name The name of the effect.
  64205. * @param scene The scene the effect belongs to.
  64206. * @param direction The direction the blur should be applied.
  64207. * @param kernel The size of the kernel used to blur.
  64208. * @param options The required width/height ratio to downsize to before computing the render pass.
  64209. * @param camera The camera to apply the render pass to.
  64210. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64211. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64213. * @param engine The engine which the post process will be applied. (default: current engine)
  64214. * @param reusable If the post process can be reused on the same frame. (default: false)
  64215. * @param textureType Type of textures used when performing the post process. (default: 0)
  64216. * @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)
  64217. */
  64218. 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);
  64219. }
  64220. }
  64221. declare module BABYLON {
  64222. /** @hidden */
  64223. export var depthOfFieldMergePixelShader: {
  64224. name: string;
  64225. shader: string;
  64226. };
  64227. }
  64228. declare module BABYLON {
  64229. /**
  64230. * Options to be set when merging outputs from the default pipeline.
  64231. */
  64232. export class DepthOfFieldMergePostProcessOptions {
  64233. /**
  64234. * The original image to merge on top of
  64235. */
  64236. originalFromInput: PostProcess;
  64237. /**
  64238. * Parameters to perform the merge of the depth of field effect
  64239. */
  64240. depthOfField?: {
  64241. circleOfConfusion: PostProcess;
  64242. blurSteps: Array<PostProcess>;
  64243. };
  64244. /**
  64245. * Parameters to perform the merge of bloom effect
  64246. */
  64247. bloom?: {
  64248. blurred: PostProcess;
  64249. weight: number;
  64250. };
  64251. }
  64252. /**
  64253. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64254. */
  64255. export class DepthOfFieldMergePostProcess extends PostProcess {
  64256. private blurSteps;
  64257. /**
  64258. * Creates a new instance of DepthOfFieldMergePostProcess
  64259. * @param name The name of the effect.
  64260. * @param originalFromInput Post process which's input will be used for the merge.
  64261. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64262. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64263. * @param options The required width/height ratio to downsize to before computing the render pass.
  64264. * @param camera The camera to apply the render pass to.
  64265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64266. * @param engine The engine which the post process will be applied. (default: current engine)
  64267. * @param reusable If the post process can be reused on the same frame. (default: false)
  64268. * @param textureType Type of textures used when performing the post process. (default: 0)
  64269. * @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)
  64270. */
  64271. 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);
  64272. /**
  64273. * Updates the effect with the current post process compile time values and recompiles the shader.
  64274. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64275. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64276. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64277. * @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
  64278. * @param onCompiled Called when the shader has been compiled.
  64279. * @param onError Called if there is an error when compiling a shader.
  64280. */
  64281. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64282. }
  64283. }
  64284. declare module BABYLON {
  64285. /**
  64286. * Specifies the level of max blur that should be applied when using the depth of field effect
  64287. */
  64288. export enum DepthOfFieldEffectBlurLevel {
  64289. /**
  64290. * Subtle blur
  64291. */
  64292. Low = 0,
  64293. /**
  64294. * Medium blur
  64295. */
  64296. Medium = 1,
  64297. /**
  64298. * Large blur
  64299. */
  64300. High = 2
  64301. }
  64302. /**
  64303. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64304. */
  64305. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64306. private _circleOfConfusion;
  64307. /**
  64308. * @hidden Internal, blurs from high to low
  64309. */
  64310. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64311. private _depthOfFieldBlurY;
  64312. private _dofMerge;
  64313. /**
  64314. * @hidden Internal post processes in depth of field effect
  64315. */
  64316. _effects: Array<PostProcess>;
  64317. /**
  64318. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64319. */
  64320. set focalLength(value: number);
  64321. get focalLength(): number;
  64322. /**
  64323. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64324. */
  64325. set fStop(value: number);
  64326. get fStop(): number;
  64327. /**
  64328. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64329. */
  64330. set focusDistance(value: number);
  64331. get focusDistance(): number;
  64332. /**
  64333. * 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.
  64334. */
  64335. set lensSize(value: number);
  64336. get lensSize(): number;
  64337. /**
  64338. * Creates a new instance DepthOfFieldEffect
  64339. * @param scene The scene the effect belongs to.
  64340. * @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.
  64341. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64342. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  64343. */
  64344. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64345. /**
  64346. * Get the current class name of the current effet
  64347. * @returns "DepthOfFieldEffect"
  64348. */
  64349. getClassName(): string;
  64350. /**
  64351. * 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.
  64352. */
  64353. set depthTexture(value: RenderTargetTexture);
  64354. /**
  64355. * Disposes each of the internal effects for a given camera.
  64356. * @param camera The camera to dispose the effect on.
  64357. */
  64358. disposeEffects(camera: Camera): void;
  64359. /**
  64360. * @hidden Internal
  64361. */
  64362. _updateEffects(): void;
  64363. /**
  64364. * Internal
  64365. * @returns if all the contained post processes are ready.
  64366. * @hidden
  64367. */
  64368. _isReady(): boolean;
  64369. }
  64370. }
  64371. declare module BABYLON {
  64372. /** @hidden */
  64373. export var displayPassPixelShader: {
  64374. name: string;
  64375. shader: string;
  64376. };
  64377. }
  64378. declare module BABYLON {
  64379. /**
  64380. * DisplayPassPostProcess which produces an output the same as it's input
  64381. */
  64382. export class DisplayPassPostProcess extends PostProcess {
  64383. /**
  64384. * Creates the DisplayPassPostProcess
  64385. * @param name The name of the effect.
  64386. * @param options The required width/height ratio to downsize to before computing the render pass.
  64387. * @param camera The camera to apply the render pass to.
  64388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64389. * @param engine The engine which the post process will be applied. (default: current engine)
  64390. * @param reusable If the post process can be reused on the same frame. (default: false)
  64391. */
  64392. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64393. }
  64394. }
  64395. declare module BABYLON {
  64396. /** @hidden */
  64397. export var filterPixelShader: {
  64398. name: string;
  64399. shader: string;
  64400. };
  64401. }
  64402. declare module BABYLON {
  64403. /**
  64404. * Applies a kernel filter to the image
  64405. */
  64406. export class FilterPostProcess extends PostProcess {
  64407. /** The matrix to be applied to the image */
  64408. kernelMatrix: Matrix;
  64409. /**
  64410. *
  64411. * @param name The name of the effect.
  64412. * @param kernelMatrix The matrix to be applied to the image
  64413. * @param options The required width/height ratio to downsize to before computing the render pass.
  64414. * @param camera The camera to apply the render pass to.
  64415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64416. * @param engine The engine which the post process will be applied. (default: current engine)
  64417. * @param reusable If the post process can be reused on the same frame. (default: false)
  64418. */
  64419. constructor(name: string,
  64420. /** The matrix to be applied to the image */
  64421. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64422. }
  64423. }
  64424. declare module BABYLON {
  64425. /** @hidden */
  64426. export var fxaaPixelShader: {
  64427. name: string;
  64428. shader: string;
  64429. };
  64430. }
  64431. declare module BABYLON {
  64432. /** @hidden */
  64433. export var fxaaVertexShader: {
  64434. name: string;
  64435. shader: string;
  64436. };
  64437. }
  64438. declare module BABYLON {
  64439. /**
  64440. * Fxaa post process
  64441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64442. */
  64443. export class FxaaPostProcess extends PostProcess {
  64444. /** @hidden */
  64445. texelWidth: number;
  64446. /** @hidden */
  64447. texelHeight: number;
  64448. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64449. private _getDefines;
  64450. }
  64451. }
  64452. declare module BABYLON {
  64453. /** @hidden */
  64454. export var grainPixelShader: {
  64455. name: string;
  64456. shader: string;
  64457. };
  64458. }
  64459. declare module BABYLON {
  64460. /**
  64461. * The GrainPostProcess adds noise to the image at mid luminance levels
  64462. */
  64463. export class GrainPostProcess extends PostProcess {
  64464. /**
  64465. * The intensity of the grain added (default: 30)
  64466. */
  64467. intensity: number;
  64468. /**
  64469. * If the grain should be randomized on every frame
  64470. */
  64471. animated: boolean;
  64472. /**
  64473. * Creates a new instance of @see GrainPostProcess
  64474. * @param name The name of the effect.
  64475. * @param options The required width/height ratio to downsize to before computing the render pass.
  64476. * @param camera The camera to apply the render pass to.
  64477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64478. * @param engine The engine which the post process will be applied. (default: current engine)
  64479. * @param reusable If the post process can be reused on the same frame. (default: false)
  64480. * @param textureType Type of textures used when performing the post process. (default: 0)
  64481. * @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)
  64482. */
  64483. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64484. }
  64485. }
  64486. declare module BABYLON {
  64487. /** @hidden */
  64488. export var highlightsPixelShader: {
  64489. name: string;
  64490. shader: string;
  64491. };
  64492. }
  64493. declare module BABYLON {
  64494. /**
  64495. * Extracts highlights from the image
  64496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64497. */
  64498. export class HighlightsPostProcess extends PostProcess {
  64499. /**
  64500. * Extracts highlights from the image
  64501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64502. * @param name The name of the effect.
  64503. * @param options The required width/height ratio to downsize to before computing the render pass.
  64504. * @param camera The camera to apply the render pass to.
  64505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64506. * @param engine The engine which the post process will be applied. (default: current engine)
  64507. * @param reusable If the post process can be reused on the same frame. (default: false)
  64508. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64509. */
  64510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64511. }
  64512. }
  64513. declare module BABYLON {
  64514. /** @hidden */
  64515. export var mrtFragmentDeclaration: {
  64516. name: string;
  64517. shader: string;
  64518. };
  64519. }
  64520. declare module BABYLON {
  64521. /** @hidden */
  64522. export var geometryPixelShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module BABYLON {
  64528. /** @hidden */
  64529. export var geometryVertexShader: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module BABYLON {
  64535. /** @hidden */
  64536. interface ISavedTransformationMatrix {
  64537. world: Matrix;
  64538. viewProjection: Matrix;
  64539. }
  64540. /**
  64541. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64542. */
  64543. export class GeometryBufferRenderer {
  64544. /**
  64545. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64546. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64547. */
  64548. static readonly POSITION_TEXTURE_TYPE: number;
  64549. /**
  64550. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64551. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64552. */
  64553. static readonly VELOCITY_TEXTURE_TYPE: number;
  64554. /**
  64555. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64556. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64557. */
  64558. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64559. /**
  64560. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64561. * in order to compute objects velocities when enableVelocity is set to "true"
  64562. * @hidden
  64563. */
  64564. _previousTransformationMatrices: {
  64565. [index: number]: ISavedTransformationMatrix;
  64566. };
  64567. /**
  64568. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64569. * in order to compute objects velocities when enableVelocity is set to "true"
  64570. * @hidden
  64571. */
  64572. _previousBonesTransformationMatrices: {
  64573. [index: number]: Float32Array;
  64574. };
  64575. /**
  64576. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64577. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64578. */
  64579. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64580. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64581. renderTransparentMeshes: boolean;
  64582. private _scene;
  64583. private _multiRenderTarget;
  64584. private _ratio;
  64585. private _enablePosition;
  64586. private _enableVelocity;
  64587. private _enableReflectivity;
  64588. private _positionIndex;
  64589. private _velocityIndex;
  64590. private _reflectivityIndex;
  64591. protected _effect: Effect;
  64592. protected _cachedDefines: string;
  64593. /**
  64594. * Set the render list (meshes to be rendered) used in the G buffer.
  64595. */
  64596. set renderList(meshes: Mesh[]);
  64597. /**
  64598. * Gets wether or not G buffer are supported by the running hardware.
  64599. * This requires draw buffer supports
  64600. */
  64601. get isSupported(): boolean;
  64602. /**
  64603. * Returns the index of the given texture type in the G-Buffer textures array
  64604. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64605. * @returns the index of the given texture type in the G-Buffer textures array
  64606. */
  64607. getTextureIndex(textureType: number): number;
  64608. /**
  64609. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64610. */
  64611. get enablePosition(): boolean;
  64612. /**
  64613. * Sets whether or not objects positions are enabled for the G buffer.
  64614. */
  64615. set enablePosition(enable: boolean);
  64616. /**
  64617. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64618. */
  64619. get enableVelocity(): boolean;
  64620. /**
  64621. * Sets wether or not objects velocities are enabled for the G buffer.
  64622. */
  64623. set enableVelocity(enable: boolean);
  64624. /**
  64625. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64626. */
  64627. get enableReflectivity(): boolean;
  64628. /**
  64629. * Sets wether or not objects roughness are enabled for the G buffer.
  64630. */
  64631. set enableReflectivity(enable: boolean);
  64632. /**
  64633. * Gets the scene associated with the buffer.
  64634. */
  64635. get scene(): Scene;
  64636. /**
  64637. * Gets the ratio used by the buffer during its creation.
  64638. * How big is the buffer related to the main canvas.
  64639. */
  64640. get ratio(): number;
  64641. /** @hidden */
  64642. static _SceneComponentInitialization: (scene: Scene) => void;
  64643. /**
  64644. * Creates a new G Buffer for the scene
  64645. * @param scene The scene the buffer belongs to
  64646. * @param ratio How big is the buffer related to the main canvas.
  64647. */
  64648. constructor(scene: Scene, ratio?: number);
  64649. /**
  64650. * Checks wether everything is ready to render a submesh to the G buffer.
  64651. * @param subMesh the submesh to check readiness for
  64652. * @param useInstances is the mesh drawn using instance or not
  64653. * @returns true if ready otherwise false
  64654. */
  64655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64656. /**
  64657. * Gets the current underlying G Buffer.
  64658. * @returns the buffer
  64659. */
  64660. getGBuffer(): MultiRenderTarget;
  64661. /**
  64662. * Gets the number of samples used to render the buffer (anti aliasing).
  64663. */
  64664. get samples(): number;
  64665. /**
  64666. * Sets the number of samples used to render the buffer (anti aliasing).
  64667. */
  64668. set samples(value: number);
  64669. /**
  64670. * Disposes the renderer and frees up associated resources.
  64671. */
  64672. dispose(): void;
  64673. protected _createRenderTargets(): void;
  64674. private _copyBonesTransformationMatrices;
  64675. }
  64676. }
  64677. declare module BABYLON {
  64678. interface Scene {
  64679. /** @hidden (Backing field) */
  64680. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64681. /**
  64682. * Gets or Sets the current geometry buffer associated to the scene.
  64683. */
  64684. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64685. /**
  64686. * Enables a GeometryBufferRender and associates it with the scene
  64687. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64688. * @returns the GeometryBufferRenderer
  64689. */
  64690. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64691. /**
  64692. * Disables the GeometryBufferRender associated with the scene
  64693. */
  64694. disableGeometryBufferRenderer(): void;
  64695. }
  64696. /**
  64697. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64698. * in several rendering techniques.
  64699. */
  64700. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64701. /**
  64702. * The component name helpful to identify the component in the list of scene components.
  64703. */
  64704. readonly name: string;
  64705. /**
  64706. * The scene the component belongs to.
  64707. */
  64708. scene: Scene;
  64709. /**
  64710. * Creates a new instance of the component for the given scene
  64711. * @param scene Defines the scene to register the component in
  64712. */
  64713. constructor(scene: Scene);
  64714. /**
  64715. * Registers the component in a given scene
  64716. */
  64717. register(): void;
  64718. /**
  64719. * Rebuilds the elements related to this component in case of
  64720. * context lost for instance.
  64721. */
  64722. rebuild(): void;
  64723. /**
  64724. * Disposes the component and the associated ressources
  64725. */
  64726. dispose(): void;
  64727. private _gatherRenderTargets;
  64728. }
  64729. }
  64730. declare module BABYLON {
  64731. /** @hidden */
  64732. export var motionBlurPixelShader: {
  64733. name: string;
  64734. shader: string;
  64735. };
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64740. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64741. * As an example, all you have to do is to create the post-process:
  64742. * var mb = new BABYLON.MotionBlurPostProcess(
  64743. * 'mb', // The name of the effect.
  64744. * scene, // The scene containing the objects to blur according to their velocity.
  64745. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64746. * camera // The camera to apply the render pass to.
  64747. * );
  64748. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64749. */
  64750. export class MotionBlurPostProcess extends PostProcess {
  64751. /**
  64752. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64753. */
  64754. motionStrength: number;
  64755. /**
  64756. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64757. */
  64758. get motionBlurSamples(): number;
  64759. /**
  64760. * Sets the number of iterations to be used for motion blur quality
  64761. */
  64762. set motionBlurSamples(samples: number);
  64763. private _motionBlurSamples;
  64764. private _geometryBufferRenderer;
  64765. /**
  64766. * Creates a new instance MotionBlurPostProcess
  64767. * @param name The name of the effect.
  64768. * @param scene The scene containing the objects to blur according to their velocity.
  64769. * @param options The required width/height ratio to downsize to before computing the render pass.
  64770. * @param camera The camera to apply the render pass to.
  64771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64772. * @param engine The engine which the post process will be applied. (default: current engine)
  64773. * @param reusable If the post process can be reused on the same frame. (default: false)
  64774. * @param textureType Type of textures used when performing the post process. (default: 0)
  64775. * @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)
  64776. */
  64777. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64778. /**
  64779. * Excludes the given skinned mesh from computing bones velocities.
  64780. * 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.
  64781. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64782. */
  64783. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64784. /**
  64785. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64786. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64787. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64788. */
  64789. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64790. /**
  64791. * Disposes the post process.
  64792. * @param camera The camera to dispose the post process on.
  64793. */
  64794. dispose(camera?: Camera): void;
  64795. }
  64796. }
  64797. declare module BABYLON {
  64798. /** @hidden */
  64799. export var refractionPixelShader: {
  64800. name: string;
  64801. shader: string;
  64802. };
  64803. }
  64804. declare module BABYLON {
  64805. /**
  64806. * Post process which applies a refractin texture
  64807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64808. */
  64809. export class RefractionPostProcess extends PostProcess {
  64810. /** the base color of the refraction (used to taint the rendering) */
  64811. color: Color3;
  64812. /** simulated refraction depth */
  64813. depth: number;
  64814. /** the coefficient of the base color (0 to remove base color tainting) */
  64815. colorLevel: number;
  64816. private _refTexture;
  64817. private _ownRefractionTexture;
  64818. /**
  64819. * Gets or sets the refraction texture
  64820. * Please note that you are responsible for disposing the texture if you set it manually
  64821. */
  64822. get refractionTexture(): Texture;
  64823. set refractionTexture(value: Texture);
  64824. /**
  64825. * Initializes the RefractionPostProcess
  64826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64827. * @param name The name of the effect.
  64828. * @param refractionTextureUrl Url of the refraction texture to use
  64829. * @param color the base color of the refraction (used to taint the rendering)
  64830. * @param depth simulated refraction depth
  64831. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64832. * @param camera The camera to apply the render pass to.
  64833. * @param options The required width/height ratio to downsize to before computing the render pass.
  64834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64835. * @param engine The engine which the post process will be applied. (default: current engine)
  64836. * @param reusable If the post process can be reused on the same frame. (default: false)
  64837. */
  64838. constructor(name: string, refractionTextureUrl: string,
  64839. /** the base color of the refraction (used to taint the rendering) */
  64840. color: Color3,
  64841. /** simulated refraction depth */
  64842. depth: number,
  64843. /** the coefficient of the base color (0 to remove base color tainting) */
  64844. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64845. /**
  64846. * Disposes of the post process
  64847. * @param camera Camera to dispose post process on
  64848. */
  64849. dispose(camera: Camera): void;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /** @hidden */
  64854. export var sharpenPixelShader: {
  64855. name: string;
  64856. shader: string;
  64857. };
  64858. }
  64859. declare module BABYLON {
  64860. /**
  64861. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64862. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64863. */
  64864. export class SharpenPostProcess extends PostProcess {
  64865. /**
  64866. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64867. */
  64868. colorAmount: number;
  64869. /**
  64870. * How much sharpness should be applied (default: 0.3)
  64871. */
  64872. edgeAmount: number;
  64873. /**
  64874. * Creates a new instance ConvolutionPostProcess
  64875. * @param name The name of the effect.
  64876. * @param options The required width/height ratio to downsize to before computing the render pass.
  64877. * @param camera The camera to apply the render pass to.
  64878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64879. * @param engine The engine which the post process will be applied. (default: current engine)
  64880. * @param reusable If the post process can be reused on the same frame. (default: false)
  64881. * @param textureType Type of textures used when performing the post process. (default: 0)
  64882. * @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)
  64883. */
  64884. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64885. }
  64886. }
  64887. declare module BABYLON {
  64888. /**
  64889. * PostProcessRenderPipeline
  64890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64891. */
  64892. export class PostProcessRenderPipeline {
  64893. private engine;
  64894. private _renderEffects;
  64895. private _renderEffectsForIsolatedPass;
  64896. /**
  64897. * List of inspectable custom properties (used by the Inspector)
  64898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64899. */
  64900. inspectableCustomProperties: IInspectable[];
  64901. /**
  64902. * @hidden
  64903. */
  64904. protected _cameras: Camera[];
  64905. /** @hidden */
  64906. _name: string;
  64907. /**
  64908. * Gets pipeline name
  64909. */
  64910. get name(): string;
  64911. /** Gets the list of attached cameras */
  64912. get cameras(): Camera[];
  64913. /**
  64914. * Initializes a PostProcessRenderPipeline
  64915. * @param engine engine to add the pipeline to
  64916. * @param name name of the pipeline
  64917. */
  64918. constructor(engine: Engine, name: string);
  64919. /**
  64920. * Gets the class name
  64921. * @returns "PostProcessRenderPipeline"
  64922. */
  64923. getClassName(): string;
  64924. /**
  64925. * If all the render effects in the pipeline are supported
  64926. */
  64927. get isSupported(): boolean;
  64928. /**
  64929. * Adds an effect to the pipeline
  64930. * @param renderEffect the effect to add
  64931. */
  64932. addEffect(renderEffect: PostProcessRenderEffect): void;
  64933. /** @hidden */
  64934. _rebuild(): void;
  64935. /** @hidden */
  64936. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64937. /** @hidden */
  64938. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64939. /** @hidden */
  64940. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64941. /** @hidden */
  64942. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64943. /** @hidden */
  64944. _attachCameras(cameras: Camera, unique: boolean): void;
  64945. /** @hidden */
  64946. _attachCameras(cameras: Camera[], unique: boolean): void;
  64947. /** @hidden */
  64948. _detachCameras(cameras: Camera): void;
  64949. /** @hidden */
  64950. _detachCameras(cameras: Nullable<Camera[]>): void;
  64951. /** @hidden */
  64952. _update(): void;
  64953. /** @hidden */
  64954. _reset(): void;
  64955. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64956. /**
  64957. * Disposes of the pipeline
  64958. */
  64959. dispose(): void;
  64960. }
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * PostProcessRenderPipelineManager class
  64965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64966. */
  64967. export class PostProcessRenderPipelineManager {
  64968. private _renderPipelines;
  64969. /**
  64970. * Initializes a PostProcessRenderPipelineManager
  64971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64972. */
  64973. constructor();
  64974. /**
  64975. * Gets the list of supported render pipelines
  64976. */
  64977. get supportedPipelines(): PostProcessRenderPipeline[];
  64978. /**
  64979. * Adds a pipeline to the manager
  64980. * @param renderPipeline The pipeline to add
  64981. */
  64982. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64983. /**
  64984. * Attaches a camera to the pipeline
  64985. * @param renderPipelineName The name of the pipeline to attach to
  64986. * @param cameras the camera to attach
  64987. * @param unique if the camera can be attached multiple times to the pipeline
  64988. */
  64989. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64990. /**
  64991. * Detaches a camera from the pipeline
  64992. * @param renderPipelineName The name of the pipeline to detach from
  64993. * @param cameras the camera to detach
  64994. */
  64995. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64996. /**
  64997. * Enables an effect by name on a pipeline
  64998. * @param renderPipelineName the name of the pipeline to enable the effect in
  64999. * @param renderEffectName the name of the effect to enable
  65000. * @param cameras the cameras that the effect should be enabled on
  65001. */
  65002. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65003. /**
  65004. * Disables an effect by name on a pipeline
  65005. * @param renderPipelineName the name of the pipeline to disable the effect in
  65006. * @param renderEffectName the name of the effect to disable
  65007. * @param cameras the cameras that the effect should be disabled on
  65008. */
  65009. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65010. /**
  65011. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65012. */
  65013. update(): void;
  65014. /** @hidden */
  65015. _rebuild(): void;
  65016. /**
  65017. * Disposes of the manager and pipelines
  65018. */
  65019. dispose(): void;
  65020. }
  65021. }
  65022. declare module BABYLON {
  65023. interface Scene {
  65024. /** @hidden (Backing field) */
  65025. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65026. /**
  65027. * Gets the postprocess render pipeline manager
  65028. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65029. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65030. */
  65031. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65032. }
  65033. /**
  65034. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65035. */
  65036. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65037. /**
  65038. * The component name helpfull to identify the component in the list of scene components.
  65039. */
  65040. readonly name: string;
  65041. /**
  65042. * The scene the component belongs to.
  65043. */
  65044. scene: Scene;
  65045. /**
  65046. * Creates a new instance of the component for the given scene
  65047. * @param scene Defines the scene to register the component in
  65048. */
  65049. constructor(scene: Scene);
  65050. /**
  65051. * Registers the component in a given scene
  65052. */
  65053. register(): void;
  65054. /**
  65055. * Rebuilds the elements related to this component in case of
  65056. * context lost for instance.
  65057. */
  65058. rebuild(): void;
  65059. /**
  65060. * Disposes the component and the associated ressources
  65061. */
  65062. dispose(): void;
  65063. private _gatherRenderTargets;
  65064. }
  65065. }
  65066. declare module BABYLON {
  65067. /**
  65068. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65069. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65070. */
  65071. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65072. private _scene;
  65073. private _camerasToBeAttached;
  65074. /**
  65075. * ID of the sharpen post process,
  65076. */
  65077. private readonly SharpenPostProcessId;
  65078. /**
  65079. * @ignore
  65080. * ID of the image processing post process;
  65081. */
  65082. readonly ImageProcessingPostProcessId: string;
  65083. /**
  65084. * @ignore
  65085. * ID of the Fast Approximate Anti-Aliasing post process;
  65086. */
  65087. readonly FxaaPostProcessId: string;
  65088. /**
  65089. * ID of the chromatic aberration post process,
  65090. */
  65091. private readonly ChromaticAberrationPostProcessId;
  65092. /**
  65093. * ID of the grain post process
  65094. */
  65095. private readonly GrainPostProcessId;
  65096. /**
  65097. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65098. */
  65099. sharpen: SharpenPostProcess;
  65100. private _sharpenEffect;
  65101. private bloom;
  65102. /**
  65103. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65104. */
  65105. depthOfField: DepthOfFieldEffect;
  65106. /**
  65107. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65108. */
  65109. fxaa: FxaaPostProcess;
  65110. /**
  65111. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65112. */
  65113. imageProcessing: ImageProcessingPostProcess;
  65114. /**
  65115. * Chromatic aberration post process which will shift rgb colors in the image
  65116. */
  65117. chromaticAberration: ChromaticAberrationPostProcess;
  65118. private _chromaticAberrationEffect;
  65119. /**
  65120. * Grain post process which add noise to the image
  65121. */
  65122. grain: GrainPostProcess;
  65123. private _grainEffect;
  65124. /**
  65125. * Glow post process which adds a glow to emissive areas of the image
  65126. */
  65127. private _glowLayer;
  65128. /**
  65129. * Animations which can be used to tweak settings over a period of time
  65130. */
  65131. animations: Animation[];
  65132. private _imageProcessingConfigurationObserver;
  65133. private _sharpenEnabled;
  65134. private _bloomEnabled;
  65135. private _depthOfFieldEnabled;
  65136. private _depthOfFieldBlurLevel;
  65137. private _fxaaEnabled;
  65138. private _imageProcessingEnabled;
  65139. private _defaultPipelineTextureType;
  65140. private _bloomScale;
  65141. private _chromaticAberrationEnabled;
  65142. private _grainEnabled;
  65143. private _buildAllowed;
  65144. /**
  65145. * Gets active scene
  65146. */
  65147. get scene(): Scene;
  65148. /**
  65149. * Enable or disable the sharpen process from the pipeline
  65150. */
  65151. set sharpenEnabled(enabled: boolean);
  65152. get sharpenEnabled(): boolean;
  65153. private _resizeObserver;
  65154. private _hardwareScaleLevel;
  65155. private _bloomKernel;
  65156. /**
  65157. * Specifies the size of the bloom blur kernel, relative to the final output size
  65158. */
  65159. get bloomKernel(): number;
  65160. set bloomKernel(value: number);
  65161. /**
  65162. * Specifies the weight of the bloom in the final rendering
  65163. */
  65164. private _bloomWeight;
  65165. /**
  65166. * Specifies the luma threshold for the area that will be blurred by the bloom
  65167. */
  65168. private _bloomThreshold;
  65169. private _hdr;
  65170. /**
  65171. * The strength of the bloom.
  65172. */
  65173. set bloomWeight(value: number);
  65174. get bloomWeight(): number;
  65175. /**
  65176. * The strength of the bloom.
  65177. */
  65178. set bloomThreshold(value: number);
  65179. get bloomThreshold(): number;
  65180. /**
  65181. * The scale of the bloom, lower value will provide better performance.
  65182. */
  65183. set bloomScale(value: number);
  65184. get bloomScale(): number;
  65185. /**
  65186. * Enable or disable the bloom from the pipeline
  65187. */
  65188. set bloomEnabled(enabled: boolean);
  65189. get bloomEnabled(): boolean;
  65190. private _rebuildBloom;
  65191. /**
  65192. * If the depth of field is enabled.
  65193. */
  65194. get depthOfFieldEnabled(): boolean;
  65195. set depthOfFieldEnabled(enabled: boolean);
  65196. /**
  65197. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65198. */
  65199. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65200. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65201. /**
  65202. * If the anti aliasing is enabled.
  65203. */
  65204. set fxaaEnabled(enabled: boolean);
  65205. get fxaaEnabled(): boolean;
  65206. private _samples;
  65207. /**
  65208. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65209. */
  65210. set samples(sampleCount: number);
  65211. get samples(): number;
  65212. /**
  65213. * If image processing is enabled.
  65214. */
  65215. set imageProcessingEnabled(enabled: boolean);
  65216. get imageProcessingEnabled(): boolean;
  65217. /**
  65218. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65219. */
  65220. set glowLayerEnabled(enabled: boolean);
  65221. get glowLayerEnabled(): boolean;
  65222. /**
  65223. * Gets the glow layer (or null if not defined)
  65224. */
  65225. get glowLayer(): Nullable<GlowLayer>;
  65226. /**
  65227. * Enable or disable the chromaticAberration process from the pipeline
  65228. */
  65229. set chromaticAberrationEnabled(enabled: boolean);
  65230. get chromaticAberrationEnabled(): boolean;
  65231. /**
  65232. * Enable or disable the grain process from the pipeline
  65233. */
  65234. set grainEnabled(enabled: boolean);
  65235. get grainEnabled(): boolean;
  65236. /**
  65237. * @constructor
  65238. * @param name - The rendering pipeline name (default: "")
  65239. * @param hdr - If high dynamic range textures should be used (default: true)
  65240. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65241. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65242. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65243. */
  65244. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65245. /**
  65246. * Get the class name
  65247. * @returns "DefaultRenderingPipeline"
  65248. */
  65249. getClassName(): string;
  65250. /**
  65251. * Force the compilation of the entire pipeline.
  65252. */
  65253. prepare(): void;
  65254. private _hasCleared;
  65255. private _prevPostProcess;
  65256. private _prevPrevPostProcess;
  65257. private _setAutoClearAndTextureSharing;
  65258. private _depthOfFieldSceneObserver;
  65259. private _buildPipeline;
  65260. private _disposePostProcesses;
  65261. /**
  65262. * Adds a camera to the pipeline
  65263. * @param camera the camera to be added
  65264. */
  65265. addCamera(camera: Camera): void;
  65266. /**
  65267. * Removes a camera from the pipeline
  65268. * @param camera the camera to remove
  65269. */
  65270. removeCamera(camera: Camera): void;
  65271. /**
  65272. * Dispose of the pipeline and stop all post processes
  65273. */
  65274. dispose(): void;
  65275. /**
  65276. * Serialize the rendering pipeline (Used when exporting)
  65277. * @returns the serialized object
  65278. */
  65279. serialize(): any;
  65280. /**
  65281. * Parse the serialized pipeline
  65282. * @param source Source pipeline.
  65283. * @param scene The scene to load the pipeline to.
  65284. * @param rootUrl The URL of the serialized pipeline.
  65285. * @returns An instantiated pipeline from the serialized object.
  65286. */
  65287. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65288. }
  65289. }
  65290. declare module BABYLON {
  65291. /** @hidden */
  65292. export var lensHighlightsPixelShader: {
  65293. name: string;
  65294. shader: string;
  65295. };
  65296. }
  65297. declare module BABYLON {
  65298. /** @hidden */
  65299. export var depthOfFieldPixelShader: {
  65300. name: string;
  65301. shader: string;
  65302. };
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * BABYLON.JS Chromatic Aberration GLSL Shader
  65307. * Author: Olivier Guyot
  65308. * Separates very slightly R, G and B colors on the edges of the screen
  65309. * Inspired by Francois Tarlier & Martins Upitis
  65310. */
  65311. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65312. /**
  65313. * @ignore
  65314. * The chromatic aberration PostProcess id in the pipeline
  65315. */
  65316. LensChromaticAberrationEffect: string;
  65317. /**
  65318. * @ignore
  65319. * The highlights enhancing PostProcess id in the pipeline
  65320. */
  65321. HighlightsEnhancingEffect: string;
  65322. /**
  65323. * @ignore
  65324. * The depth-of-field PostProcess id in the pipeline
  65325. */
  65326. LensDepthOfFieldEffect: string;
  65327. private _scene;
  65328. private _depthTexture;
  65329. private _grainTexture;
  65330. private _chromaticAberrationPostProcess;
  65331. private _highlightsPostProcess;
  65332. private _depthOfFieldPostProcess;
  65333. private _edgeBlur;
  65334. private _grainAmount;
  65335. private _chromaticAberration;
  65336. private _distortion;
  65337. private _highlightsGain;
  65338. private _highlightsThreshold;
  65339. private _dofDistance;
  65340. private _dofAperture;
  65341. private _dofDarken;
  65342. private _dofPentagon;
  65343. private _blurNoise;
  65344. /**
  65345. * @constructor
  65346. *
  65347. * Effect parameters are as follow:
  65348. * {
  65349. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65350. * edge_blur: number; // from 0 to x (1 for realism)
  65351. * distortion: number; // from 0 to x (1 for realism)
  65352. * grain_amount: number; // from 0 to 1
  65353. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65354. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65355. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65356. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65357. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65358. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65359. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65360. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65361. * }
  65362. * Note: if an effect parameter is unset, effect is disabled
  65363. *
  65364. * @param name The rendering pipeline name
  65365. * @param parameters - An object containing all parameters (see above)
  65366. * @param scene The scene linked to this pipeline
  65367. * @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)
  65368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65369. */
  65370. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65371. /**
  65372. * Get the class name
  65373. * @returns "LensRenderingPipeline"
  65374. */
  65375. getClassName(): string;
  65376. /**
  65377. * Gets associated scene
  65378. */
  65379. get scene(): Scene;
  65380. /**
  65381. * Gets or sets the edge blur
  65382. */
  65383. get edgeBlur(): number;
  65384. set edgeBlur(value: number);
  65385. /**
  65386. * Gets or sets the grain amount
  65387. */
  65388. get grainAmount(): number;
  65389. set grainAmount(value: number);
  65390. /**
  65391. * Gets or sets the chromatic aberration amount
  65392. */
  65393. get chromaticAberration(): number;
  65394. set chromaticAberration(value: number);
  65395. /**
  65396. * Gets or sets the depth of field aperture
  65397. */
  65398. get dofAperture(): number;
  65399. set dofAperture(value: number);
  65400. /**
  65401. * Gets or sets the edge distortion
  65402. */
  65403. get edgeDistortion(): number;
  65404. set edgeDistortion(value: number);
  65405. /**
  65406. * Gets or sets the depth of field distortion
  65407. */
  65408. get dofDistortion(): number;
  65409. set dofDistortion(value: number);
  65410. /**
  65411. * Gets or sets the darken out of focus amount
  65412. */
  65413. get darkenOutOfFocus(): number;
  65414. set darkenOutOfFocus(value: number);
  65415. /**
  65416. * Gets or sets a boolean indicating if blur noise is enabled
  65417. */
  65418. get blurNoise(): boolean;
  65419. set blurNoise(value: boolean);
  65420. /**
  65421. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65422. */
  65423. get pentagonBokeh(): boolean;
  65424. set pentagonBokeh(value: boolean);
  65425. /**
  65426. * Gets or sets the highlight grain amount
  65427. */
  65428. get highlightsGain(): number;
  65429. set highlightsGain(value: number);
  65430. /**
  65431. * Gets or sets the highlight threshold
  65432. */
  65433. get highlightsThreshold(): number;
  65434. set highlightsThreshold(value: number);
  65435. /**
  65436. * Sets the amount of blur at the edges
  65437. * @param amount blur amount
  65438. */
  65439. setEdgeBlur(amount: number): void;
  65440. /**
  65441. * Sets edge blur to 0
  65442. */
  65443. disableEdgeBlur(): void;
  65444. /**
  65445. * Sets the amout of grain
  65446. * @param amount Amount of grain
  65447. */
  65448. setGrainAmount(amount: number): void;
  65449. /**
  65450. * Set grain amount to 0
  65451. */
  65452. disableGrain(): void;
  65453. /**
  65454. * Sets the chromatic aberration amount
  65455. * @param amount amount of chromatic aberration
  65456. */
  65457. setChromaticAberration(amount: number): void;
  65458. /**
  65459. * Sets chromatic aberration amount to 0
  65460. */
  65461. disableChromaticAberration(): void;
  65462. /**
  65463. * Sets the EdgeDistortion amount
  65464. * @param amount amount of EdgeDistortion
  65465. */
  65466. setEdgeDistortion(amount: number): void;
  65467. /**
  65468. * Sets edge distortion to 0
  65469. */
  65470. disableEdgeDistortion(): void;
  65471. /**
  65472. * Sets the FocusDistance amount
  65473. * @param amount amount of FocusDistance
  65474. */
  65475. setFocusDistance(amount: number): void;
  65476. /**
  65477. * Disables depth of field
  65478. */
  65479. disableDepthOfField(): void;
  65480. /**
  65481. * Sets the Aperture amount
  65482. * @param amount amount of Aperture
  65483. */
  65484. setAperture(amount: number): void;
  65485. /**
  65486. * Sets the DarkenOutOfFocus amount
  65487. * @param amount amount of DarkenOutOfFocus
  65488. */
  65489. setDarkenOutOfFocus(amount: number): void;
  65490. private _pentagonBokehIsEnabled;
  65491. /**
  65492. * Creates a pentagon bokeh effect
  65493. */
  65494. enablePentagonBokeh(): void;
  65495. /**
  65496. * Disables the pentagon bokeh effect
  65497. */
  65498. disablePentagonBokeh(): void;
  65499. /**
  65500. * Enables noise blur
  65501. */
  65502. enableNoiseBlur(): void;
  65503. /**
  65504. * Disables noise blur
  65505. */
  65506. disableNoiseBlur(): void;
  65507. /**
  65508. * Sets the HighlightsGain amount
  65509. * @param amount amount of HighlightsGain
  65510. */
  65511. setHighlightsGain(amount: number): void;
  65512. /**
  65513. * Sets the HighlightsThreshold amount
  65514. * @param amount amount of HighlightsThreshold
  65515. */
  65516. setHighlightsThreshold(amount: number): void;
  65517. /**
  65518. * Disables highlights
  65519. */
  65520. disableHighlights(): void;
  65521. /**
  65522. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65523. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65524. */
  65525. dispose(disableDepthRender?: boolean): void;
  65526. private _createChromaticAberrationPostProcess;
  65527. private _createHighlightsPostProcess;
  65528. private _createDepthOfFieldPostProcess;
  65529. private _createGrainTexture;
  65530. }
  65531. }
  65532. declare module BABYLON {
  65533. /** @hidden */
  65534. export var ssao2PixelShader: {
  65535. name: string;
  65536. shader: string;
  65537. };
  65538. }
  65539. declare module BABYLON {
  65540. /** @hidden */
  65541. export var ssaoCombinePixelShader: {
  65542. name: string;
  65543. shader: string;
  65544. };
  65545. }
  65546. declare module BABYLON {
  65547. /**
  65548. * Render pipeline to produce ssao effect
  65549. */
  65550. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65551. /**
  65552. * @ignore
  65553. * The PassPostProcess id in the pipeline that contains the original scene color
  65554. */
  65555. SSAOOriginalSceneColorEffect: string;
  65556. /**
  65557. * @ignore
  65558. * The SSAO PostProcess id in the pipeline
  65559. */
  65560. SSAORenderEffect: string;
  65561. /**
  65562. * @ignore
  65563. * The horizontal blur PostProcess id in the pipeline
  65564. */
  65565. SSAOBlurHRenderEffect: string;
  65566. /**
  65567. * @ignore
  65568. * The vertical blur PostProcess id in the pipeline
  65569. */
  65570. SSAOBlurVRenderEffect: string;
  65571. /**
  65572. * @ignore
  65573. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65574. */
  65575. SSAOCombineRenderEffect: string;
  65576. /**
  65577. * The output strength of the SSAO post-process. Default value is 1.0.
  65578. */
  65579. totalStrength: number;
  65580. /**
  65581. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65582. */
  65583. maxZ: number;
  65584. /**
  65585. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65586. */
  65587. minZAspect: number;
  65588. private _samples;
  65589. /**
  65590. * Number of samples used for the SSAO calculations. Default value is 8
  65591. */
  65592. set samples(n: number);
  65593. get samples(): number;
  65594. private _textureSamples;
  65595. /**
  65596. * Number of samples to use for antialiasing
  65597. */
  65598. set textureSamples(n: number);
  65599. get textureSamples(): number;
  65600. /**
  65601. * Ratio object used for SSAO ratio and blur ratio
  65602. */
  65603. private _ratio;
  65604. /**
  65605. * Dynamically generated sphere sampler.
  65606. */
  65607. private _sampleSphere;
  65608. /**
  65609. * Blur filter offsets
  65610. */
  65611. private _samplerOffsets;
  65612. private _expensiveBlur;
  65613. /**
  65614. * If bilateral blur should be used
  65615. */
  65616. set expensiveBlur(b: boolean);
  65617. get expensiveBlur(): boolean;
  65618. /**
  65619. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65620. */
  65621. radius: number;
  65622. /**
  65623. * The base color of the SSAO post-process
  65624. * The final result is "base + ssao" between [0, 1]
  65625. */
  65626. base: number;
  65627. /**
  65628. * Support test.
  65629. */
  65630. static get IsSupported(): boolean;
  65631. private _scene;
  65632. private _depthTexture;
  65633. private _normalTexture;
  65634. private _randomTexture;
  65635. private _originalColorPostProcess;
  65636. private _ssaoPostProcess;
  65637. private _blurHPostProcess;
  65638. private _blurVPostProcess;
  65639. private _ssaoCombinePostProcess;
  65640. /**
  65641. * Gets active scene
  65642. */
  65643. get scene(): Scene;
  65644. /**
  65645. * @constructor
  65646. * @param name The rendering pipeline name
  65647. * @param scene The scene linked to this pipeline
  65648. * @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 }
  65649. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65650. */
  65651. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65652. /**
  65653. * Get the class name
  65654. * @returns "SSAO2RenderingPipeline"
  65655. */
  65656. getClassName(): string;
  65657. /**
  65658. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65659. */
  65660. dispose(disableGeometryBufferRenderer?: boolean): void;
  65661. private _createBlurPostProcess;
  65662. /** @hidden */
  65663. _rebuild(): void;
  65664. private _bits;
  65665. private _radicalInverse_VdC;
  65666. private _hammersley;
  65667. private _hemisphereSample_uniform;
  65668. private _generateHemisphere;
  65669. private _createSSAOPostProcess;
  65670. private _createSSAOCombinePostProcess;
  65671. private _createRandomTexture;
  65672. /**
  65673. * Serialize the rendering pipeline (Used when exporting)
  65674. * @returns the serialized object
  65675. */
  65676. serialize(): any;
  65677. /**
  65678. * Parse the serialized pipeline
  65679. * @param source Source pipeline.
  65680. * @param scene The scene to load the pipeline to.
  65681. * @param rootUrl The URL of the serialized pipeline.
  65682. * @returns An instantiated pipeline from the serialized object.
  65683. */
  65684. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65685. }
  65686. }
  65687. declare module BABYLON {
  65688. /** @hidden */
  65689. export var ssaoPixelShader: {
  65690. name: string;
  65691. shader: string;
  65692. };
  65693. }
  65694. declare module BABYLON {
  65695. /**
  65696. * Render pipeline to produce ssao effect
  65697. */
  65698. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65699. /**
  65700. * @ignore
  65701. * The PassPostProcess id in the pipeline that contains the original scene color
  65702. */
  65703. SSAOOriginalSceneColorEffect: string;
  65704. /**
  65705. * @ignore
  65706. * The SSAO PostProcess id in the pipeline
  65707. */
  65708. SSAORenderEffect: string;
  65709. /**
  65710. * @ignore
  65711. * The horizontal blur PostProcess id in the pipeline
  65712. */
  65713. SSAOBlurHRenderEffect: string;
  65714. /**
  65715. * @ignore
  65716. * The vertical blur PostProcess id in the pipeline
  65717. */
  65718. SSAOBlurVRenderEffect: string;
  65719. /**
  65720. * @ignore
  65721. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65722. */
  65723. SSAOCombineRenderEffect: string;
  65724. /**
  65725. * The output strength of the SSAO post-process. Default value is 1.0.
  65726. */
  65727. totalStrength: number;
  65728. /**
  65729. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65730. */
  65731. radius: number;
  65732. /**
  65733. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65734. * Must not be equal to fallOff and superior to fallOff.
  65735. * Default value is 0.0075
  65736. */
  65737. area: number;
  65738. /**
  65739. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65740. * Must not be equal to area and inferior to area.
  65741. * Default value is 0.000001
  65742. */
  65743. fallOff: number;
  65744. /**
  65745. * The base color of the SSAO post-process
  65746. * The final result is "base + ssao" between [0, 1]
  65747. */
  65748. base: number;
  65749. private _scene;
  65750. private _depthTexture;
  65751. private _randomTexture;
  65752. private _originalColorPostProcess;
  65753. private _ssaoPostProcess;
  65754. private _blurHPostProcess;
  65755. private _blurVPostProcess;
  65756. private _ssaoCombinePostProcess;
  65757. private _firstUpdate;
  65758. /**
  65759. * Gets active scene
  65760. */
  65761. get scene(): Scene;
  65762. /**
  65763. * @constructor
  65764. * @param name - The rendering pipeline name
  65765. * @param scene - The scene linked to this pipeline
  65766. * @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 }
  65767. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65768. */
  65769. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65770. /**
  65771. * Get the class name
  65772. * @returns "SSAORenderingPipeline"
  65773. */
  65774. getClassName(): string;
  65775. /**
  65776. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65777. */
  65778. dispose(disableDepthRender?: boolean): void;
  65779. private _createBlurPostProcess;
  65780. /** @hidden */
  65781. _rebuild(): void;
  65782. private _createSSAOPostProcess;
  65783. private _createSSAOCombinePostProcess;
  65784. private _createRandomTexture;
  65785. }
  65786. }
  65787. declare module BABYLON {
  65788. /** @hidden */
  65789. export var screenSpaceReflectionPixelShader: {
  65790. name: string;
  65791. shader: string;
  65792. };
  65793. }
  65794. declare module BABYLON {
  65795. /**
  65796. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65797. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65798. */
  65799. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65800. /**
  65801. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65802. */
  65803. threshold: number;
  65804. /**
  65805. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65806. */
  65807. strength: number;
  65808. /**
  65809. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65810. */
  65811. reflectionSpecularFalloffExponent: number;
  65812. /**
  65813. * 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]
  65814. */
  65815. step: number;
  65816. /**
  65817. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65818. */
  65819. roughnessFactor: number;
  65820. private _geometryBufferRenderer;
  65821. private _enableSmoothReflections;
  65822. private _reflectionSamples;
  65823. private _smoothSteps;
  65824. /**
  65825. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65826. * @param name The name of the effect.
  65827. * @param scene The scene containing the objects to calculate reflections.
  65828. * @param options The required width/height ratio to downsize to before computing the render pass.
  65829. * @param camera The camera to apply the render pass to.
  65830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65831. * @param engine The engine which the post process will be applied. (default: current engine)
  65832. * @param reusable If the post process can be reused on the same frame. (default: false)
  65833. * @param textureType Type of textures used when performing the post process. (default: 0)
  65834. * @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)
  65835. */
  65836. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65837. /**
  65838. * Gets wether or not smoothing reflections is enabled.
  65839. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65840. */
  65841. get enableSmoothReflections(): boolean;
  65842. /**
  65843. * Sets wether or not smoothing reflections is enabled.
  65844. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65845. */
  65846. set enableSmoothReflections(enabled: boolean);
  65847. /**
  65848. * Gets the number of samples taken while computing reflections. More samples count is high,
  65849. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65850. */
  65851. get reflectionSamples(): number;
  65852. /**
  65853. * Sets the number of samples taken while computing reflections. More samples count is high,
  65854. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65855. */
  65856. set reflectionSamples(samples: number);
  65857. /**
  65858. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65859. * more the post-process will require GPU power and can generate a drop in FPS.
  65860. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65861. */
  65862. get smoothSteps(): number;
  65863. set smoothSteps(steps: number);
  65864. private _updateEffectDefines;
  65865. }
  65866. }
  65867. declare module BABYLON {
  65868. /** @hidden */
  65869. export var standardPixelShader: {
  65870. name: string;
  65871. shader: string;
  65872. };
  65873. }
  65874. declare module BABYLON {
  65875. /**
  65876. * Standard rendering pipeline
  65877. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65878. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65879. */
  65880. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65881. /**
  65882. * Public members
  65883. */
  65884. /**
  65885. * Post-process which contains the original scene color before the pipeline applies all the effects
  65886. */
  65887. originalPostProcess: Nullable<PostProcess>;
  65888. /**
  65889. * Post-process used to down scale an image x4
  65890. */
  65891. downSampleX4PostProcess: Nullable<PostProcess>;
  65892. /**
  65893. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65894. */
  65895. brightPassPostProcess: Nullable<PostProcess>;
  65896. /**
  65897. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65898. */
  65899. blurHPostProcesses: PostProcess[];
  65900. /**
  65901. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65902. */
  65903. blurVPostProcesses: PostProcess[];
  65904. /**
  65905. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65906. */
  65907. textureAdderPostProcess: Nullable<PostProcess>;
  65908. /**
  65909. * Post-process used to create volumetric lighting effect
  65910. */
  65911. volumetricLightPostProcess: Nullable<PostProcess>;
  65912. /**
  65913. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65914. */
  65915. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65916. /**
  65917. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65918. */
  65919. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65920. /**
  65921. * Post-process used to merge the volumetric light effect and the real scene color
  65922. */
  65923. volumetricLightMergePostProces: Nullable<PostProcess>;
  65924. /**
  65925. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65926. */
  65927. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65928. /**
  65929. * Base post-process used to calculate the average luminance of the final image for HDR
  65930. */
  65931. luminancePostProcess: Nullable<PostProcess>;
  65932. /**
  65933. * Post-processes used to create down sample post-processes in order to get
  65934. * the average luminance of the final image for HDR
  65935. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65936. */
  65937. luminanceDownSamplePostProcesses: PostProcess[];
  65938. /**
  65939. * Post-process used to create a HDR effect (light adaptation)
  65940. */
  65941. hdrPostProcess: Nullable<PostProcess>;
  65942. /**
  65943. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65944. */
  65945. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65946. /**
  65947. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65948. */
  65949. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65950. /**
  65951. * Post-process used to merge the final HDR post-process and the real scene color
  65952. */
  65953. hdrFinalPostProcess: Nullable<PostProcess>;
  65954. /**
  65955. * Post-process used to create a lens flare effect
  65956. */
  65957. lensFlarePostProcess: Nullable<PostProcess>;
  65958. /**
  65959. * Post-process that merges the result of the lens flare post-process and the real scene color
  65960. */
  65961. lensFlareComposePostProcess: Nullable<PostProcess>;
  65962. /**
  65963. * Post-process used to create a motion blur effect
  65964. */
  65965. motionBlurPostProcess: Nullable<PostProcess>;
  65966. /**
  65967. * Post-process used to create a depth of field effect
  65968. */
  65969. depthOfFieldPostProcess: Nullable<PostProcess>;
  65970. /**
  65971. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65972. */
  65973. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65974. /**
  65975. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65976. */
  65977. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65978. /**
  65979. * Represents the brightness threshold in order to configure the illuminated surfaces
  65980. */
  65981. brightThreshold: number;
  65982. /**
  65983. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65984. */
  65985. blurWidth: number;
  65986. /**
  65987. * Sets if the blur for highlighted surfaces must be only horizontal
  65988. */
  65989. horizontalBlur: boolean;
  65990. /**
  65991. * Gets the overall exposure used by the pipeline
  65992. */
  65993. get exposure(): number;
  65994. /**
  65995. * Sets the overall exposure used by the pipeline
  65996. */
  65997. set exposure(value: number);
  65998. /**
  65999. * Texture used typically to simulate "dirty" on camera lens
  66000. */
  66001. lensTexture: Nullable<Texture>;
  66002. /**
  66003. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66004. */
  66005. volumetricLightCoefficient: number;
  66006. /**
  66007. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66008. */
  66009. volumetricLightPower: number;
  66010. /**
  66011. * Used the set the blur intensity to smooth the volumetric lights
  66012. */
  66013. volumetricLightBlurScale: number;
  66014. /**
  66015. * Light (spot or directional) used to generate the volumetric lights rays
  66016. * The source light must have a shadow generate so the pipeline can get its
  66017. * depth map
  66018. */
  66019. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66020. /**
  66021. * For eye adaptation, represents the minimum luminance the eye can see
  66022. */
  66023. hdrMinimumLuminance: number;
  66024. /**
  66025. * For eye adaptation, represents the decrease luminance speed
  66026. */
  66027. hdrDecreaseRate: number;
  66028. /**
  66029. * For eye adaptation, represents the increase luminance speed
  66030. */
  66031. hdrIncreaseRate: number;
  66032. /**
  66033. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66034. */
  66035. get hdrAutoExposure(): boolean;
  66036. /**
  66037. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66038. */
  66039. set hdrAutoExposure(value: boolean);
  66040. /**
  66041. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66042. */
  66043. lensColorTexture: Nullable<Texture>;
  66044. /**
  66045. * The overall strengh for the lens flare effect
  66046. */
  66047. lensFlareStrength: number;
  66048. /**
  66049. * Dispersion coefficient for lens flare ghosts
  66050. */
  66051. lensFlareGhostDispersal: number;
  66052. /**
  66053. * Main lens flare halo width
  66054. */
  66055. lensFlareHaloWidth: number;
  66056. /**
  66057. * Based on the lens distortion effect, defines how much the lens flare result
  66058. * is distorted
  66059. */
  66060. lensFlareDistortionStrength: number;
  66061. /**
  66062. * Configures the blur intensity used for for lens flare (halo)
  66063. */
  66064. lensFlareBlurWidth: number;
  66065. /**
  66066. * Lens star texture must be used to simulate rays on the flares and is available
  66067. * in the documentation
  66068. */
  66069. lensStarTexture: Nullable<Texture>;
  66070. /**
  66071. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66072. * flare effect by taking account of the dirt texture
  66073. */
  66074. lensFlareDirtTexture: Nullable<Texture>;
  66075. /**
  66076. * Represents the focal length for the depth of field effect
  66077. */
  66078. depthOfFieldDistance: number;
  66079. /**
  66080. * Represents the blur intensity for the blurred part of the depth of field effect
  66081. */
  66082. depthOfFieldBlurWidth: number;
  66083. /**
  66084. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66085. */
  66086. get motionStrength(): number;
  66087. /**
  66088. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66089. */
  66090. set motionStrength(strength: number);
  66091. /**
  66092. * Gets wether or not the motion blur post-process is object based or screen based.
  66093. */
  66094. get objectBasedMotionBlur(): boolean;
  66095. /**
  66096. * Sets wether or not the motion blur post-process should be object based or screen based
  66097. */
  66098. set objectBasedMotionBlur(value: boolean);
  66099. /**
  66100. * List of animations for the pipeline (IAnimatable implementation)
  66101. */
  66102. animations: Animation[];
  66103. /**
  66104. * Private members
  66105. */
  66106. private _scene;
  66107. private _currentDepthOfFieldSource;
  66108. private _basePostProcess;
  66109. private _fixedExposure;
  66110. private _currentExposure;
  66111. private _hdrAutoExposure;
  66112. private _hdrCurrentLuminance;
  66113. private _motionStrength;
  66114. private _isObjectBasedMotionBlur;
  66115. private _floatTextureType;
  66116. private _camerasToBeAttached;
  66117. private _ratio;
  66118. private _bloomEnabled;
  66119. private _depthOfFieldEnabled;
  66120. private _vlsEnabled;
  66121. private _lensFlareEnabled;
  66122. private _hdrEnabled;
  66123. private _motionBlurEnabled;
  66124. private _fxaaEnabled;
  66125. private _screenSpaceReflectionsEnabled;
  66126. private _motionBlurSamples;
  66127. private _volumetricLightStepsCount;
  66128. private _samples;
  66129. /**
  66130. * @ignore
  66131. * Specifies if the bloom pipeline is enabled
  66132. */
  66133. get BloomEnabled(): boolean;
  66134. set BloomEnabled(enabled: boolean);
  66135. /**
  66136. * @ignore
  66137. * Specifies if the depth of field pipeline is enabed
  66138. */
  66139. get DepthOfFieldEnabled(): boolean;
  66140. set DepthOfFieldEnabled(enabled: boolean);
  66141. /**
  66142. * @ignore
  66143. * Specifies if the lens flare pipeline is enabed
  66144. */
  66145. get LensFlareEnabled(): boolean;
  66146. set LensFlareEnabled(enabled: boolean);
  66147. /**
  66148. * @ignore
  66149. * Specifies if the HDR pipeline is enabled
  66150. */
  66151. get HDREnabled(): boolean;
  66152. set HDREnabled(enabled: boolean);
  66153. /**
  66154. * @ignore
  66155. * Specifies if the volumetric lights scattering effect is enabled
  66156. */
  66157. get VLSEnabled(): boolean;
  66158. set VLSEnabled(enabled: boolean);
  66159. /**
  66160. * @ignore
  66161. * Specifies if the motion blur effect is enabled
  66162. */
  66163. get MotionBlurEnabled(): boolean;
  66164. set MotionBlurEnabled(enabled: boolean);
  66165. /**
  66166. * Specifies if anti-aliasing is enabled
  66167. */
  66168. get fxaaEnabled(): boolean;
  66169. set fxaaEnabled(enabled: boolean);
  66170. /**
  66171. * Specifies if screen space reflections are enabled.
  66172. */
  66173. get screenSpaceReflectionsEnabled(): boolean;
  66174. set screenSpaceReflectionsEnabled(enabled: boolean);
  66175. /**
  66176. * Specifies the number of steps used to calculate the volumetric lights
  66177. * Typically in interval [50, 200]
  66178. */
  66179. get volumetricLightStepsCount(): number;
  66180. set volumetricLightStepsCount(count: number);
  66181. /**
  66182. * Specifies the number of samples used for the motion blur effect
  66183. * Typically in interval [16, 64]
  66184. */
  66185. get motionBlurSamples(): number;
  66186. set motionBlurSamples(samples: number);
  66187. /**
  66188. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66189. */
  66190. get samples(): number;
  66191. set samples(sampleCount: number);
  66192. /**
  66193. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66194. * @constructor
  66195. * @param name The rendering pipeline name
  66196. * @param scene The scene linked to this pipeline
  66197. * @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)
  66198. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66199. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66200. */
  66201. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66202. private _buildPipeline;
  66203. private _createDownSampleX4PostProcess;
  66204. private _createBrightPassPostProcess;
  66205. private _createBlurPostProcesses;
  66206. private _createTextureAdderPostProcess;
  66207. private _createVolumetricLightPostProcess;
  66208. private _createLuminancePostProcesses;
  66209. private _createHdrPostProcess;
  66210. private _createLensFlarePostProcess;
  66211. private _createDepthOfFieldPostProcess;
  66212. private _createMotionBlurPostProcess;
  66213. private _getDepthTexture;
  66214. private _disposePostProcesses;
  66215. /**
  66216. * Dispose of the pipeline and stop all post processes
  66217. */
  66218. dispose(): void;
  66219. /**
  66220. * Serialize the rendering pipeline (Used when exporting)
  66221. * @returns the serialized object
  66222. */
  66223. serialize(): any;
  66224. /**
  66225. * Parse the serialized pipeline
  66226. * @param source Source pipeline.
  66227. * @param scene The scene to load the pipeline to.
  66228. * @param rootUrl The URL of the serialized pipeline.
  66229. * @returns An instantiated pipeline from the serialized object.
  66230. */
  66231. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66232. /**
  66233. * Luminance steps
  66234. */
  66235. static LuminanceSteps: number;
  66236. }
  66237. }
  66238. declare module BABYLON {
  66239. /** @hidden */
  66240. export var tonemapPixelShader: {
  66241. name: string;
  66242. shader: string;
  66243. };
  66244. }
  66245. declare module BABYLON {
  66246. /** Defines operator used for tonemapping */
  66247. export enum TonemappingOperator {
  66248. /** Hable */
  66249. Hable = 0,
  66250. /** Reinhard */
  66251. Reinhard = 1,
  66252. /** HejiDawson */
  66253. HejiDawson = 2,
  66254. /** Photographic */
  66255. Photographic = 3
  66256. }
  66257. /**
  66258. * Defines a post process to apply tone mapping
  66259. */
  66260. export class TonemapPostProcess extends PostProcess {
  66261. private _operator;
  66262. /** Defines the required exposure adjustement */
  66263. exposureAdjustment: number;
  66264. /**
  66265. * Creates a new TonemapPostProcess
  66266. * @param name defines the name of the postprocess
  66267. * @param _operator defines the operator to use
  66268. * @param exposureAdjustment defines the required exposure adjustement
  66269. * @param camera defines the camera to use (can be null)
  66270. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66271. * @param engine defines the hosting engine (can be ignore if camera is set)
  66272. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66273. */
  66274. constructor(name: string, _operator: TonemappingOperator,
  66275. /** Defines the required exposure adjustement */
  66276. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66277. }
  66278. }
  66279. declare module BABYLON {
  66280. /** @hidden */
  66281. export var volumetricLightScatteringPixelShader: {
  66282. name: string;
  66283. shader: string;
  66284. };
  66285. }
  66286. declare module BABYLON {
  66287. /** @hidden */
  66288. export var volumetricLightScatteringPassVertexShader: {
  66289. name: string;
  66290. shader: string;
  66291. };
  66292. }
  66293. declare module BABYLON {
  66294. /** @hidden */
  66295. export var volumetricLightScatteringPassPixelShader: {
  66296. name: string;
  66297. shader: string;
  66298. };
  66299. }
  66300. declare module BABYLON {
  66301. /**
  66302. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66303. */
  66304. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66305. private _volumetricLightScatteringPass;
  66306. private _volumetricLightScatteringRTT;
  66307. private _viewPort;
  66308. private _screenCoordinates;
  66309. private _cachedDefines;
  66310. /**
  66311. * If not undefined, the mesh position is computed from the attached node position
  66312. */
  66313. attachedNode: {
  66314. position: Vector3;
  66315. };
  66316. /**
  66317. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66318. */
  66319. customMeshPosition: Vector3;
  66320. /**
  66321. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66322. */
  66323. useCustomMeshPosition: boolean;
  66324. /**
  66325. * If the post-process should inverse the light scattering direction
  66326. */
  66327. invert: boolean;
  66328. /**
  66329. * The internal mesh used by the post-process
  66330. */
  66331. mesh: Mesh;
  66332. /**
  66333. * @hidden
  66334. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66335. */
  66336. get useDiffuseColor(): boolean;
  66337. set useDiffuseColor(useDiffuseColor: boolean);
  66338. /**
  66339. * Array containing the excluded meshes not rendered in the internal pass
  66340. */
  66341. excludedMeshes: AbstractMesh[];
  66342. /**
  66343. * Controls the overall intensity of the post-process
  66344. */
  66345. exposure: number;
  66346. /**
  66347. * Dissipates each sample's contribution in range [0, 1]
  66348. */
  66349. decay: number;
  66350. /**
  66351. * Controls the overall intensity of each sample
  66352. */
  66353. weight: number;
  66354. /**
  66355. * Controls the density of each sample
  66356. */
  66357. density: number;
  66358. /**
  66359. * @constructor
  66360. * @param name The post-process name
  66361. * @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)
  66362. * @param camera The camera that the post-process will be attached to
  66363. * @param mesh The mesh used to create the light scattering
  66364. * @param samples The post-process quality, default 100
  66365. * @param samplingModeThe post-process filtering mode
  66366. * @param engine The babylon engine
  66367. * @param reusable If the post-process is reusable
  66368. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66369. */
  66370. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66371. /**
  66372. * Returns the string "VolumetricLightScatteringPostProcess"
  66373. * @returns "VolumetricLightScatteringPostProcess"
  66374. */
  66375. getClassName(): string;
  66376. private _isReady;
  66377. /**
  66378. * Sets the new light position for light scattering effect
  66379. * @param position The new custom light position
  66380. */
  66381. setCustomMeshPosition(position: Vector3): void;
  66382. /**
  66383. * Returns the light position for light scattering effect
  66384. * @return Vector3 The custom light position
  66385. */
  66386. getCustomMeshPosition(): Vector3;
  66387. /**
  66388. * Disposes the internal assets and detaches the post-process from the camera
  66389. */
  66390. dispose(camera: Camera): void;
  66391. /**
  66392. * Returns the render target texture used by the post-process
  66393. * @return the render target texture used by the post-process
  66394. */
  66395. getPass(): RenderTargetTexture;
  66396. private _meshExcluded;
  66397. private _createPass;
  66398. private _updateMeshScreenCoordinates;
  66399. /**
  66400. * Creates a default mesh for the Volumeric Light Scattering post-process
  66401. * @param name The mesh name
  66402. * @param scene The scene where to create the mesh
  66403. * @return the default mesh
  66404. */
  66405. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66406. }
  66407. }
  66408. declare module BABYLON {
  66409. interface Scene {
  66410. /** @hidden (Backing field) */
  66411. _boundingBoxRenderer: BoundingBoxRenderer;
  66412. /** @hidden (Backing field) */
  66413. _forceShowBoundingBoxes: boolean;
  66414. /**
  66415. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66416. */
  66417. forceShowBoundingBoxes: boolean;
  66418. /**
  66419. * Gets the bounding box renderer associated with the scene
  66420. * @returns a BoundingBoxRenderer
  66421. */
  66422. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66423. }
  66424. interface AbstractMesh {
  66425. /** @hidden (Backing field) */
  66426. _showBoundingBox: boolean;
  66427. /**
  66428. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66429. */
  66430. showBoundingBox: boolean;
  66431. }
  66432. /**
  66433. * Component responsible of rendering the bounding box of the meshes in a scene.
  66434. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66435. */
  66436. export class BoundingBoxRenderer implements ISceneComponent {
  66437. /**
  66438. * The component name helpfull to identify the component in the list of scene components.
  66439. */
  66440. readonly name: string;
  66441. /**
  66442. * The scene the component belongs to.
  66443. */
  66444. scene: Scene;
  66445. /**
  66446. * Color of the bounding box lines placed in front of an object
  66447. */
  66448. frontColor: Color3;
  66449. /**
  66450. * Color of the bounding box lines placed behind an object
  66451. */
  66452. backColor: Color3;
  66453. /**
  66454. * Defines if the renderer should show the back lines or not
  66455. */
  66456. showBackLines: boolean;
  66457. /**
  66458. * @hidden
  66459. */
  66460. renderList: SmartArray<BoundingBox>;
  66461. private _colorShader;
  66462. private _vertexBuffers;
  66463. private _indexBuffer;
  66464. private _fillIndexBuffer;
  66465. private _fillIndexData;
  66466. /**
  66467. * Instantiates a new bounding box renderer in a scene.
  66468. * @param scene the scene the renderer renders in
  66469. */
  66470. constructor(scene: Scene);
  66471. /**
  66472. * Registers the component in a given scene
  66473. */
  66474. register(): void;
  66475. private _evaluateSubMesh;
  66476. private _activeMesh;
  66477. private _prepareRessources;
  66478. private _createIndexBuffer;
  66479. /**
  66480. * Rebuilds the elements related to this component in case of
  66481. * context lost for instance.
  66482. */
  66483. rebuild(): void;
  66484. /**
  66485. * @hidden
  66486. */
  66487. reset(): void;
  66488. /**
  66489. * Render the bounding boxes of a specific rendering group
  66490. * @param renderingGroupId defines the rendering group to render
  66491. */
  66492. render(renderingGroupId: number): void;
  66493. /**
  66494. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66495. * @param mesh Define the mesh to render the occlusion bounding box for
  66496. */
  66497. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66498. /**
  66499. * Dispose and release the resources attached to this renderer.
  66500. */
  66501. dispose(): void;
  66502. }
  66503. }
  66504. declare module BABYLON {
  66505. interface Scene {
  66506. /** @hidden (Backing field) */
  66507. _depthRenderer: {
  66508. [id: string]: DepthRenderer;
  66509. };
  66510. /**
  66511. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66512. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66513. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66514. * @returns the created depth renderer
  66515. */
  66516. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66517. /**
  66518. * Disables a depth renderer for a given camera
  66519. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66520. */
  66521. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66522. }
  66523. /**
  66524. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66525. * in several rendering techniques.
  66526. */
  66527. export class DepthRendererSceneComponent implements ISceneComponent {
  66528. /**
  66529. * The component name helpfull to identify the component in the list of scene components.
  66530. */
  66531. readonly name: string;
  66532. /**
  66533. * The scene the component belongs to.
  66534. */
  66535. scene: Scene;
  66536. /**
  66537. * Creates a new instance of the component for the given scene
  66538. * @param scene Defines the scene to register the component in
  66539. */
  66540. constructor(scene: Scene);
  66541. /**
  66542. * Registers the component in a given scene
  66543. */
  66544. register(): void;
  66545. /**
  66546. * Rebuilds the elements related to this component in case of
  66547. * context lost for instance.
  66548. */
  66549. rebuild(): void;
  66550. /**
  66551. * Disposes the component and the associated ressources
  66552. */
  66553. dispose(): void;
  66554. private _gatherRenderTargets;
  66555. private _gatherActiveCameraRenderTargets;
  66556. }
  66557. }
  66558. declare module BABYLON {
  66559. /** @hidden */
  66560. export var outlinePixelShader: {
  66561. name: string;
  66562. shader: string;
  66563. };
  66564. }
  66565. declare module BABYLON {
  66566. /** @hidden */
  66567. export var outlineVertexShader: {
  66568. name: string;
  66569. shader: string;
  66570. };
  66571. }
  66572. declare module BABYLON {
  66573. interface Scene {
  66574. /** @hidden */
  66575. _outlineRenderer: OutlineRenderer;
  66576. /**
  66577. * Gets the outline renderer associated with the scene
  66578. * @returns a OutlineRenderer
  66579. */
  66580. getOutlineRenderer(): OutlineRenderer;
  66581. }
  66582. interface AbstractMesh {
  66583. /** @hidden (Backing field) */
  66584. _renderOutline: boolean;
  66585. /**
  66586. * Gets or sets a boolean indicating if the outline must be rendered as well
  66587. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66588. */
  66589. renderOutline: boolean;
  66590. /** @hidden (Backing field) */
  66591. _renderOverlay: boolean;
  66592. /**
  66593. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66594. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66595. */
  66596. renderOverlay: boolean;
  66597. }
  66598. /**
  66599. * This class is responsible to draw bothe outline/overlay of meshes.
  66600. * It should not be used directly but through the available method on mesh.
  66601. */
  66602. export class OutlineRenderer implements ISceneComponent {
  66603. /**
  66604. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66605. */
  66606. private static _StencilReference;
  66607. /**
  66608. * The name of the component. Each component must have a unique name.
  66609. */
  66610. name: string;
  66611. /**
  66612. * The scene the component belongs to.
  66613. */
  66614. scene: Scene;
  66615. /**
  66616. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66617. */
  66618. zOffset: number;
  66619. private _engine;
  66620. private _effect;
  66621. private _cachedDefines;
  66622. private _savedDepthWrite;
  66623. /**
  66624. * Instantiates a new outline renderer. (There could be only one per scene).
  66625. * @param scene Defines the scene it belongs to
  66626. */
  66627. constructor(scene: Scene);
  66628. /**
  66629. * Register the component to one instance of a scene.
  66630. */
  66631. register(): void;
  66632. /**
  66633. * Rebuilds the elements related to this component in case of
  66634. * context lost for instance.
  66635. */
  66636. rebuild(): void;
  66637. /**
  66638. * Disposes the component and the associated ressources.
  66639. */
  66640. dispose(): void;
  66641. /**
  66642. * Renders the outline in the canvas.
  66643. * @param subMesh Defines the sumesh to render
  66644. * @param batch Defines the batch of meshes in case of instances
  66645. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66646. */
  66647. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66648. /**
  66649. * Returns whether or not the outline renderer is ready for a given submesh.
  66650. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66651. * @param subMesh Defines the submesh to check readyness for
  66652. * @param useInstances Defines wheter wee are trying to render instances or not
  66653. * @returns true if ready otherwise false
  66654. */
  66655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66656. private _beforeRenderingMesh;
  66657. private _afterRenderingMesh;
  66658. }
  66659. }
  66660. declare module BABYLON {
  66661. /**
  66662. * Defines the basic options interface of a Sprite Frame Source Size.
  66663. */
  66664. export interface ISpriteJSONSpriteSourceSize {
  66665. /**
  66666. * number of the original width of the Frame
  66667. */
  66668. w: number;
  66669. /**
  66670. * number of the original height of the Frame
  66671. */
  66672. h: number;
  66673. }
  66674. /**
  66675. * Defines the basic options interface of a Sprite Frame Data.
  66676. */
  66677. export interface ISpriteJSONSpriteFrameData {
  66678. /**
  66679. * number of the x offset of the Frame
  66680. */
  66681. x: number;
  66682. /**
  66683. * number of the y offset of the Frame
  66684. */
  66685. y: number;
  66686. /**
  66687. * number of the width of the Frame
  66688. */
  66689. w: number;
  66690. /**
  66691. * number of the height of the Frame
  66692. */
  66693. h: number;
  66694. }
  66695. /**
  66696. * Defines the basic options interface of a JSON Sprite.
  66697. */
  66698. export interface ISpriteJSONSprite {
  66699. /**
  66700. * string name of the Frame
  66701. */
  66702. filename: string;
  66703. /**
  66704. * ISpriteJSONSpriteFrame basic object of the frame data
  66705. */
  66706. frame: ISpriteJSONSpriteFrameData;
  66707. /**
  66708. * boolean to flag is the frame was rotated.
  66709. */
  66710. rotated: boolean;
  66711. /**
  66712. * boolean to flag is the frame was trimmed.
  66713. */
  66714. trimmed: boolean;
  66715. /**
  66716. * ISpriteJSONSpriteFrame basic object of the source data
  66717. */
  66718. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66719. /**
  66720. * ISpriteJSONSpriteFrame basic object of the source data
  66721. */
  66722. sourceSize: ISpriteJSONSpriteSourceSize;
  66723. }
  66724. /**
  66725. * Defines the basic options interface of a JSON atlas.
  66726. */
  66727. export interface ISpriteJSONAtlas {
  66728. /**
  66729. * Array of objects that contain the frame data.
  66730. */
  66731. frames: Array<ISpriteJSONSprite>;
  66732. /**
  66733. * object basic object containing the sprite meta data.
  66734. */
  66735. meta?: object;
  66736. }
  66737. }
  66738. declare module BABYLON {
  66739. /** @hidden */
  66740. export var spriteMapPixelShader: {
  66741. name: string;
  66742. shader: string;
  66743. };
  66744. }
  66745. declare module BABYLON {
  66746. /** @hidden */
  66747. export var spriteMapVertexShader: {
  66748. name: string;
  66749. shader: string;
  66750. };
  66751. }
  66752. declare module BABYLON {
  66753. /**
  66754. * Defines the basic options interface of a SpriteMap
  66755. */
  66756. export interface ISpriteMapOptions {
  66757. /**
  66758. * Vector2 of the number of cells in the grid.
  66759. */
  66760. stageSize?: Vector2;
  66761. /**
  66762. * Vector2 of the size of the output plane in World Units.
  66763. */
  66764. outputSize?: Vector2;
  66765. /**
  66766. * Vector3 of the position of the output plane in World Units.
  66767. */
  66768. outputPosition?: Vector3;
  66769. /**
  66770. * Vector3 of the rotation of the output plane.
  66771. */
  66772. outputRotation?: Vector3;
  66773. /**
  66774. * number of layers that the system will reserve in resources.
  66775. */
  66776. layerCount?: number;
  66777. /**
  66778. * number of max animation frames a single cell will reserve in resources.
  66779. */
  66780. maxAnimationFrames?: number;
  66781. /**
  66782. * number cell index of the base tile when the system compiles.
  66783. */
  66784. baseTile?: number;
  66785. /**
  66786. * boolean flip the sprite after its been repositioned by the framing data.
  66787. */
  66788. flipU?: boolean;
  66789. /**
  66790. * Vector3 scalar of the global RGB values of the SpriteMap.
  66791. */
  66792. colorMultiply?: Vector3;
  66793. }
  66794. /**
  66795. * Defines the IDisposable interface in order to be cleanable from resources.
  66796. */
  66797. export interface ISpriteMap extends IDisposable {
  66798. /**
  66799. * String name of the SpriteMap.
  66800. */
  66801. name: string;
  66802. /**
  66803. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66804. */
  66805. atlasJSON: ISpriteJSONAtlas;
  66806. /**
  66807. * Texture of the SpriteMap.
  66808. */
  66809. spriteSheet: Texture;
  66810. /**
  66811. * The parameters to initialize the SpriteMap with.
  66812. */
  66813. options: ISpriteMapOptions;
  66814. }
  66815. /**
  66816. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66817. */
  66818. export class SpriteMap implements ISpriteMap {
  66819. /** The Name of the spriteMap */
  66820. name: string;
  66821. /** The JSON file with the frame and meta data */
  66822. atlasJSON: ISpriteJSONAtlas;
  66823. /** The systems Sprite Sheet Texture */
  66824. spriteSheet: Texture;
  66825. /** Arguments passed with the Constructor */
  66826. options: ISpriteMapOptions;
  66827. /** Public Sprite Storage array, parsed from atlasJSON */
  66828. sprites: Array<ISpriteJSONSprite>;
  66829. /** Returns the Number of Sprites in the System */
  66830. get spriteCount(): number;
  66831. /** Returns the Position of Output Plane*/
  66832. get position(): Vector3;
  66833. /** Returns the Position of Output Plane*/
  66834. set position(v: Vector3);
  66835. /** Returns the Rotation of Output Plane*/
  66836. get rotation(): Vector3;
  66837. /** Returns the Rotation of Output Plane*/
  66838. set rotation(v: Vector3);
  66839. /** Sets the AnimationMap*/
  66840. get animationMap(): RawTexture;
  66841. /** Sets the AnimationMap*/
  66842. set animationMap(v: RawTexture);
  66843. /** Scene that the SpriteMap was created in */
  66844. private _scene;
  66845. /** Texture Buffer of Float32 that holds tile frame data*/
  66846. private _frameMap;
  66847. /** Texture Buffers of Float32 that holds tileMap data*/
  66848. private _tileMaps;
  66849. /** Texture Buffer of Float32 that holds Animation Data*/
  66850. private _animationMap;
  66851. /** Custom ShaderMaterial Central to the System*/
  66852. private _material;
  66853. /** Custom ShaderMaterial Central to the System*/
  66854. private _output;
  66855. /** Systems Time Ticker*/
  66856. private _time;
  66857. /**
  66858. * Creates a new SpriteMap
  66859. * @param name defines the SpriteMaps Name
  66860. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66861. * @param spriteSheet is the Texture that the Sprites are on.
  66862. * @param options a basic deployment configuration
  66863. * @param scene The Scene that the map is deployed on
  66864. */
  66865. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66866. /**
  66867. * Returns tileID location
  66868. * @returns Vector2 the cell position ID
  66869. */
  66870. getTileID(): Vector2;
  66871. /**
  66872. * Gets the UV location of the mouse over the SpriteMap.
  66873. * @returns Vector2 the UV position of the mouse interaction
  66874. */
  66875. getMousePosition(): Vector2;
  66876. /**
  66877. * Creates the "frame" texture Buffer
  66878. * -------------------------------------
  66879. * Structure of frames
  66880. * "filename": "Falling-Water-2.png",
  66881. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66882. * "rotated": true,
  66883. * "trimmed": true,
  66884. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66885. * "sourceSize": {"w":32,"h":32}
  66886. * @returns RawTexture of the frameMap
  66887. */
  66888. private _createFrameBuffer;
  66889. /**
  66890. * Creates the tileMap texture Buffer
  66891. * @param buffer normally and array of numbers, or a false to generate from scratch
  66892. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66893. * @returns RawTexture of the tileMap
  66894. */
  66895. private _createTileBuffer;
  66896. /**
  66897. * Modifies the data of the tileMaps
  66898. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66899. * @param pos is the iVector2 Coordinates of the Tile
  66900. * @param tile The SpriteIndex of the new Tile
  66901. */
  66902. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66903. /**
  66904. * Creates the animationMap texture Buffer
  66905. * @param buffer normally and array of numbers, or a false to generate from scratch
  66906. * @returns RawTexture of the animationMap
  66907. */
  66908. private _createTileAnimationBuffer;
  66909. /**
  66910. * Modifies the data of the animationMap
  66911. * @param cellID is the Index of the Sprite
  66912. * @param _frame is the target Animation frame
  66913. * @param toCell is the Target Index of the next frame of the animation
  66914. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66915. * @param speed is a global scalar of the time variable on the map.
  66916. */
  66917. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66918. /**
  66919. * Exports the .tilemaps file
  66920. */
  66921. saveTileMaps(): void;
  66922. /**
  66923. * Imports the .tilemaps file
  66924. * @param url of the .tilemaps file
  66925. */
  66926. loadTileMaps(url: string): void;
  66927. /**
  66928. * Release associated resources
  66929. */
  66930. dispose(): void;
  66931. }
  66932. }
  66933. declare module BABYLON {
  66934. /**
  66935. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66936. * @see http://doc.babylonjs.com/babylon101/sprites
  66937. */
  66938. export class SpritePackedManager extends SpriteManager {
  66939. /** defines the packed manager's name */
  66940. name: string;
  66941. /**
  66942. * Creates a new sprite manager from a packed sprite sheet
  66943. * @param name defines the manager's name
  66944. * @param imgUrl defines the sprite sheet url
  66945. * @param capacity defines the maximum allowed number of sprites
  66946. * @param scene defines the hosting scene
  66947. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66948. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66949. * @param samplingMode defines the smapling mode to use with spritesheet
  66950. * @param fromPacked set to true; do not alter
  66951. */
  66952. constructor(
  66953. /** defines the packed manager's name */
  66954. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66955. }
  66956. }
  66957. declare module BABYLON {
  66958. /**
  66959. * Defines the list of states available for a task inside a AssetsManager
  66960. */
  66961. export enum AssetTaskState {
  66962. /**
  66963. * Initialization
  66964. */
  66965. INIT = 0,
  66966. /**
  66967. * Running
  66968. */
  66969. RUNNING = 1,
  66970. /**
  66971. * Done
  66972. */
  66973. DONE = 2,
  66974. /**
  66975. * Error
  66976. */
  66977. ERROR = 3
  66978. }
  66979. /**
  66980. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66981. */
  66982. export abstract class AbstractAssetTask {
  66983. /**
  66984. * Task name
  66985. */ name: string;
  66986. /**
  66987. * Callback called when the task is successful
  66988. */
  66989. onSuccess: (task: any) => void;
  66990. /**
  66991. * Callback called when the task is not successful
  66992. */
  66993. onError: (task: any, message?: string, exception?: any) => void;
  66994. /**
  66995. * Creates a new AssetsManager
  66996. * @param name defines the name of the task
  66997. */
  66998. constructor(
  66999. /**
  67000. * Task name
  67001. */ name: string);
  67002. private _isCompleted;
  67003. private _taskState;
  67004. private _errorObject;
  67005. /**
  67006. * Get if the task is completed
  67007. */
  67008. get isCompleted(): boolean;
  67009. /**
  67010. * Gets the current state of the task
  67011. */
  67012. get taskState(): AssetTaskState;
  67013. /**
  67014. * Gets the current error object (if task is in error)
  67015. */
  67016. get errorObject(): {
  67017. message?: string;
  67018. exception?: any;
  67019. };
  67020. /**
  67021. * Internal only
  67022. * @hidden
  67023. */
  67024. _setErrorObject(message?: string, exception?: any): void;
  67025. /**
  67026. * Execute the current task
  67027. * @param scene defines the scene where you want your assets to be loaded
  67028. * @param onSuccess is a callback called when the task is successfully executed
  67029. * @param onError is a callback called if an error occurs
  67030. */
  67031. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67032. /**
  67033. * Execute the current task
  67034. * @param scene defines the scene where you want your assets to be loaded
  67035. * @param onSuccess is a callback called when the task is successfully executed
  67036. * @param onError is a callback called if an error occurs
  67037. */
  67038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67039. /**
  67040. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67041. * This can be used with failed tasks that have the reason for failure fixed.
  67042. */
  67043. reset(): void;
  67044. private onErrorCallback;
  67045. private onDoneCallback;
  67046. }
  67047. /**
  67048. * Define the interface used by progress events raised during assets loading
  67049. */
  67050. export interface IAssetsProgressEvent {
  67051. /**
  67052. * Defines the number of remaining tasks to process
  67053. */
  67054. remainingCount: number;
  67055. /**
  67056. * Defines the total number of tasks
  67057. */
  67058. totalCount: number;
  67059. /**
  67060. * Defines the task that was just processed
  67061. */
  67062. task: AbstractAssetTask;
  67063. }
  67064. /**
  67065. * Class used to share progress information about assets loading
  67066. */
  67067. export class AssetsProgressEvent implements 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. * Creates a AssetsProgressEvent
  67082. * @param remainingCount defines the number of remaining tasks to process
  67083. * @param totalCount defines the total number of tasks
  67084. * @param task defines the task that was just processed
  67085. */
  67086. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67087. }
  67088. /**
  67089. * Define a task used by AssetsManager to load meshes
  67090. */
  67091. export class MeshAssetTask extends AbstractAssetTask {
  67092. /**
  67093. * Defines the name of the task
  67094. */
  67095. name: string;
  67096. /**
  67097. * Defines the list of mesh's names you want to load
  67098. */
  67099. meshesNames: any;
  67100. /**
  67101. * Defines the root url to use as a base to load your meshes and associated resources
  67102. */
  67103. rootUrl: string;
  67104. /**
  67105. * Defines the filename of the scene to load from
  67106. */
  67107. sceneFilename: string;
  67108. /**
  67109. * Gets the list of loaded meshes
  67110. */
  67111. loadedMeshes: Array<AbstractMesh>;
  67112. /**
  67113. * Gets the list of loaded particle systems
  67114. */
  67115. loadedParticleSystems: Array<IParticleSystem>;
  67116. /**
  67117. * Gets the list of loaded skeletons
  67118. */
  67119. loadedSkeletons: Array<Skeleton>;
  67120. /**
  67121. * Gets the list of loaded animation groups
  67122. */
  67123. loadedAnimationGroups: Array<AnimationGroup>;
  67124. /**
  67125. * Callback called when the task is successful
  67126. */
  67127. onSuccess: (task: MeshAssetTask) => void;
  67128. /**
  67129. * Callback called when the task is successful
  67130. */
  67131. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67132. /**
  67133. * Creates a new MeshAssetTask
  67134. * @param name defines the name of the task
  67135. * @param meshesNames defines the list of mesh's names you want to load
  67136. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67137. * @param sceneFilename defines the filename of the scene to load from
  67138. */
  67139. constructor(
  67140. /**
  67141. * Defines the name of the task
  67142. */
  67143. name: string,
  67144. /**
  67145. * Defines the list of mesh's names you want to load
  67146. */
  67147. meshesNames: any,
  67148. /**
  67149. * Defines the root url to use as a base to load your meshes and associated resources
  67150. */
  67151. rootUrl: string,
  67152. /**
  67153. * Defines the filename of the scene to load from
  67154. */
  67155. sceneFilename: string);
  67156. /**
  67157. * Execute the current task
  67158. * @param scene defines the scene where you want your assets to be loaded
  67159. * @param onSuccess is a callback called when the task is successfully executed
  67160. * @param onError is a callback called if an error occurs
  67161. */
  67162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67163. }
  67164. /**
  67165. * Define a task used by AssetsManager to load text content
  67166. */
  67167. export class TextFileAssetTask extends AbstractAssetTask {
  67168. /**
  67169. * Defines the name of the task
  67170. */
  67171. name: string;
  67172. /**
  67173. * Defines the location of the file to load
  67174. */
  67175. url: string;
  67176. /**
  67177. * Gets the loaded text string
  67178. */
  67179. text: string;
  67180. /**
  67181. * Callback called when the task is successful
  67182. */
  67183. onSuccess: (task: TextFileAssetTask) => void;
  67184. /**
  67185. * Callback called when the task is successful
  67186. */
  67187. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67188. /**
  67189. * Creates a new TextFileAssetTask object
  67190. * @param name defines the name of the task
  67191. * @param url defines the location of the file to load
  67192. */
  67193. constructor(
  67194. /**
  67195. * Defines the name of the task
  67196. */
  67197. name: string,
  67198. /**
  67199. * Defines the location of the file to load
  67200. */
  67201. url: string);
  67202. /**
  67203. * Execute the current task
  67204. * @param scene defines the scene where you want your assets to be loaded
  67205. * @param onSuccess is a callback called when the task is successfully executed
  67206. * @param onError is a callback called if an error occurs
  67207. */
  67208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67209. }
  67210. /**
  67211. * Define a task used by AssetsManager to load binary data
  67212. */
  67213. export class BinaryFileAssetTask extends AbstractAssetTask {
  67214. /**
  67215. * Defines the name of the task
  67216. */
  67217. name: string;
  67218. /**
  67219. * Defines the location of the file to load
  67220. */
  67221. url: string;
  67222. /**
  67223. * Gets the lodaded data (as an array buffer)
  67224. */
  67225. data: ArrayBuffer;
  67226. /**
  67227. * Callback called when the task is successful
  67228. */
  67229. onSuccess: (task: BinaryFileAssetTask) => void;
  67230. /**
  67231. * Callback called when the task is successful
  67232. */
  67233. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67234. /**
  67235. * Creates a new BinaryFileAssetTask object
  67236. * @param name defines the name of the new task
  67237. * @param url defines the location of the file to load
  67238. */
  67239. constructor(
  67240. /**
  67241. * Defines the name of the task
  67242. */
  67243. name: string,
  67244. /**
  67245. * Defines the location of the file to load
  67246. */
  67247. url: string);
  67248. /**
  67249. * Execute the current task
  67250. * @param scene defines the scene where you want your assets to be loaded
  67251. * @param onSuccess is a callback called when the task is successfully executed
  67252. * @param onError is a callback called if an error occurs
  67253. */
  67254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67255. }
  67256. /**
  67257. * Define a task used by AssetsManager to load images
  67258. */
  67259. export class ImageAssetTask extends AbstractAssetTask {
  67260. /**
  67261. * Defines the name of the task
  67262. */
  67263. name: string;
  67264. /**
  67265. * Defines the location of the image to load
  67266. */
  67267. url: string;
  67268. /**
  67269. * Gets the loaded images
  67270. */
  67271. image: HTMLImageElement;
  67272. /**
  67273. * Callback called when the task is successful
  67274. */
  67275. onSuccess: (task: ImageAssetTask) => void;
  67276. /**
  67277. * Callback called when the task is successful
  67278. */
  67279. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67280. /**
  67281. * Creates a new ImageAssetTask
  67282. * @param name defines the name of the task
  67283. * @param url defines the location of the image to load
  67284. */
  67285. constructor(
  67286. /**
  67287. * Defines the name of the task
  67288. */
  67289. name: string,
  67290. /**
  67291. * Defines the location of the image to load
  67292. */
  67293. url: string);
  67294. /**
  67295. * Execute the current task
  67296. * @param scene defines the scene where you want your assets to be loaded
  67297. * @param onSuccess is a callback called when the task is successfully executed
  67298. * @param onError is a callback called if an error occurs
  67299. */
  67300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67301. }
  67302. /**
  67303. * Defines the interface used by texture loading tasks
  67304. */
  67305. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67306. /**
  67307. * Gets the loaded texture
  67308. */
  67309. texture: TEX;
  67310. }
  67311. /**
  67312. * Define a task used by AssetsManager to load 2D textures
  67313. */
  67314. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67315. /**
  67316. * Defines the name of the task
  67317. */
  67318. name: string;
  67319. /**
  67320. * Defines the location of the file to load
  67321. */
  67322. url: string;
  67323. /**
  67324. * Defines if mipmap should not be generated (default is false)
  67325. */
  67326. noMipmap?: boolean | undefined;
  67327. /**
  67328. * Defines if texture must be inverted on Y axis (default is false)
  67329. */
  67330. invertY?: boolean | undefined;
  67331. /**
  67332. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67333. */
  67334. samplingMode: number;
  67335. /**
  67336. * Gets the loaded texture
  67337. */
  67338. texture: Texture;
  67339. /**
  67340. * Callback called when the task is successful
  67341. */
  67342. onSuccess: (task: TextureAssetTask) => void;
  67343. /**
  67344. * Callback called when the task is successful
  67345. */
  67346. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67347. /**
  67348. * Creates a new TextureAssetTask object
  67349. * @param name defines the name of the task
  67350. * @param url defines the location of the file to load
  67351. * @param noMipmap defines if mipmap should not be generated (default is false)
  67352. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67353. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67354. */
  67355. constructor(
  67356. /**
  67357. * Defines the name of the task
  67358. */
  67359. name: string,
  67360. /**
  67361. * Defines the location of the file to load
  67362. */
  67363. url: string,
  67364. /**
  67365. * Defines if mipmap should not be generated (default is false)
  67366. */
  67367. noMipmap?: boolean | undefined,
  67368. /**
  67369. * Defines if texture must be inverted on Y axis (default is false)
  67370. */
  67371. invertY?: boolean | undefined,
  67372. /**
  67373. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67374. */
  67375. samplingMode?: number);
  67376. /**
  67377. * Execute the current task
  67378. * @param scene defines the scene where you want your assets to be loaded
  67379. * @param onSuccess is a callback called when the task is successfully executed
  67380. * @param onError is a callback called if an error occurs
  67381. */
  67382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67383. }
  67384. /**
  67385. * Define a task used by AssetsManager to load cube textures
  67386. */
  67387. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67388. /**
  67389. * Defines the name of the task
  67390. */
  67391. name: string;
  67392. /**
  67393. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67394. */
  67395. url: string;
  67396. /**
  67397. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67398. */
  67399. extensions?: string[] | undefined;
  67400. /**
  67401. * Defines if mipmaps should not be generated (default is false)
  67402. */
  67403. noMipmap?: boolean | undefined;
  67404. /**
  67405. * Defines the explicit list of files (undefined by default)
  67406. */
  67407. files?: string[] | undefined;
  67408. /**
  67409. * Gets the loaded texture
  67410. */
  67411. texture: CubeTexture;
  67412. /**
  67413. * Callback called when the task is successful
  67414. */
  67415. onSuccess: (task: CubeTextureAssetTask) => void;
  67416. /**
  67417. * Callback called when the task is successful
  67418. */
  67419. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67420. /**
  67421. * Creates a new CubeTextureAssetTask
  67422. * @param name defines the name of the task
  67423. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67424. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67425. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67426. * @param files defines the explicit list of files (undefined by default)
  67427. */
  67428. constructor(
  67429. /**
  67430. * Defines the name of the task
  67431. */
  67432. name: string,
  67433. /**
  67434. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67435. */
  67436. url: string,
  67437. /**
  67438. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67439. */
  67440. extensions?: string[] | undefined,
  67441. /**
  67442. * Defines if mipmaps should not be generated (default is false)
  67443. */
  67444. noMipmap?: boolean | undefined,
  67445. /**
  67446. * Defines the explicit list of files (undefined by default)
  67447. */
  67448. files?: string[] | undefined);
  67449. /**
  67450. * Execute the current task
  67451. * @param scene defines the scene where you want your assets to be loaded
  67452. * @param onSuccess is a callback called when the task is successfully executed
  67453. * @param onError is a callback called if an error occurs
  67454. */
  67455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67456. }
  67457. /**
  67458. * Define a task used by AssetsManager to load HDR cube textures
  67459. */
  67460. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67461. /**
  67462. * Defines the name of the task
  67463. */
  67464. name: string;
  67465. /**
  67466. * Defines the location of the file to load
  67467. */
  67468. url: string;
  67469. /**
  67470. * Defines the desired size (the more it increases the longer the generation will be)
  67471. */
  67472. size: number;
  67473. /**
  67474. * Defines if mipmaps should not be generated (default is false)
  67475. */
  67476. noMipmap: boolean;
  67477. /**
  67478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67479. */
  67480. generateHarmonics: boolean;
  67481. /**
  67482. * 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)
  67483. */
  67484. gammaSpace: boolean;
  67485. /**
  67486. * Internal Use Only
  67487. */
  67488. reserved: boolean;
  67489. /**
  67490. * Gets the loaded texture
  67491. */
  67492. texture: HDRCubeTexture;
  67493. /**
  67494. * Callback called when the task is successful
  67495. */
  67496. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67497. /**
  67498. * Callback called when the task is successful
  67499. */
  67500. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67501. /**
  67502. * Creates a new HDRCubeTextureAssetTask object
  67503. * @param name defines the name of the task
  67504. * @param url defines the location of the file to load
  67505. * @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.
  67506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67507. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67508. * @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)
  67509. * @param reserved Internal use only
  67510. */
  67511. constructor(
  67512. /**
  67513. * Defines the name of the task
  67514. */
  67515. name: string,
  67516. /**
  67517. * Defines the location of the file to load
  67518. */
  67519. url: string,
  67520. /**
  67521. * Defines the desired size (the more it increases the longer the generation will be)
  67522. */
  67523. size: number,
  67524. /**
  67525. * Defines if mipmaps should not be generated (default is false)
  67526. */
  67527. noMipmap?: boolean,
  67528. /**
  67529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67530. */
  67531. generateHarmonics?: boolean,
  67532. /**
  67533. * 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)
  67534. */
  67535. gammaSpace?: boolean,
  67536. /**
  67537. * Internal Use Only
  67538. */
  67539. reserved?: boolean);
  67540. /**
  67541. * Execute the current task
  67542. * @param scene defines the scene where you want your assets to be loaded
  67543. * @param onSuccess is a callback called when the task is successfully executed
  67544. * @param onError is a callback called if an error occurs
  67545. */
  67546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67547. }
  67548. /**
  67549. * Define a task used by AssetsManager to load Equirectangular cube textures
  67550. */
  67551. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67552. /**
  67553. * Defines the name of the task
  67554. */
  67555. name: string;
  67556. /**
  67557. * Defines the location of the file to load
  67558. */
  67559. url: string;
  67560. /**
  67561. * Defines the desired size (the more it increases the longer the generation will be)
  67562. */
  67563. size: number;
  67564. /**
  67565. * Defines if mipmaps should not be generated (default is false)
  67566. */
  67567. noMipmap: boolean;
  67568. /**
  67569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67570. * but the standard material would require them in Gamma space) (default is true)
  67571. */
  67572. gammaSpace: boolean;
  67573. /**
  67574. * Gets the loaded texture
  67575. */
  67576. texture: EquiRectangularCubeTexture;
  67577. /**
  67578. * Callback called when the task is successful
  67579. */
  67580. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67581. /**
  67582. * Callback called when the task is successful
  67583. */
  67584. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67585. /**
  67586. * Creates a new EquiRectangularCubeTextureAssetTask object
  67587. * @param name defines the name of the task
  67588. * @param url defines the location of the file to load
  67589. * @param size defines the desired size (the more it increases the longer the generation will be)
  67590. * If the size is omitted this implies you are using a preprocessed cubemap.
  67591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67592. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67593. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67594. * (default is true)
  67595. */
  67596. constructor(
  67597. /**
  67598. * Defines the name of the task
  67599. */
  67600. name: string,
  67601. /**
  67602. * Defines the location of the file to load
  67603. */
  67604. url: string,
  67605. /**
  67606. * Defines the desired size (the more it increases the longer the generation will be)
  67607. */
  67608. size: number,
  67609. /**
  67610. * Defines if mipmaps should not be generated (default is false)
  67611. */
  67612. noMipmap?: boolean,
  67613. /**
  67614. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67615. * but the standard material would require them in Gamma space) (default is true)
  67616. */
  67617. gammaSpace?: boolean);
  67618. /**
  67619. * Execute the current task
  67620. * @param scene defines the scene where you want your assets to be loaded
  67621. * @param onSuccess is a callback called when the task is successfully executed
  67622. * @param onError is a callback called if an error occurs
  67623. */
  67624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67625. }
  67626. /**
  67627. * This class can be used to easily import assets into a scene
  67628. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67629. */
  67630. export class AssetsManager {
  67631. private _scene;
  67632. private _isLoading;
  67633. protected _tasks: AbstractAssetTask[];
  67634. protected _waitingTasksCount: number;
  67635. protected _totalTasksCount: number;
  67636. /**
  67637. * Callback called when all tasks are processed
  67638. */
  67639. onFinish: (tasks: AbstractAssetTask[]) => void;
  67640. /**
  67641. * Callback called when a task is successful
  67642. */
  67643. onTaskSuccess: (task: AbstractAssetTask) => void;
  67644. /**
  67645. * Callback called when a task had an error
  67646. */
  67647. onTaskError: (task: AbstractAssetTask) => void;
  67648. /**
  67649. * Callback called when a task is done (whatever the result is)
  67650. */
  67651. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67652. /**
  67653. * Observable called when all tasks are processed
  67654. */
  67655. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67656. /**
  67657. * Observable called when a task had an error
  67658. */
  67659. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67660. /**
  67661. * Observable called when all tasks were executed
  67662. */
  67663. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67664. /**
  67665. * Observable called when a task is done (whatever the result is)
  67666. */
  67667. onProgressObservable: Observable<IAssetsProgressEvent>;
  67668. /**
  67669. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67671. */
  67672. useDefaultLoadingScreen: boolean;
  67673. /**
  67674. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67675. * when all assets have been downloaded.
  67676. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67677. */
  67678. autoHideLoadingUI: boolean;
  67679. /**
  67680. * Creates a new AssetsManager
  67681. * @param scene defines the scene to work on
  67682. */
  67683. constructor(scene: Scene);
  67684. /**
  67685. * Add a MeshAssetTask to the list of active tasks
  67686. * @param taskName defines the name of the new task
  67687. * @param meshesNames defines the name of meshes to load
  67688. * @param rootUrl defines the root url to use to locate files
  67689. * @param sceneFilename defines the filename of the scene file
  67690. * @returns a new MeshAssetTask object
  67691. */
  67692. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67693. /**
  67694. * Add a TextFileAssetTask to the list of active tasks
  67695. * @param taskName defines the name of the new task
  67696. * @param url defines the url of the file to load
  67697. * @returns a new TextFileAssetTask object
  67698. */
  67699. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67700. /**
  67701. * Add a BinaryFileAssetTask to the list of active tasks
  67702. * @param taskName defines the name of the new task
  67703. * @param url defines the url of the file to load
  67704. * @returns a new BinaryFileAssetTask object
  67705. */
  67706. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67707. /**
  67708. * Add a ImageAssetTask to the list of active tasks
  67709. * @param taskName defines the name of the new task
  67710. * @param url defines the url of the file to load
  67711. * @returns a new ImageAssetTask object
  67712. */
  67713. addImageTask(taskName: string, url: string): ImageAssetTask;
  67714. /**
  67715. * Add a TextureAssetTask to the list of active tasks
  67716. * @param taskName defines the name of the new task
  67717. * @param url defines the url of the file to load
  67718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67719. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67720. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67721. * @returns a new TextureAssetTask object
  67722. */
  67723. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67724. /**
  67725. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  67729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67730. * @param files defines the list of files to load (can be null)
  67731. * @returns a new CubeTextureAssetTask object
  67732. */
  67733. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67734. /**
  67735. *
  67736. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67737. * @param taskName defines the name of the new task
  67738. * @param url defines the url of the file to load
  67739. * @param size defines the size you want for the cubemap (can be null)
  67740. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67741. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67742. * @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)
  67743. * @param reserved Internal use only
  67744. * @returns a new HDRCubeTextureAssetTask object
  67745. */
  67746. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67747. /**
  67748. *
  67749. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67750. * @param taskName defines the name of the new task
  67751. * @param url defines the url of the file to load
  67752. * @param size defines the size you want for the cubemap (can be null)
  67753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67754. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67755. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67756. * @returns a new EquiRectangularCubeTextureAssetTask object
  67757. */
  67758. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67759. /**
  67760. * Remove a task from the assets manager.
  67761. * @param task the task to remove
  67762. */
  67763. removeTask(task: AbstractAssetTask): void;
  67764. private _decreaseWaitingTasksCount;
  67765. private _runTask;
  67766. /**
  67767. * Reset the AssetsManager and remove all tasks
  67768. * @return the current instance of the AssetsManager
  67769. */
  67770. reset(): AssetsManager;
  67771. /**
  67772. * Start the loading process
  67773. * @return the current instance of the AssetsManager
  67774. */
  67775. load(): AssetsManager;
  67776. /**
  67777. * Start the loading process as an async operation
  67778. * @return a promise returning the list of failed tasks
  67779. */
  67780. loadAsync(): Promise<void>;
  67781. }
  67782. }
  67783. declare module BABYLON {
  67784. /**
  67785. * Wrapper class for promise with external resolve and reject.
  67786. */
  67787. export class Deferred<T> {
  67788. /**
  67789. * The promise associated with this deferred object.
  67790. */
  67791. readonly promise: Promise<T>;
  67792. private _resolve;
  67793. private _reject;
  67794. /**
  67795. * The resolve method of the promise associated with this deferred object.
  67796. */
  67797. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67798. /**
  67799. * The reject method of the promise associated with this deferred object.
  67800. */
  67801. get reject(): (reason?: any) => void;
  67802. /**
  67803. * Constructor for this deferred object.
  67804. */
  67805. constructor();
  67806. }
  67807. }
  67808. declare module BABYLON {
  67809. /**
  67810. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67811. */
  67812. export class MeshExploder {
  67813. private _centerMesh;
  67814. private _meshes;
  67815. private _meshesOrigins;
  67816. private _toCenterVectors;
  67817. private _scaledDirection;
  67818. private _newPosition;
  67819. private _centerPosition;
  67820. /**
  67821. * Explodes meshes from a center mesh.
  67822. * @param meshes The meshes to explode.
  67823. * @param centerMesh The mesh to be center of explosion.
  67824. */
  67825. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67826. private _setCenterMesh;
  67827. /**
  67828. * Get class name
  67829. * @returns "MeshExploder"
  67830. */
  67831. getClassName(): string;
  67832. /**
  67833. * "Exploded meshes"
  67834. * @returns Array of meshes with the centerMesh at index 0.
  67835. */
  67836. getMeshes(): Array<Mesh>;
  67837. /**
  67838. * Explodes meshes giving a specific direction
  67839. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67840. */
  67841. explode(direction?: number): void;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. * Class used to help managing file picking and drag'n'drop
  67847. */
  67848. export class FilesInput {
  67849. /**
  67850. * List of files ready to be loaded
  67851. */
  67852. static get FilesToLoad(): {
  67853. [key: string]: File;
  67854. };
  67855. /**
  67856. * Callback called when a file is processed
  67857. */
  67858. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67859. private _engine;
  67860. private _currentScene;
  67861. private _sceneLoadedCallback;
  67862. private _progressCallback;
  67863. private _additionalRenderLoopLogicCallback;
  67864. private _textureLoadingCallback;
  67865. private _startingProcessingFilesCallback;
  67866. private _onReloadCallback;
  67867. private _errorCallback;
  67868. private _elementToMonitor;
  67869. private _sceneFileToLoad;
  67870. private _filesToLoad;
  67871. /**
  67872. * Creates a new FilesInput
  67873. * @param engine defines the rendering engine
  67874. * @param scene defines the hosting scene
  67875. * @param sceneLoadedCallback callback called when scene is loaded
  67876. * @param progressCallback callback called to track progress
  67877. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67878. * @param textureLoadingCallback callback called when a texture is loading
  67879. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67880. * @param onReloadCallback callback called when a reload is requested
  67881. * @param errorCallback callback call if an error occurs
  67882. */
  67883. 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);
  67884. private _dragEnterHandler;
  67885. private _dragOverHandler;
  67886. private _dropHandler;
  67887. /**
  67888. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67889. * @param elementToMonitor defines the DOM element to track
  67890. */
  67891. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67892. /**
  67893. * Release all associated resources
  67894. */
  67895. dispose(): void;
  67896. private renderFunction;
  67897. private drag;
  67898. private drop;
  67899. private _traverseFolder;
  67900. private _processFiles;
  67901. /**
  67902. * Load files from a drop event
  67903. * @param event defines the drop event to use as source
  67904. */
  67905. loadFiles(event: any): void;
  67906. private _processReload;
  67907. /**
  67908. * Reload the current scene from the loaded files
  67909. */
  67910. reload(): void;
  67911. }
  67912. }
  67913. declare module BABYLON {
  67914. /**
  67915. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67917. */
  67918. export class SceneOptimization {
  67919. /**
  67920. * Defines the priority of this optimization (0 by default which means first in the list)
  67921. */
  67922. priority: number;
  67923. /**
  67924. * Gets a string describing the action executed by the current optimization
  67925. * @returns description string
  67926. */
  67927. getDescription(): string;
  67928. /**
  67929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67930. * @param scene defines the current scene where to apply this optimization
  67931. * @param optimizer defines the current optimizer
  67932. * @returns true if everything that can be done was applied
  67933. */
  67934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67935. /**
  67936. * Creates the SceneOptimization object
  67937. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67938. * @param desc defines the description associated with the optimization
  67939. */
  67940. constructor(
  67941. /**
  67942. * Defines the priority of this optimization (0 by default which means first in the list)
  67943. */
  67944. priority?: number);
  67945. }
  67946. /**
  67947. * Defines an optimization used to reduce the size of render target textures
  67948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67949. */
  67950. export class TextureOptimization extends SceneOptimization {
  67951. /**
  67952. * Defines the priority of this optimization (0 by default which means first in the list)
  67953. */
  67954. priority: number;
  67955. /**
  67956. * 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
  67957. */
  67958. maximumSize: number;
  67959. /**
  67960. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67961. */
  67962. step: number;
  67963. /**
  67964. * Gets a string describing the action executed by the current optimization
  67965. * @returns description string
  67966. */
  67967. getDescription(): string;
  67968. /**
  67969. * Creates the TextureOptimization object
  67970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67971. * @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
  67972. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67973. */
  67974. constructor(
  67975. /**
  67976. * Defines the priority of this optimization (0 by default which means first in the list)
  67977. */
  67978. priority?: number,
  67979. /**
  67980. * 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
  67981. */
  67982. maximumSize?: number,
  67983. /**
  67984. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67985. */
  67986. step?: number);
  67987. /**
  67988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67989. * @param scene defines the current scene where to apply this optimization
  67990. * @param optimizer defines the current optimizer
  67991. * @returns true if everything that can be done was applied
  67992. */
  67993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67994. }
  67995. /**
  67996. * Defines an optimization used to increase or decrease the rendering resolution
  67997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67998. */
  67999. export class HardwareScalingOptimization extends SceneOptimization {
  68000. /**
  68001. * Defines the priority of this optimization (0 by default which means first in the list)
  68002. */
  68003. priority: number;
  68004. /**
  68005. * Defines the maximum scale to use (2 by default)
  68006. */
  68007. maximumScale: number;
  68008. /**
  68009. * Defines the step to use between two passes (0.5 by default)
  68010. */
  68011. step: number;
  68012. private _currentScale;
  68013. private _directionOffset;
  68014. /**
  68015. * Gets a string describing the action executed by the current optimization
  68016. * @return description string
  68017. */
  68018. getDescription(): string;
  68019. /**
  68020. * Creates the HardwareScalingOptimization object
  68021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68022. * @param maximumScale defines the maximum scale to use (2 by default)
  68023. * @param step defines the step to use between two passes (0.5 by default)
  68024. */
  68025. constructor(
  68026. /**
  68027. * Defines the priority of this optimization (0 by default which means first in the list)
  68028. */
  68029. priority?: number,
  68030. /**
  68031. * Defines the maximum scale to use (2 by default)
  68032. */
  68033. maximumScale?: number,
  68034. /**
  68035. * Defines the step to use between two passes (0.5 by default)
  68036. */
  68037. step?: number);
  68038. /**
  68039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68040. * @param scene defines the current scene where to apply this optimization
  68041. * @param optimizer defines the current optimizer
  68042. * @returns true if everything that can be done was applied
  68043. */
  68044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68045. }
  68046. /**
  68047. * Defines an optimization used to remove shadows
  68048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68049. */
  68050. export class ShadowsOptimization extends SceneOptimization {
  68051. /**
  68052. * Gets a string describing the action executed by the current optimization
  68053. * @return description string
  68054. */
  68055. getDescription(): string;
  68056. /**
  68057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68058. * @param scene defines the current scene where to apply this optimization
  68059. * @param optimizer defines the current optimizer
  68060. * @returns true if everything that can be done was applied
  68061. */
  68062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68063. }
  68064. /**
  68065. * Defines an optimization used to turn post-processes off
  68066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68067. */
  68068. export class PostProcessesOptimization extends SceneOptimization {
  68069. /**
  68070. * Gets a string describing the action executed by the current optimization
  68071. * @return description string
  68072. */
  68073. getDescription(): string;
  68074. /**
  68075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68076. * @param scene defines the current scene where to apply this optimization
  68077. * @param optimizer defines the current optimizer
  68078. * @returns true if everything that can be done was applied
  68079. */
  68080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68081. }
  68082. /**
  68083. * Defines an optimization used to turn lens flares off
  68084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68085. */
  68086. export class LensFlaresOptimization extends SceneOptimization {
  68087. /**
  68088. * Gets a string describing the action executed by the current optimization
  68089. * @return description string
  68090. */
  68091. getDescription(): string;
  68092. /**
  68093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68094. * @param scene defines the current scene where to apply this optimization
  68095. * @param optimizer defines the current optimizer
  68096. * @returns true if everything that can be done was applied
  68097. */
  68098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68099. }
  68100. /**
  68101. * Defines an optimization based on user defined callback.
  68102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68103. */
  68104. export class CustomOptimization extends SceneOptimization {
  68105. /**
  68106. * Callback called to apply the custom optimization.
  68107. */
  68108. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68109. /**
  68110. * Callback called to get custom description
  68111. */
  68112. onGetDescription: () => string;
  68113. /**
  68114. * Gets a string describing the action executed by the current optimization
  68115. * @returns description string
  68116. */
  68117. getDescription(): string;
  68118. /**
  68119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68120. * @param scene defines the current scene where to apply this optimization
  68121. * @param optimizer defines the current optimizer
  68122. * @returns true if everything that can be done was applied
  68123. */
  68124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68125. }
  68126. /**
  68127. * Defines an optimization used to turn particles off
  68128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68129. */
  68130. export class ParticlesOptimization extends SceneOptimization {
  68131. /**
  68132. * Gets a string describing the action executed by the current optimization
  68133. * @return description string
  68134. */
  68135. getDescription(): string;
  68136. /**
  68137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68138. * @param scene defines the current scene where to apply this optimization
  68139. * @param optimizer defines the current optimizer
  68140. * @returns true if everything that can be done was applied
  68141. */
  68142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68143. }
  68144. /**
  68145. * Defines an optimization used to turn render targets off
  68146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68147. */
  68148. export class RenderTargetsOptimization extends SceneOptimization {
  68149. /**
  68150. * Gets a string describing the action executed by the current optimization
  68151. * @return description string
  68152. */
  68153. getDescription(): string;
  68154. /**
  68155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68156. * @param scene defines the current scene where to apply this optimization
  68157. * @param optimizer defines the current optimizer
  68158. * @returns true if everything that can be done was applied
  68159. */
  68160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68161. }
  68162. /**
  68163. * Defines an optimization used to merge meshes with compatible materials
  68164. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68165. */
  68166. export class MergeMeshesOptimization extends SceneOptimization {
  68167. private static _UpdateSelectionTree;
  68168. /**
  68169. * Gets or sets a boolean which defines if optimization octree has to be updated
  68170. */
  68171. static get UpdateSelectionTree(): boolean;
  68172. /**
  68173. * Gets or sets a boolean which defines if optimization octree has to be updated
  68174. */
  68175. static set UpdateSelectionTree(value: boolean);
  68176. /**
  68177. * Gets a string describing the action executed by the current optimization
  68178. * @return description string
  68179. */
  68180. getDescription(): string;
  68181. private _canBeMerged;
  68182. /**
  68183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68184. * @param scene defines the current scene where to apply this optimization
  68185. * @param optimizer defines the current optimizer
  68186. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68187. * @returns true if everything that can be done was applied
  68188. */
  68189. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68190. }
  68191. /**
  68192. * Defines a list of options used by SceneOptimizer
  68193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68194. */
  68195. export class SceneOptimizerOptions {
  68196. /**
  68197. * Defines the target frame rate to reach (60 by default)
  68198. */
  68199. targetFrameRate: number;
  68200. /**
  68201. * Defines the interval between two checkes (2000ms by default)
  68202. */
  68203. trackerDuration: number;
  68204. /**
  68205. * Gets the list of optimizations to apply
  68206. */
  68207. optimizations: SceneOptimization[];
  68208. /**
  68209. * Creates a new list of options used by SceneOptimizer
  68210. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68211. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68212. */
  68213. constructor(
  68214. /**
  68215. * Defines the target frame rate to reach (60 by default)
  68216. */
  68217. targetFrameRate?: number,
  68218. /**
  68219. * Defines the interval between two checkes (2000ms by default)
  68220. */
  68221. trackerDuration?: number);
  68222. /**
  68223. * Add a new optimization
  68224. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68225. * @returns the current SceneOptimizerOptions
  68226. */
  68227. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68228. /**
  68229. * Add a new custom optimization
  68230. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68231. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68233. * @returns the current SceneOptimizerOptions
  68234. */
  68235. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68236. /**
  68237. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68238. * @param targetFrameRate defines the target frame rate (60 by default)
  68239. * @returns a SceneOptimizerOptions object
  68240. */
  68241. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68242. /**
  68243. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68244. * @param targetFrameRate defines the target frame rate (60 by default)
  68245. * @returns a SceneOptimizerOptions object
  68246. */
  68247. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68248. /**
  68249. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68250. * @param targetFrameRate defines the target frame rate (60 by default)
  68251. * @returns a SceneOptimizerOptions object
  68252. */
  68253. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68254. }
  68255. /**
  68256. * Class used to run optimizations in order to reach a target frame rate
  68257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68258. */
  68259. export class SceneOptimizer implements IDisposable {
  68260. private _isRunning;
  68261. private _options;
  68262. private _scene;
  68263. private _currentPriorityLevel;
  68264. private _targetFrameRate;
  68265. private _trackerDuration;
  68266. private _currentFrameRate;
  68267. private _sceneDisposeObserver;
  68268. private _improvementMode;
  68269. /**
  68270. * Defines an observable called when the optimizer reaches the target frame rate
  68271. */
  68272. onSuccessObservable: Observable<SceneOptimizer>;
  68273. /**
  68274. * Defines an observable called when the optimizer enables an optimization
  68275. */
  68276. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68277. /**
  68278. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68279. */
  68280. onFailureObservable: Observable<SceneOptimizer>;
  68281. /**
  68282. * Gets a boolean indicating if the optimizer is in improvement mode
  68283. */
  68284. get isInImprovementMode(): boolean;
  68285. /**
  68286. * Gets the current priority level (0 at start)
  68287. */
  68288. get currentPriorityLevel(): number;
  68289. /**
  68290. * Gets the current frame rate checked by the SceneOptimizer
  68291. */
  68292. get currentFrameRate(): number;
  68293. /**
  68294. * Gets or sets the current target frame rate (60 by default)
  68295. */
  68296. get targetFrameRate(): number;
  68297. /**
  68298. * Gets or sets the current target frame rate (60 by default)
  68299. */
  68300. set targetFrameRate(value: number);
  68301. /**
  68302. * Gets or sets the current interval between two checks (every 2000ms by default)
  68303. */
  68304. get trackerDuration(): number;
  68305. /**
  68306. * Gets or sets the current interval between two checks (every 2000ms by default)
  68307. */
  68308. set trackerDuration(value: number);
  68309. /**
  68310. * Gets the list of active optimizations
  68311. */
  68312. get optimizations(): SceneOptimization[];
  68313. /**
  68314. * Creates a new SceneOptimizer
  68315. * @param scene defines the scene to work on
  68316. * @param options defines the options to use with the SceneOptimizer
  68317. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68318. * @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)
  68319. */
  68320. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68321. /**
  68322. * Stops the current optimizer
  68323. */
  68324. stop(): void;
  68325. /**
  68326. * Reset the optimizer to initial step (current priority level = 0)
  68327. */
  68328. reset(): void;
  68329. /**
  68330. * Start the optimizer. By default it will try to reach a specific framerate
  68331. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68332. */
  68333. start(): void;
  68334. private _checkCurrentState;
  68335. /**
  68336. * Release all resources
  68337. */
  68338. dispose(): void;
  68339. /**
  68340. * Helper function to create a SceneOptimizer with one single line of code
  68341. * @param scene defines the scene to work on
  68342. * @param options defines the options to use with the SceneOptimizer
  68343. * @param onSuccess defines a callback to call on success
  68344. * @param onFailure defines a callback to call on failure
  68345. * @returns the new SceneOptimizer object
  68346. */
  68347. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68348. }
  68349. }
  68350. declare module BABYLON {
  68351. /**
  68352. * Class used to serialize a scene into a string
  68353. */
  68354. export class SceneSerializer {
  68355. /**
  68356. * Clear cache used by a previous serialization
  68357. */
  68358. static ClearCache(): void;
  68359. /**
  68360. * Serialize a scene into a JSON compatible object
  68361. * @param scene defines the scene to serialize
  68362. * @returns a JSON compatible object
  68363. */
  68364. static Serialize(scene: Scene): any;
  68365. /**
  68366. * Serialize a mesh into a JSON compatible object
  68367. * @param toSerialize defines the mesh to serialize
  68368. * @param withParents defines if parents must be serialized as well
  68369. * @param withChildren defines if children must be serialized as well
  68370. * @returns a JSON compatible object
  68371. */
  68372. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * Class used to host texture specific utilities
  68378. */
  68379. export class TextureTools {
  68380. /**
  68381. * Uses the GPU to create a copy texture rescaled at a given size
  68382. * @param texture Texture to copy from
  68383. * @param width defines the desired width
  68384. * @param height defines the desired height
  68385. * @param useBilinearMode defines if bilinear mode has to be used
  68386. * @return the generated texture
  68387. */
  68388. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * This represents the different options available for the video capture.
  68394. */
  68395. export interface VideoRecorderOptions {
  68396. /** Defines the mime type of the video. */
  68397. mimeType: string;
  68398. /** Defines the FPS the video should be recorded at. */
  68399. fps: number;
  68400. /** Defines the chunk size for the recording data. */
  68401. recordChunckSize: number;
  68402. /** The audio tracks to attach to the recording. */
  68403. audioTracks?: MediaStreamTrack[];
  68404. }
  68405. /**
  68406. * This can help with recording videos from BabylonJS.
  68407. * This is based on the available WebRTC functionalities of the browser.
  68408. *
  68409. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68410. */
  68411. export class VideoRecorder {
  68412. private static readonly _defaultOptions;
  68413. /**
  68414. * Returns whether or not the VideoRecorder is available in your browser.
  68415. * @param engine Defines the Babylon Engine.
  68416. * @returns true if supported otherwise false.
  68417. */
  68418. static IsSupported(engine: Engine): boolean;
  68419. private readonly _options;
  68420. private _canvas;
  68421. private _mediaRecorder;
  68422. private _recordedChunks;
  68423. private _fileName;
  68424. private _resolve;
  68425. private _reject;
  68426. /**
  68427. * True when a recording is already in progress.
  68428. */
  68429. get isRecording(): boolean;
  68430. /**
  68431. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68432. * @param engine Defines the BabylonJS Engine you wish to record.
  68433. * @param options Defines options that can be used to customize the capture.
  68434. */
  68435. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68436. /**
  68437. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68438. */
  68439. stopRecording(): void;
  68440. /**
  68441. * Starts recording the canvas for a max duration specified in parameters.
  68442. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68443. * If null no automatic download will start and you can rely on the promise to get the data back.
  68444. * @param maxDuration Defines the maximum recording time in seconds.
  68445. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68446. * @return A promise callback at the end of the recording with the video data in Blob.
  68447. */
  68448. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68449. /**
  68450. * Releases internal resources used during the recording.
  68451. */
  68452. dispose(): void;
  68453. private _handleDataAvailable;
  68454. private _handleError;
  68455. private _handleStop;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /**
  68460. * Class containing a set of static utilities functions for screenshots
  68461. */
  68462. export class ScreenshotTools {
  68463. /**
  68464. * Captures a screenshot of the current rendering
  68465. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68466. * @param engine defines the rendering engine
  68467. * @param camera defines the source camera
  68468. * @param size This parameter can be set to a single number or to an object with the
  68469. * following (optional) properties: precision, width, height. If a single number is passed,
  68470. * it will be used for both width and height. If an object is passed, the screenshot size
  68471. * will be derived from the parameters. The precision property is a multiplier allowing
  68472. * rendering at a higher or lower resolution
  68473. * @param successCallback defines the callback receives a single parameter which contains the
  68474. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68475. * src parameter of an <img> to display it
  68476. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68477. * Check your browser for supported MIME types
  68478. */
  68479. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  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 mimeType defines the MIME type of the screenshot image (default: image/png).
  68491. * Check your browser for supported MIME types
  68492. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68493. * to the src parameter of an <img> to display it
  68494. */
  68495. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68496. /**
  68497. * Generates an image screenshot from the specified camera.
  68498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68499. * @param engine The engine to use for rendering
  68500. * @param camera The camera to use for rendering
  68501. * @param size This parameter can be set to a single number or to an object with the
  68502. * following (optional) properties: precision, width, height. If a single number is passed,
  68503. * it will be used for both width and height. If an object is passed, the screenshot size
  68504. * will be derived from the parameters. The precision property is a multiplier allowing
  68505. * rendering at a higher or lower resolution
  68506. * @param successCallback The callback receives a single parameter which contains the
  68507. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68508. * src parameter of an <img> to display it
  68509. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68510. * Check your browser for supported MIME types
  68511. * @param samples Texture samples (default: 1)
  68512. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68513. * @param fileName A name for for the downloaded file.
  68514. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68515. */
  68516. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68517. /**
  68518. * Generates an image screenshot from the specified camera.
  68519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68520. * @param engine The engine to use for rendering
  68521. * @param camera The camera to use for rendering
  68522. * @param size This parameter can be set to a single number or to an object with the
  68523. * following (optional) properties: precision, width, height. If a single number is passed,
  68524. * it will be used for both width and height. If an object is passed, the screenshot size
  68525. * will be derived from the parameters. The precision property is a multiplier allowing
  68526. * rendering at a higher or lower resolution
  68527. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68528. * Check your browser for supported MIME types
  68529. * @param samples Texture samples (default: 1)
  68530. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68531. * @param fileName A name for for the downloaded file.
  68532. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68533. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68534. * to the src parameter of an <img> to display it
  68535. */
  68536. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68537. /**
  68538. * Gets height and width for screenshot size
  68539. * @private
  68540. */
  68541. private static _getScreenshotSize;
  68542. }
  68543. }
  68544. declare module BABYLON {
  68545. /**
  68546. * Interface for a data buffer
  68547. */
  68548. export interface IDataBuffer {
  68549. /**
  68550. * Reads bytes from the data buffer.
  68551. * @param byteOffset The byte offset to read
  68552. * @param byteLength The byte length to read
  68553. * @returns A promise that resolves when the bytes are read
  68554. */
  68555. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68556. /**
  68557. * The byte length of the buffer.
  68558. */
  68559. readonly byteLength: number;
  68560. }
  68561. /**
  68562. * Utility class for reading from a data buffer
  68563. */
  68564. export class DataReader {
  68565. /**
  68566. * The data buffer associated with this data reader.
  68567. */
  68568. readonly buffer: IDataBuffer;
  68569. /**
  68570. * The current byte offset from the beginning of the data buffer.
  68571. */
  68572. byteOffset: number;
  68573. private _dataView;
  68574. private _dataByteOffset;
  68575. /**
  68576. * Constructor
  68577. * @param buffer The buffer to read
  68578. */
  68579. constructor(buffer: IDataBuffer);
  68580. /**
  68581. * Loads the given byte length.
  68582. * @param byteLength The byte length to load
  68583. * @returns A promise that resolves when the load is complete
  68584. */
  68585. loadAsync(byteLength: number): Promise<void>;
  68586. /**
  68587. * Read a unsigned 32-bit integer from the currently loaded data range.
  68588. * @returns The 32-bit integer read
  68589. */
  68590. readUint32(): number;
  68591. /**
  68592. * Read a byte array from the currently loaded data range.
  68593. * @param byteLength The byte length to read
  68594. * @returns The byte array read
  68595. */
  68596. readUint8Array(byteLength: number): Uint8Array;
  68597. /**
  68598. * Read a string from the currently loaded data range.
  68599. * @param byteLength The byte length to read
  68600. * @returns The string read
  68601. */
  68602. readString(byteLength: number): string;
  68603. /**
  68604. * Skips the given byte length the currently loaded data range.
  68605. * @param byteLength The byte length to skip
  68606. */
  68607. skipBytes(byteLength: number): void;
  68608. }
  68609. }
  68610. declare module BABYLON {
  68611. /**
  68612. * Options used for hit testing
  68613. */
  68614. export interface IWebXRHitTestOptions {
  68615. /**
  68616. * Only test when user interacted with the scene. Default - hit test every frame
  68617. */
  68618. testOnPointerDownOnly?: boolean;
  68619. /**
  68620. * The node to use to transform the local results to world coordinates
  68621. */
  68622. worldParentNode?: TransformNode;
  68623. }
  68624. /**
  68625. * Interface defining the babylon result of raycasting/hit-test
  68626. */
  68627. export interface IWebXRHitResult {
  68628. /**
  68629. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68630. */
  68631. transformationMatrix: Matrix;
  68632. /**
  68633. * The native hit test result
  68634. */
  68635. xrHitResult: XRHitResult;
  68636. }
  68637. /**
  68638. * The currently-working hit-test module.
  68639. * Hit test (or Ray-casting) is used to interact with the real world.
  68640. * For further information read here - https://github.com/immersive-web/hit-test
  68641. */
  68642. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68643. /**
  68644. * options to use when constructing this feature
  68645. */
  68646. readonly options: IWebXRHitTestOptions;
  68647. private _direction;
  68648. private _mat;
  68649. private _onSelectEnabled;
  68650. private _origin;
  68651. /**
  68652. * The module's name
  68653. */
  68654. static readonly Name: string;
  68655. /**
  68656. * The (Babylon) version of this module.
  68657. * This is an integer representing the implementation version.
  68658. * This number does not correspond to the WebXR specs version
  68659. */
  68660. static readonly Version: number;
  68661. /**
  68662. * Populated with the last native XR Hit Results
  68663. */
  68664. lastNativeXRHitResults: XRHitResult[];
  68665. /**
  68666. * Triggered when new babylon (transformed) hit test results are available
  68667. */
  68668. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68669. /**
  68670. * Creates a new instance of the (legacy version) hit test feature
  68671. * @param _xrSessionManager an instance of WebXRSessionManager
  68672. * @param options options to use when constructing this feature
  68673. */
  68674. constructor(_xrSessionManager: WebXRSessionManager,
  68675. /**
  68676. * options to use when constructing this feature
  68677. */
  68678. options?: IWebXRHitTestOptions);
  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 ray-casting
  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. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68691. * @param event the (select) event to use to select with
  68692. * @param referenceSpace the reference space to use for this hit test
  68693. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68694. */
  68695. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68696. /**
  68697. * attach this feature
  68698. * Will usually be called by the features manager
  68699. *
  68700. * @returns true if successful.
  68701. */
  68702. attach(): boolean;
  68703. /**
  68704. * detach this feature.
  68705. * Will usually be called by the features manager
  68706. *
  68707. * @returns true if successful.
  68708. */
  68709. detach(): boolean;
  68710. /**
  68711. * Dispose this feature and all of the resources attached
  68712. */
  68713. dispose(): void;
  68714. protected _onXRFrame(frame: XRFrame): void;
  68715. private _onHitTestResults;
  68716. private _onSelect;
  68717. }
  68718. }
  68719. declare module BABYLON {
  68720. /**
  68721. * Options used in the plane detector module
  68722. */
  68723. export interface IWebXRPlaneDetectorOptions {
  68724. /**
  68725. * The node to use to transform the local results to world coordinates
  68726. */
  68727. worldParentNode?: TransformNode;
  68728. }
  68729. /**
  68730. * A babylon interface for a WebXR plane.
  68731. * A Plane is actually a polygon, built from N points in space
  68732. *
  68733. * Supported in chrome 79, not supported in canary 81 ATM
  68734. */
  68735. export interface IWebXRPlane {
  68736. /**
  68737. * a babylon-assigned ID for this polygon
  68738. */
  68739. id: number;
  68740. /**
  68741. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68742. */
  68743. polygonDefinition: Array<Vector3>;
  68744. /**
  68745. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68746. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68747. */
  68748. transformationMatrix: Matrix;
  68749. /**
  68750. * the native xr-plane object
  68751. */
  68752. xrPlane: XRPlane;
  68753. }
  68754. /**
  68755. * The plane detector is used to detect planes in the real world when in AR
  68756. * For more information see https://github.com/immersive-web/real-world-geometry/
  68757. */
  68758. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68759. private _options;
  68760. private _detectedPlanes;
  68761. private _enabled;
  68762. private _lastFrameDetected;
  68763. /**
  68764. * The module's name
  68765. */
  68766. static readonly Name: string;
  68767. /**
  68768. * The (Babylon) version of this module.
  68769. * This is an integer representing the implementation version.
  68770. * This number does not correspond to the WebXR specs version
  68771. */
  68772. static readonly Version: number;
  68773. /**
  68774. * Observers registered here will be executed when a new plane was added to the session
  68775. */
  68776. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68777. /**
  68778. * Observers registered here will be executed when a plane is no longer detected in the session
  68779. */
  68780. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68781. /**
  68782. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68783. * This can execute N times every frame
  68784. */
  68785. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68786. /**
  68787. * construct a new Plane Detector
  68788. * @param _xrSessionManager an instance of xr Session manager
  68789. * @param _options configuration to use when constructing this feature
  68790. */
  68791. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68792. /**
  68793. * Dispose this feature and all of the resources attached
  68794. */
  68795. dispose(): void;
  68796. protected _onXRFrame(frame: XRFrame): void;
  68797. private _init;
  68798. private _updatePlaneWithXRPlane;
  68799. /**
  68800. * avoiding using Array.find for global support.
  68801. * @param xrPlane the plane to find in the array
  68802. */
  68803. private findIndexInPlaneArray;
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /**
  68808. * Configuration options of the anchor system
  68809. */
  68810. export interface IWebXRAnchorSystemOptions {
  68811. /**
  68812. * Should a new anchor be added every time a select event is triggered
  68813. */
  68814. addAnchorOnSelect?: boolean;
  68815. /**
  68816. * should the anchor system use plane detection.
  68817. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68818. */
  68819. usePlaneDetection?: boolean;
  68820. /**
  68821. * a node that will be used to convert local to world coordinates
  68822. */
  68823. worldParentNode?: TransformNode;
  68824. }
  68825. /**
  68826. * A babylon container for an XR Anchor
  68827. */
  68828. export interface IWebXRAnchor {
  68829. /**
  68830. * A babylon-assigned ID for this anchor
  68831. */
  68832. id: number;
  68833. /**
  68834. * Transformation matrix to apply to an object attached to this anchor
  68835. */
  68836. transformationMatrix: Matrix;
  68837. /**
  68838. * The native anchor object
  68839. */
  68840. xrAnchor: XRAnchor;
  68841. }
  68842. /**
  68843. * An implementation of the anchor system of WebXR.
  68844. * Note that the current documented implementation is not available in any browser. Future implementations
  68845. * will use the frame to create an anchor and not the session or a detected plane
  68846. * For further information see https://github.com/immersive-web/anchors/
  68847. */
  68848. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68849. private _options;
  68850. private _enabled;
  68851. private _hitTestModule;
  68852. private _lastFrameDetected;
  68853. private _onSelect;
  68854. private _planeDetector;
  68855. private _trackedAnchors;
  68856. /**
  68857. * The module's name
  68858. */
  68859. static readonly Name: string;
  68860. /**
  68861. * The (Babylon) version of this module.
  68862. * This is an integer representing the implementation version.
  68863. * This number does not correspond to the WebXR specs version
  68864. */
  68865. static readonly Version: number;
  68866. /**
  68867. * Observers registered here will be executed when a new anchor was added to the session
  68868. */
  68869. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68870. /**
  68871. * Observers registered here will be executed when an anchor was removed from the session
  68872. */
  68873. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68874. /**
  68875. * Observers registered here will be executed when an existing anchor updates
  68876. * This can execute N times every frame
  68877. */
  68878. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68879. /**
  68880. * constructs a new anchor system
  68881. * @param _xrSessionManager an instance of WebXRSessionManager
  68882. * @param _options configuration object for this feature
  68883. */
  68884. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68885. /**
  68886. * Add anchor at a specific XR point.
  68887. *
  68888. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68889. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68890. * @returns a promise the fulfills when the anchor was created
  68891. */
  68892. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68893. /**
  68894. * attach this feature
  68895. * Will usually be called by the features manager
  68896. *
  68897. * @returns true if successful.
  68898. */
  68899. attach(): boolean;
  68900. /**
  68901. * detach this feature.
  68902. * Will usually be called by the features manager
  68903. *
  68904. * @returns true if successful.
  68905. */
  68906. detach(): boolean;
  68907. /**
  68908. * Dispose this feature and all of the resources attached
  68909. */
  68910. dispose(): void;
  68911. /**
  68912. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68913. * @param hitTestModule the hit-test module to use.
  68914. */
  68915. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68916. /**
  68917. * set the plane detector to use in order to create anchors from frames
  68918. * @param planeDetector the plane-detector module to use
  68919. * @param enable enable plane-anchors. default is true
  68920. */
  68921. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68922. protected _onXRFrame(frame: XRFrame): void;
  68923. /**
  68924. * avoiding using Array.find for global support.
  68925. * @param xrAnchor the plane to find in the array
  68926. */
  68927. private _findIndexInAnchorArray;
  68928. private _updateAnchorWithXRFrame;
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * Options interface for the background remover plugin
  68934. */
  68935. export interface IWebXRBackgroundRemoverOptions {
  68936. /**
  68937. * Further background meshes to disable when entering AR
  68938. */
  68939. backgroundMeshes?: AbstractMesh[];
  68940. /**
  68941. * flags to configure the removal of the environment helper.
  68942. * If not set, the entire background will be removed. If set, flags should be set as well.
  68943. */
  68944. environmentHelperRemovalFlags?: {
  68945. /**
  68946. * Should the skybox be removed (default false)
  68947. */
  68948. skyBox?: boolean;
  68949. /**
  68950. * Should the ground be removed (default false)
  68951. */
  68952. ground?: boolean;
  68953. };
  68954. /**
  68955. * don't disable the environment helper
  68956. */
  68957. ignoreEnvironmentHelper?: boolean;
  68958. }
  68959. /**
  68960. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68961. */
  68962. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68963. /**
  68964. * read-only options to be used in this module
  68965. */
  68966. readonly options: IWebXRBackgroundRemoverOptions;
  68967. /**
  68968. * The module's name
  68969. */
  68970. static readonly Name: string;
  68971. /**
  68972. * The (Babylon) version of this module.
  68973. * This is an integer representing the implementation version.
  68974. * This number does not correspond to the WebXR specs version
  68975. */
  68976. static readonly Version: number;
  68977. /**
  68978. * registered observers will be triggered when the background state changes
  68979. */
  68980. onBackgroundStateChangedObservable: Observable<boolean>;
  68981. /**
  68982. * constructs a new background remover module
  68983. * @param _xrSessionManager the session manager for this module
  68984. * @param options read-only options to be used in this module
  68985. */
  68986. constructor(_xrSessionManager: WebXRSessionManager,
  68987. /**
  68988. * read-only options to be used in this module
  68989. */
  68990. options?: IWebXRBackgroundRemoverOptions);
  68991. /**
  68992. * attach this feature
  68993. * Will usually be called by the features manager
  68994. *
  68995. * @returns true if successful.
  68996. */
  68997. attach(): boolean;
  68998. /**
  68999. * detach this feature.
  69000. * Will usually be called by the features manager
  69001. *
  69002. * @returns true if successful.
  69003. */
  69004. detach(): boolean;
  69005. /**
  69006. * Dispose this feature and all of the resources attached
  69007. */
  69008. dispose(): void;
  69009. protected _onXRFrame(_xrFrame: XRFrame): void;
  69010. private _setBackgroundState;
  69011. }
  69012. }
  69013. declare module BABYLON {
  69014. /**
  69015. * Options for the controller physics feature
  69016. */
  69017. export class IWebXRControllerPhysicsOptions {
  69018. /**
  69019. * Should the headset get its own impostor
  69020. */
  69021. enableHeadsetImpostor?: boolean;
  69022. /**
  69023. * Optional parameters for the headset impostor
  69024. */
  69025. headsetImpostorParams?: {
  69026. /**
  69027. * The type of impostor to create. Default is sphere
  69028. */
  69029. impostorType: number;
  69030. /**
  69031. * the size of the impostor. Defaults to 10cm
  69032. */
  69033. impostorSize?: number | {
  69034. width: number;
  69035. height: number;
  69036. depth: number;
  69037. };
  69038. /**
  69039. * Friction definitions
  69040. */
  69041. friction?: number;
  69042. /**
  69043. * Restitution
  69044. */
  69045. restitution?: number;
  69046. };
  69047. /**
  69048. * The physics properties of the future impostors
  69049. */
  69050. physicsProperties?: {
  69051. /**
  69052. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69053. * Note that this requires a physics engine that supports mesh impostors!
  69054. */
  69055. useControllerMesh?: boolean;
  69056. /**
  69057. * The type of impostor to create. Default is sphere
  69058. */
  69059. impostorType?: number;
  69060. /**
  69061. * the size of the impostor. Defaults to 10cm
  69062. */
  69063. impostorSize?: number | {
  69064. width: number;
  69065. height: number;
  69066. depth: number;
  69067. };
  69068. /**
  69069. * Friction definitions
  69070. */
  69071. friction?: number;
  69072. /**
  69073. * Restitution
  69074. */
  69075. restitution?: number;
  69076. };
  69077. /**
  69078. * the xr input to use with this pointer selection
  69079. */
  69080. xrInput: WebXRInput;
  69081. }
  69082. /**
  69083. * Add physics impostor to your webxr controllers,
  69084. * including naive calculation of their linear and angular velocity
  69085. */
  69086. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69087. private readonly _options;
  69088. private _attachController;
  69089. private _controllers;
  69090. private _debugMode;
  69091. private _delta;
  69092. private _headsetImpostor?;
  69093. private _headsetMesh?;
  69094. private _lastTimestamp;
  69095. private _tmpQuaternion;
  69096. private _tmpVector;
  69097. /**
  69098. * The module's name
  69099. */
  69100. static readonly Name: string;
  69101. /**
  69102. * The (Babylon) version of this module.
  69103. * This is an integer representing the implementation version.
  69104. * This number does not correspond to the webxr specs version
  69105. */
  69106. static readonly Version: number;
  69107. /**
  69108. * Construct a new Controller Physics Feature
  69109. * @param _xrSessionManager the corresponding xr session manager
  69110. * @param _options options to create this feature with
  69111. */
  69112. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69113. /**
  69114. * @hidden
  69115. * enable debugging - will show console outputs and the impostor mesh
  69116. */
  69117. _enablePhysicsDebug(): void;
  69118. /**
  69119. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69120. * @param xrController the controller to add
  69121. */
  69122. addController(xrController: WebXRInputSource): void;
  69123. /**
  69124. * attach this feature
  69125. * Will usually be called by the features manager
  69126. *
  69127. * @returns true if successful.
  69128. */
  69129. attach(): boolean;
  69130. /**
  69131. * detach this feature.
  69132. * Will usually be called by the features manager
  69133. *
  69134. * @returns true if successful.
  69135. */
  69136. detach(): boolean;
  69137. /**
  69138. * Get the headset impostor, if enabled
  69139. * @returns the impostor
  69140. */
  69141. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69142. /**
  69143. * Get the physics impostor of a specific controller.
  69144. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69145. * @param controller the controller or the controller id of which to get the impostor
  69146. * @returns the impostor or null
  69147. */
  69148. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69149. /**
  69150. * Update the physics properties provided in the constructor
  69151. * @param newProperties the new properties object
  69152. */
  69153. setPhysicsProperties(newProperties: {
  69154. impostorType?: number;
  69155. impostorSize?: number | {
  69156. width: number;
  69157. height: number;
  69158. depth: number;
  69159. };
  69160. friction?: number;
  69161. restitution?: number;
  69162. }): void;
  69163. protected _onXRFrame(_xrFrame: any): void;
  69164. private _detachController;
  69165. }
  69166. }
  69167. declare module BABYLON {
  69168. /**
  69169. * The motion controller class for all microsoft mixed reality controllers
  69170. */
  69171. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69172. protected readonly _mapping: {
  69173. defaultButton: {
  69174. "valueNodeName": string;
  69175. "unpressedNodeName": string;
  69176. "pressedNodeName": string;
  69177. };
  69178. defaultAxis: {
  69179. "valueNodeName": string;
  69180. "minNodeName": string;
  69181. "maxNodeName": string;
  69182. };
  69183. buttons: {
  69184. "xr-standard-trigger": {
  69185. "rootNodeName": string;
  69186. "componentProperty": string;
  69187. "states": string[];
  69188. };
  69189. "xr-standard-squeeze": {
  69190. "rootNodeName": string;
  69191. "componentProperty": string;
  69192. "states": string[];
  69193. };
  69194. "xr-standard-touchpad": {
  69195. "rootNodeName": string;
  69196. "labelAnchorNodeName": string;
  69197. "touchPointNodeName": string;
  69198. };
  69199. "xr-standard-thumbstick": {
  69200. "rootNodeName": string;
  69201. "componentProperty": string;
  69202. "states": string[];
  69203. };
  69204. };
  69205. axes: {
  69206. "xr-standard-touchpad": {
  69207. "x-axis": {
  69208. "rootNodeName": string;
  69209. };
  69210. "y-axis": {
  69211. "rootNodeName": string;
  69212. };
  69213. };
  69214. "xr-standard-thumbstick": {
  69215. "x-axis": {
  69216. "rootNodeName": string;
  69217. };
  69218. "y-axis": {
  69219. "rootNodeName": string;
  69220. };
  69221. };
  69222. };
  69223. };
  69224. /**
  69225. * The base url used to load the left and right controller models
  69226. */
  69227. static MODEL_BASE_URL: string;
  69228. /**
  69229. * The name of the left controller model file
  69230. */
  69231. static MODEL_LEFT_FILENAME: string;
  69232. /**
  69233. * The name of the right controller model file
  69234. */
  69235. static MODEL_RIGHT_FILENAME: string;
  69236. profileId: string;
  69237. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69238. protected _getFilenameAndPath(): {
  69239. filename: string;
  69240. path: string;
  69241. };
  69242. protected _getModelLoadingConstraints(): boolean;
  69243. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69244. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69245. protected _updateModel(): void;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /**
  69250. * The motion controller class for oculus touch (quest, rift).
  69251. * This class supports legacy mapping as well the standard xr mapping
  69252. */
  69253. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69254. private _forceLegacyControllers;
  69255. private _modelRootNode;
  69256. /**
  69257. * The base url used to load the left and right controller models
  69258. */
  69259. static MODEL_BASE_URL: string;
  69260. /**
  69261. * The name of the left controller model file
  69262. */
  69263. static MODEL_LEFT_FILENAME: string;
  69264. /**
  69265. * The name of the right controller model file
  69266. */
  69267. static MODEL_RIGHT_FILENAME: string;
  69268. /**
  69269. * Base Url for the Quest controller model.
  69270. */
  69271. static QUEST_MODEL_BASE_URL: string;
  69272. profileId: string;
  69273. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69274. protected _getFilenameAndPath(): {
  69275. filename: string;
  69276. path: string;
  69277. };
  69278. protected _getModelLoadingConstraints(): boolean;
  69279. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69280. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69281. protected _updateModel(): void;
  69282. /**
  69283. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69284. * between the touch and touch 2.
  69285. */
  69286. private _isQuest;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * The motion controller class for the standard HTC-Vive controllers
  69292. */
  69293. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69294. private _modelRootNode;
  69295. /**
  69296. * The base url used to load the left and right controller models
  69297. */
  69298. static MODEL_BASE_URL: string;
  69299. /**
  69300. * File name for the controller model.
  69301. */
  69302. static MODEL_FILENAME: string;
  69303. profileId: string;
  69304. /**
  69305. * Create a new Vive motion controller object
  69306. * @param scene the scene to use to create this controller
  69307. * @param gamepadObject the corresponding gamepad object
  69308. * @param handness the handness of the controller
  69309. */
  69310. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69311. protected _getFilenameAndPath(): {
  69312. filename: string;
  69313. path: string;
  69314. };
  69315. protected _getModelLoadingConstraints(): boolean;
  69316. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69317. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69318. protected _updateModel(): void;
  69319. }
  69320. }
  69321. declare module BABYLON {
  69322. /**
  69323. * A cursor which tracks a point on a path
  69324. */
  69325. export class PathCursor {
  69326. private path;
  69327. /**
  69328. * Stores path cursor callbacks for when an onchange event is triggered
  69329. */
  69330. private _onchange;
  69331. /**
  69332. * The value of the path cursor
  69333. */
  69334. value: number;
  69335. /**
  69336. * The animation array of the path cursor
  69337. */
  69338. animations: Animation[];
  69339. /**
  69340. * Initializes the path cursor
  69341. * @param path The path to track
  69342. */
  69343. constructor(path: Path2);
  69344. /**
  69345. * Gets the cursor point on the path
  69346. * @returns A point on the path cursor at the cursor location
  69347. */
  69348. getPoint(): Vector3;
  69349. /**
  69350. * Moves the cursor ahead by the step amount
  69351. * @param step The amount to move the cursor forward
  69352. * @returns This path cursor
  69353. */
  69354. moveAhead(step?: number): PathCursor;
  69355. /**
  69356. * Moves the cursor behind by the step amount
  69357. * @param step The amount to move the cursor back
  69358. * @returns This path cursor
  69359. */
  69360. moveBack(step?: number): PathCursor;
  69361. /**
  69362. * Moves the cursor by the step amount
  69363. * If the step amount is greater than one, an exception is thrown
  69364. * @param step The amount to move the cursor
  69365. * @returns This path cursor
  69366. */
  69367. move(step: number): PathCursor;
  69368. /**
  69369. * Ensures that the value is limited between zero and one
  69370. * @returns This path cursor
  69371. */
  69372. private ensureLimits;
  69373. /**
  69374. * Runs onchange callbacks on change (used by the animation engine)
  69375. * @returns This path cursor
  69376. */
  69377. private raiseOnChange;
  69378. /**
  69379. * Executes a function on change
  69380. * @param f A path cursor onchange callback
  69381. * @returns This path cursor
  69382. */
  69383. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69384. }
  69385. }
  69386. declare module BABYLON {
  69387. /** @hidden */
  69388. export var blurPixelShader: {
  69389. name: string;
  69390. shader: string;
  69391. };
  69392. }
  69393. declare module BABYLON {
  69394. /** @hidden */
  69395. export var pointCloudVertexDeclaration: {
  69396. name: string;
  69397. shader: string;
  69398. };
  69399. }
  69400. // Mixins
  69401. interface Window {
  69402. mozIndexedDB: IDBFactory;
  69403. webkitIndexedDB: IDBFactory;
  69404. msIndexedDB: IDBFactory;
  69405. webkitURL: typeof URL;
  69406. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69407. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69408. WebGLRenderingContext: WebGLRenderingContext;
  69409. MSGesture: MSGesture;
  69410. CANNON: any;
  69411. AudioContext: AudioContext;
  69412. webkitAudioContext: AudioContext;
  69413. PointerEvent: any;
  69414. Math: Math;
  69415. Uint8Array: Uint8ArrayConstructor;
  69416. Float32Array: Float32ArrayConstructor;
  69417. mozURL: typeof URL;
  69418. msURL: typeof URL;
  69419. VRFrameData: any; // WebVR, from specs 1.1
  69420. DracoDecoderModule: any;
  69421. setImmediate(handler: (...args: any[]) => void): number;
  69422. }
  69423. interface HTMLCanvasElement {
  69424. requestPointerLock(): void;
  69425. msRequestPointerLock?(): void;
  69426. mozRequestPointerLock?(): void;
  69427. webkitRequestPointerLock?(): void;
  69428. /** Track wether a record is in progress */
  69429. isRecording: boolean;
  69430. /** Capture Stream method defined by some browsers */
  69431. captureStream(fps?: number): MediaStream;
  69432. }
  69433. interface CanvasRenderingContext2D {
  69434. msImageSmoothingEnabled: boolean;
  69435. }
  69436. interface MouseEvent {
  69437. mozMovementX: number;
  69438. mozMovementY: number;
  69439. webkitMovementX: number;
  69440. webkitMovementY: number;
  69441. msMovementX: number;
  69442. msMovementY: number;
  69443. }
  69444. interface Navigator {
  69445. mozGetVRDevices: (any: any) => any;
  69446. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69447. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69448. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69449. webkitGetGamepads(): Gamepad[];
  69450. msGetGamepads(): Gamepad[];
  69451. webkitGamepads(): Gamepad[];
  69452. }
  69453. interface HTMLVideoElement {
  69454. mozSrcObject: any;
  69455. }
  69456. interface Math {
  69457. fround(x: number): number;
  69458. imul(a: number, b: number): number;
  69459. }
  69460. interface WebGLRenderingContext {
  69461. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69462. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69463. vertexAttribDivisor(index: number, divisor: number): void;
  69464. createVertexArray(): any;
  69465. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69466. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69467. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69468. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69469. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69470. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69471. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69472. // Queries
  69473. createQuery(): WebGLQuery;
  69474. deleteQuery(query: WebGLQuery): void;
  69475. beginQuery(target: number, query: WebGLQuery): void;
  69476. endQuery(target: number): void;
  69477. getQueryParameter(query: WebGLQuery, pname: number): any;
  69478. getQuery(target: number, pname: number): any;
  69479. MAX_SAMPLES: number;
  69480. RGBA8: number;
  69481. READ_FRAMEBUFFER: number;
  69482. DRAW_FRAMEBUFFER: number;
  69483. UNIFORM_BUFFER: number;
  69484. HALF_FLOAT_OES: number;
  69485. RGBA16F: number;
  69486. RGBA32F: number;
  69487. R32F: number;
  69488. RG32F: number;
  69489. RGB32F: number;
  69490. R16F: number;
  69491. RG16F: number;
  69492. RGB16F: number;
  69493. RED: number;
  69494. RG: number;
  69495. R8: number;
  69496. RG8: number;
  69497. UNSIGNED_INT_24_8: number;
  69498. DEPTH24_STENCIL8: number;
  69499. MIN: number;
  69500. MAX: number;
  69501. /* Multiple Render Targets */
  69502. drawBuffers(buffers: number[]): void;
  69503. readBuffer(src: number): void;
  69504. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69505. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69506. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69507. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69508. // Occlusion Query
  69509. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69510. ANY_SAMPLES_PASSED: number;
  69511. QUERY_RESULT_AVAILABLE: number;
  69512. QUERY_RESULT: number;
  69513. }
  69514. interface WebGLProgram {
  69515. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69516. }
  69517. interface EXT_disjoint_timer_query {
  69518. QUERY_COUNTER_BITS_EXT: number;
  69519. TIME_ELAPSED_EXT: number;
  69520. TIMESTAMP_EXT: number;
  69521. GPU_DISJOINT_EXT: number;
  69522. QUERY_RESULT_EXT: number;
  69523. QUERY_RESULT_AVAILABLE_EXT: number;
  69524. queryCounterEXT(query: WebGLQuery, target: number): void;
  69525. createQueryEXT(): WebGLQuery;
  69526. beginQueryEXT(target: number, query: WebGLQuery): void;
  69527. endQueryEXT(target: number): void;
  69528. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69529. deleteQueryEXT(query: WebGLQuery): void;
  69530. }
  69531. interface WebGLUniformLocation {
  69532. _currentState: any;
  69533. }
  69534. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69535. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69536. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69537. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69538. interface WebGLRenderingContext {
  69539. readonly RASTERIZER_DISCARD: number;
  69540. readonly DEPTH_COMPONENT24: number;
  69541. readonly TEXTURE_3D: number;
  69542. readonly TEXTURE_2D_ARRAY: number;
  69543. readonly TEXTURE_COMPARE_FUNC: number;
  69544. readonly TEXTURE_COMPARE_MODE: number;
  69545. readonly COMPARE_REF_TO_TEXTURE: number;
  69546. readonly TEXTURE_WRAP_R: number;
  69547. readonly HALF_FLOAT: number;
  69548. readonly RGB8: number;
  69549. readonly RED_INTEGER: number;
  69550. readonly RG_INTEGER: number;
  69551. readonly RGB_INTEGER: number;
  69552. readonly RGBA_INTEGER: number;
  69553. readonly R8_SNORM: number;
  69554. readonly RG8_SNORM: number;
  69555. readonly RGB8_SNORM: number;
  69556. readonly RGBA8_SNORM: number;
  69557. readonly R8I: number;
  69558. readonly RG8I: number;
  69559. readonly RGB8I: number;
  69560. readonly RGBA8I: number;
  69561. readonly R8UI: number;
  69562. readonly RG8UI: number;
  69563. readonly RGB8UI: number;
  69564. readonly RGBA8UI: number;
  69565. readonly R16I: number;
  69566. readonly RG16I: number;
  69567. readonly RGB16I: number;
  69568. readonly RGBA16I: number;
  69569. readonly R16UI: number;
  69570. readonly RG16UI: number;
  69571. readonly RGB16UI: number;
  69572. readonly RGBA16UI: number;
  69573. readonly R32I: number;
  69574. readonly RG32I: number;
  69575. readonly RGB32I: number;
  69576. readonly RGBA32I: number;
  69577. readonly R32UI: number;
  69578. readonly RG32UI: number;
  69579. readonly RGB32UI: number;
  69580. readonly RGBA32UI: number;
  69581. readonly RGB10_A2UI: number;
  69582. readonly R11F_G11F_B10F: number;
  69583. readonly RGB9_E5: number;
  69584. readonly RGB10_A2: number;
  69585. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69586. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69587. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69588. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69589. readonly DEPTH_COMPONENT32F: number;
  69590. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69591. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69592. 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;
  69593. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69594. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69595. readonly TRANSFORM_FEEDBACK: number;
  69596. readonly INTERLEAVED_ATTRIBS: number;
  69597. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69598. createTransformFeedback(): WebGLTransformFeedback;
  69599. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69600. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69601. beginTransformFeedback(primitiveMode: number): void;
  69602. endTransformFeedback(): void;
  69603. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69604. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69605. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69606. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69607. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69608. }
  69609. interface ImageBitmap {
  69610. readonly width: number;
  69611. readonly height: number;
  69612. close(): void;
  69613. }
  69614. interface WebGLQuery extends WebGLObject {
  69615. }
  69616. declare var WebGLQuery: {
  69617. prototype: WebGLQuery;
  69618. new(): WebGLQuery;
  69619. };
  69620. interface WebGLSampler extends WebGLObject {
  69621. }
  69622. declare var WebGLSampler: {
  69623. prototype: WebGLSampler;
  69624. new(): WebGLSampler;
  69625. };
  69626. interface WebGLSync extends WebGLObject {
  69627. }
  69628. declare var WebGLSync: {
  69629. prototype: WebGLSync;
  69630. new(): WebGLSync;
  69631. };
  69632. interface WebGLTransformFeedback extends WebGLObject {
  69633. }
  69634. declare var WebGLTransformFeedback: {
  69635. prototype: WebGLTransformFeedback;
  69636. new(): WebGLTransformFeedback;
  69637. };
  69638. interface WebGLVertexArrayObject extends WebGLObject {
  69639. }
  69640. declare var WebGLVertexArrayObject: {
  69641. prototype: WebGLVertexArrayObject;
  69642. new(): WebGLVertexArrayObject;
  69643. };
  69644. // Type definitions for WebVR API
  69645. // Project: https://w3c.github.io/webvr/
  69646. // Definitions by: six a <https://github.com/lostfictions>
  69647. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69648. interface VRDisplay extends EventTarget {
  69649. /**
  69650. * Dictionary of capabilities describing the VRDisplay.
  69651. */
  69652. readonly capabilities: VRDisplayCapabilities;
  69653. /**
  69654. * z-depth defining the far plane of the eye view frustum
  69655. * enables mapping of values in the render target depth
  69656. * attachment to scene coordinates. Initially set to 10000.0.
  69657. */
  69658. depthFar: number;
  69659. /**
  69660. * z-depth defining the near plane of the eye view frustum
  69661. * enables mapping of values in the render target depth
  69662. * attachment to scene coordinates. Initially set to 0.01.
  69663. */
  69664. depthNear: number;
  69665. /**
  69666. * An identifier for this distinct VRDisplay. Used as an
  69667. * association point in the Gamepad API.
  69668. */
  69669. readonly displayId: number;
  69670. /**
  69671. * A display name, a user-readable name identifying it.
  69672. */
  69673. readonly displayName: string;
  69674. readonly isConnected: boolean;
  69675. readonly isPresenting: boolean;
  69676. /**
  69677. * If this VRDisplay supports room-scale experiences, the optional
  69678. * stage attribute contains details on the room-scale parameters.
  69679. */
  69680. readonly stageParameters: VRStageParameters | null;
  69681. /**
  69682. * Passing the value returned by `requestAnimationFrame` to
  69683. * `cancelAnimationFrame` will unregister the callback.
  69684. * @param handle Define the hanle of the request to cancel
  69685. */
  69686. cancelAnimationFrame(handle: number): void;
  69687. /**
  69688. * Stops presenting to the VRDisplay.
  69689. * @returns a promise to know when it stopped
  69690. */
  69691. exitPresent(): Promise<void>;
  69692. /**
  69693. * Return the current VREyeParameters for the given eye.
  69694. * @param whichEye Define the eye we want the parameter for
  69695. * @returns the eye parameters
  69696. */
  69697. getEyeParameters(whichEye: string): VREyeParameters;
  69698. /**
  69699. * Populates the passed VRFrameData with the information required to render
  69700. * the current frame.
  69701. * @param frameData Define the data structure to populate
  69702. * @returns true if ok otherwise false
  69703. */
  69704. getFrameData(frameData: VRFrameData): boolean;
  69705. /**
  69706. * Get the layers currently being presented.
  69707. * @returns the list of VR layers
  69708. */
  69709. getLayers(): VRLayer[];
  69710. /**
  69711. * Return a VRPose containing the future predicted pose of the VRDisplay
  69712. * when the current frame will be presented. The value returned will not
  69713. * change until JavaScript has returned control to the browser.
  69714. *
  69715. * The VRPose will contain the position, orientation, velocity,
  69716. * and acceleration of each of these properties.
  69717. * @returns the pose object
  69718. */
  69719. getPose(): VRPose;
  69720. /**
  69721. * Return the current instantaneous pose of the VRDisplay, with no
  69722. * prediction applied.
  69723. * @returns the current instantaneous pose
  69724. */
  69725. getImmediatePose(): VRPose;
  69726. /**
  69727. * The callback passed to `requestAnimationFrame` will be called
  69728. * any time a new frame should be rendered. When the VRDisplay is
  69729. * presenting the callback will be called at the native refresh
  69730. * rate of the HMD. When not presenting this function acts
  69731. * identically to how window.requestAnimationFrame acts. Content should
  69732. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69733. * asynchronously from other displays and at differing refresh rates.
  69734. * @param callback Define the eaction to run next frame
  69735. * @returns the request handle it
  69736. */
  69737. requestAnimationFrame(callback: FrameRequestCallback): number;
  69738. /**
  69739. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69740. * Repeat calls while already presenting will update the VRLayers being displayed.
  69741. * @param layers Define the list of layer to present
  69742. * @returns a promise to know when the request has been fulfilled
  69743. */
  69744. requestPresent(layers: VRLayer[]): Promise<void>;
  69745. /**
  69746. * Reset the pose for this display, treating its current position and
  69747. * orientation as the "origin/zero" values. VRPose.position,
  69748. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69749. * updated when calling resetPose(). This should be called in only
  69750. * sitting-space experiences.
  69751. */
  69752. resetPose(): void;
  69753. /**
  69754. * The VRLayer provided to the VRDisplay will be captured and presented
  69755. * in the HMD. Calling this function has the same effect on the source
  69756. * canvas as any other operation that uses its source image, and canvases
  69757. * created without preserveDrawingBuffer set to true will be cleared.
  69758. * @param pose Define the pose to submit
  69759. */
  69760. submitFrame(pose?: VRPose): void;
  69761. }
  69762. declare var VRDisplay: {
  69763. prototype: VRDisplay;
  69764. new(): VRDisplay;
  69765. };
  69766. interface VRLayer {
  69767. leftBounds?: number[] | Float32Array | null;
  69768. rightBounds?: number[] | Float32Array | null;
  69769. source?: HTMLCanvasElement | null;
  69770. }
  69771. interface VRDisplayCapabilities {
  69772. readonly canPresent: boolean;
  69773. readonly hasExternalDisplay: boolean;
  69774. readonly hasOrientation: boolean;
  69775. readonly hasPosition: boolean;
  69776. readonly maxLayers: number;
  69777. }
  69778. interface VREyeParameters {
  69779. /** @deprecated */
  69780. readonly fieldOfView: VRFieldOfView;
  69781. readonly offset: Float32Array;
  69782. readonly renderHeight: number;
  69783. readonly renderWidth: number;
  69784. }
  69785. interface VRFieldOfView {
  69786. readonly downDegrees: number;
  69787. readonly leftDegrees: number;
  69788. readonly rightDegrees: number;
  69789. readonly upDegrees: number;
  69790. }
  69791. interface VRFrameData {
  69792. readonly leftProjectionMatrix: Float32Array;
  69793. readonly leftViewMatrix: Float32Array;
  69794. readonly pose: VRPose;
  69795. readonly rightProjectionMatrix: Float32Array;
  69796. readonly rightViewMatrix: Float32Array;
  69797. readonly timestamp: number;
  69798. }
  69799. interface VRPose {
  69800. readonly angularAcceleration: Float32Array | null;
  69801. readonly angularVelocity: Float32Array | null;
  69802. readonly linearAcceleration: Float32Array | null;
  69803. readonly linearVelocity: Float32Array | null;
  69804. readonly orientation: Float32Array | null;
  69805. readonly position: Float32Array | null;
  69806. readonly timestamp: number;
  69807. }
  69808. interface VRStageParameters {
  69809. sittingToStandingTransform?: Float32Array;
  69810. sizeX?: number;
  69811. sizeY?: number;
  69812. }
  69813. interface Navigator {
  69814. getVRDisplays(): Promise<VRDisplay[]>;
  69815. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69816. }
  69817. interface Window {
  69818. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69819. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69820. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69821. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69822. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69823. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69824. }
  69825. interface Gamepad {
  69826. readonly displayId: number;
  69827. }
  69828. type XRSessionMode =
  69829. | "inline"
  69830. | "immersive-vr"
  69831. | "immersive-ar";
  69832. type XRReferenceSpaceType =
  69833. | "viewer"
  69834. | "local"
  69835. | "local-floor"
  69836. | "bounded-floor"
  69837. | "unbounded";
  69838. type XREnvironmentBlendMode =
  69839. | "opaque"
  69840. | "additive"
  69841. | "alpha-blend";
  69842. type XRVisibilityState =
  69843. | "visible"
  69844. | "visible-blurred"
  69845. | "hidden";
  69846. type XRHandedness =
  69847. | "none"
  69848. | "left"
  69849. | "right";
  69850. type XRTargetRayMode =
  69851. | "gaze"
  69852. | "tracked-pointer"
  69853. | "screen";
  69854. type XREye =
  69855. | "none"
  69856. | "left"
  69857. | "right";
  69858. interface XRSpace extends EventTarget {
  69859. }
  69860. interface XRRenderState {
  69861. depthNear?: number;
  69862. depthFar?: number;
  69863. inlineVerticalFieldOfView?: number;
  69864. baseLayer?: XRWebGLLayer;
  69865. }
  69866. interface XRInputSource {
  69867. handedness: XRHandedness;
  69868. targetRayMode: XRTargetRayMode;
  69869. targetRaySpace: XRSpace;
  69870. gripSpace: XRSpace | undefined;
  69871. gamepad: Gamepad | undefined;
  69872. profiles: Array<string>;
  69873. }
  69874. interface XRSessionInit {
  69875. optionalFeatures?: XRReferenceSpaceType[];
  69876. requiredFeatures?: XRReferenceSpaceType[];
  69877. }
  69878. interface XRSession extends XRAnchorCreator {
  69879. addEventListener: Function;
  69880. removeEventListener: Function;
  69881. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69882. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69883. requestAnimationFrame: Function;
  69884. end(): Promise<void>;
  69885. renderState: XRRenderState;
  69886. inputSources: Array<XRInputSource>;
  69887. // AR hit test
  69888. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69889. updateWorldTrackingState(options: {
  69890. planeDetectionState?: { enabled: boolean; }
  69891. }): void;
  69892. }
  69893. interface XRReferenceSpace extends XRSpace {
  69894. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69895. onreset: any;
  69896. }
  69897. type XRPlaneSet = Set<XRPlane>;
  69898. type XRAnchorSet = Set<XRAnchor>;
  69899. interface XRFrame {
  69900. session: XRSession;
  69901. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69902. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69903. // Anchors
  69904. trackedAnchors?: XRAnchorSet;
  69905. // Planes
  69906. worldInformation: {
  69907. detectedPlanes?: XRPlaneSet;
  69908. };
  69909. }
  69910. interface XRViewerPose extends XRPose {
  69911. views: Array<XRView>;
  69912. }
  69913. interface XRPose {
  69914. transform: XRRigidTransform;
  69915. emulatedPosition: boolean;
  69916. }
  69917. interface XRWebGLLayerOptions {
  69918. antialias?: boolean;
  69919. depth?: boolean;
  69920. stencil?: boolean;
  69921. alpha?: boolean;
  69922. multiview?: boolean;
  69923. framebufferScaleFactor?: number;
  69924. }
  69925. declare var XRWebGLLayer: {
  69926. prototype: XRWebGLLayer;
  69927. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69928. };
  69929. interface XRWebGLLayer {
  69930. framebuffer: WebGLFramebuffer;
  69931. framebufferWidth: number;
  69932. framebufferHeight: number;
  69933. getViewport: Function;
  69934. }
  69935. declare class XRRigidTransform {
  69936. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69937. position: DOMPointReadOnly;
  69938. orientation: DOMPointReadOnly;
  69939. matrix: Float32Array;
  69940. inverse: XRRigidTransform;
  69941. }
  69942. interface XRView {
  69943. eye: XREye;
  69944. projectionMatrix: Float32Array;
  69945. transform: XRRigidTransform;
  69946. }
  69947. interface XRInputSourceChangeEvent {
  69948. session: XRSession;
  69949. removed: Array<XRInputSource>;
  69950. added: Array<XRInputSource>;
  69951. }
  69952. interface XRInputSourceEvent extends Event {
  69953. readonly frame: XRFrame;
  69954. readonly inputSource: XRInputSource;
  69955. }
  69956. // Experimental(er) features
  69957. declare class XRRay {
  69958. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69959. origin: DOMPointReadOnly;
  69960. direction: DOMPointReadOnly;
  69961. matrix: Float32Array;
  69962. }
  69963. interface XRHitResult {
  69964. hitMatrix: Float32Array;
  69965. }
  69966. interface XRAnchor {
  69967. // remove?
  69968. id?: string;
  69969. anchorSpace: XRSpace;
  69970. lastChangedTime: number;
  69971. detach(): void;
  69972. }
  69973. interface XRPlane extends XRAnchorCreator {
  69974. orientation: "Horizontal" | "Vertical";
  69975. planeSpace: XRSpace;
  69976. polygon: Array<DOMPointReadOnly>;
  69977. lastChangedTime: number;
  69978. }
  69979. interface XRAnchorCreator {
  69980. // AR Anchors
  69981. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69982. }
  69983. /**
  69984. * @ignore
  69985. */
  69986. declare module BABYLON.GLTF2.Exporter {
  69987. }
  69988. /**
  69989. * @ignore
  69990. */
  69991. declare module BABYLON.GLTF1 {
  69992. }
  69993. declare module BABYLON.GUI {
  69994. /**
  69995. * Class used to specific a value and its associated unit
  69996. */
  69997. export class ValueAndUnit {
  69998. /** defines the unit to store */
  69999. unit: number;
  70000. /** defines a boolean indicating if the value can be negative */
  70001. negativeValueAllowed: boolean;
  70002. private _value;
  70003. private _originalUnit;
  70004. /**
  70005. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70006. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70007. */
  70008. ignoreAdaptiveScaling: boolean;
  70009. /**
  70010. * Creates a new ValueAndUnit
  70011. * @param value defines the value to store
  70012. * @param unit defines the unit to store
  70013. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70014. */
  70015. constructor(value: number,
  70016. /** defines the unit to store */
  70017. unit?: number,
  70018. /** defines a boolean indicating if the value can be negative */
  70019. negativeValueAllowed?: boolean);
  70020. /** Gets a boolean indicating if the value is a percentage */
  70021. get isPercentage(): boolean;
  70022. /** Gets a boolean indicating if the value is store as pixel */
  70023. get isPixel(): boolean;
  70024. /** Gets direct internal value */
  70025. get internalValue(): number;
  70026. /**
  70027. * Gets value as pixel
  70028. * @param host defines the root host
  70029. * @param refValue defines the reference value for percentages
  70030. * @returns the value as pixel
  70031. */
  70032. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70033. /**
  70034. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70035. * @param value defines the value to store
  70036. * @param unit defines the unit to store
  70037. * @returns the current ValueAndUnit
  70038. */
  70039. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70040. /**
  70041. * Gets the value accordingly to its unit
  70042. * @param host defines the root host
  70043. * @returns the value
  70044. */
  70045. getValue(host: AdvancedDynamicTexture): number;
  70046. /**
  70047. * Gets a string representation of the value
  70048. * @param host defines the root host
  70049. * @param decimals defines an optional number of decimals to display
  70050. * @returns a string
  70051. */
  70052. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70053. /**
  70054. * Store a value parsed from a string
  70055. * @param source defines the source string
  70056. * @returns true if the value was successfully parsed
  70057. */
  70058. fromString(source: string | number): boolean;
  70059. private static _Regex;
  70060. private static _UNITMODE_PERCENTAGE;
  70061. private static _UNITMODE_PIXEL;
  70062. /** UNITMODE_PERCENTAGE */
  70063. static get UNITMODE_PERCENTAGE(): number;
  70064. /** UNITMODE_PIXEL */
  70065. static get UNITMODE_PIXEL(): number;
  70066. }
  70067. }
  70068. declare module BABYLON.GUI {
  70069. /**
  70070. * Define a style used by control to automatically setup properties based on a template.
  70071. * Only support font related properties so far
  70072. */
  70073. export class Style implements BABYLON.IDisposable {
  70074. private _fontFamily;
  70075. private _fontStyle;
  70076. private _fontWeight;
  70077. /** @hidden */
  70078. _host: AdvancedDynamicTexture;
  70079. /** @hidden */
  70080. _fontSize: ValueAndUnit;
  70081. /**
  70082. * BABYLON.Observable raised when the style values are changed
  70083. */
  70084. onChangedObservable: BABYLON.Observable<Style>;
  70085. /**
  70086. * Creates a new style object
  70087. * @param host defines the AdvancedDynamicTexture which hosts this style
  70088. */
  70089. constructor(host: AdvancedDynamicTexture);
  70090. /**
  70091. * Gets or sets the font size
  70092. */
  70093. get fontSize(): string | number;
  70094. set fontSize(value: string | number);
  70095. /**
  70096. * Gets or sets the font family
  70097. */
  70098. get fontFamily(): string;
  70099. set fontFamily(value: string);
  70100. /**
  70101. * Gets or sets the font style
  70102. */
  70103. get fontStyle(): string;
  70104. set fontStyle(value: string);
  70105. /** Gets or sets font weight */
  70106. get fontWeight(): string;
  70107. set fontWeight(value: string);
  70108. /** Dispose all associated resources */
  70109. dispose(): void;
  70110. }
  70111. }
  70112. declare module BABYLON.GUI {
  70113. /**
  70114. * Class used to transport BABYLON.Vector2 information for pointer events
  70115. */
  70116. export class Vector2WithInfo extends BABYLON.Vector2 {
  70117. /** defines the current mouse button index */
  70118. buttonIndex: number;
  70119. /**
  70120. * Creates a new Vector2WithInfo
  70121. * @param source defines the vector2 data to transport
  70122. * @param buttonIndex defines the current mouse button index
  70123. */
  70124. constructor(source: BABYLON.Vector2,
  70125. /** defines the current mouse button index */
  70126. buttonIndex?: number);
  70127. }
  70128. /** Class used to provide 2D matrix features */
  70129. export class Matrix2D {
  70130. /** Gets the internal array of 6 floats used to store matrix data */
  70131. m: Float32Array;
  70132. /**
  70133. * Creates a new matrix
  70134. * @param m00 defines value for (0, 0)
  70135. * @param m01 defines value for (0, 1)
  70136. * @param m10 defines value for (1, 0)
  70137. * @param m11 defines value for (1, 1)
  70138. * @param m20 defines value for (2, 0)
  70139. * @param m21 defines value for (2, 1)
  70140. */
  70141. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70142. /**
  70143. * Fills the matrix from direct values
  70144. * @param m00 defines value for (0, 0)
  70145. * @param m01 defines value for (0, 1)
  70146. * @param m10 defines value for (1, 0)
  70147. * @param m11 defines value for (1, 1)
  70148. * @param m20 defines value for (2, 0)
  70149. * @param m21 defines value for (2, 1)
  70150. * @returns the current modified matrix
  70151. */
  70152. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70153. /**
  70154. * Gets matrix determinant
  70155. * @returns the determinant
  70156. */
  70157. determinant(): number;
  70158. /**
  70159. * Inverses the matrix and stores it in a target matrix
  70160. * @param result defines the target matrix
  70161. * @returns the current matrix
  70162. */
  70163. invertToRef(result: Matrix2D): Matrix2D;
  70164. /**
  70165. * Multiplies the current matrix with another one
  70166. * @param other defines the second operand
  70167. * @param result defines the target matrix
  70168. * @returns the current matrix
  70169. */
  70170. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70171. /**
  70172. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70173. * @param x defines the x coordinate to transform
  70174. * @param y defines the x coordinate to transform
  70175. * @param result defines the target vector2
  70176. * @returns the current matrix
  70177. */
  70178. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70179. /**
  70180. * Creates an identity matrix
  70181. * @returns a new matrix
  70182. */
  70183. static Identity(): Matrix2D;
  70184. /**
  70185. * Creates a translation matrix and stores it in a target matrix
  70186. * @param x defines the x coordinate of the translation
  70187. * @param y defines the y coordinate of the translation
  70188. * @param result defines the target matrix
  70189. */
  70190. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70191. /**
  70192. * Creates a scaling matrix and stores it in a target matrix
  70193. * @param x defines the x coordinate of the scaling
  70194. * @param y defines the y coordinate of the scaling
  70195. * @param result defines the target matrix
  70196. */
  70197. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70198. /**
  70199. * Creates a rotation matrix and stores it in a target matrix
  70200. * @param angle defines the rotation angle
  70201. * @param result defines the target matrix
  70202. */
  70203. static RotationToRef(angle: number, result: Matrix2D): void;
  70204. private static _TempPreTranslationMatrix;
  70205. private static _TempPostTranslationMatrix;
  70206. private static _TempRotationMatrix;
  70207. private static _TempScalingMatrix;
  70208. private static _TempCompose0;
  70209. private static _TempCompose1;
  70210. private static _TempCompose2;
  70211. /**
  70212. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70213. * @param tx defines the x coordinate of the translation
  70214. * @param ty defines the y coordinate of the translation
  70215. * @param angle defines the rotation angle
  70216. * @param scaleX defines the x coordinate of the scaling
  70217. * @param scaleY defines the y coordinate of the scaling
  70218. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70219. * @param result defines the target matrix
  70220. */
  70221. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70222. }
  70223. }
  70224. declare module BABYLON.GUI {
  70225. /**
  70226. * Class used to store 2D control sizes
  70227. */
  70228. export class Measure {
  70229. /** defines left coordinate */
  70230. left: number;
  70231. /** defines top coordinate */
  70232. top: number;
  70233. /** defines width dimension */
  70234. width: number;
  70235. /** defines height dimension */
  70236. height: number;
  70237. /**
  70238. * Creates a new measure
  70239. * @param left defines left coordinate
  70240. * @param top defines top coordinate
  70241. * @param width defines width dimension
  70242. * @param height defines height dimension
  70243. */
  70244. constructor(
  70245. /** defines left coordinate */
  70246. left: number,
  70247. /** defines top coordinate */
  70248. top: number,
  70249. /** defines width dimension */
  70250. width: number,
  70251. /** defines height dimension */
  70252. height: number);
  70253. /**
  70254. * Copy from another measure
  70255. * @param other defines the other measure to copy from
  70256. */
  70257. copyFrom(other: Measure): void;
  70258. /**
  70259. * Copy from a group of 4 floats
  70260. * @param left defines left coordinate
  70261. * @param top defines top coordinate
  70262. * @param width defines width dimension
  70263. * @param height defines height dimension
  70264. */
  70265. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70266. /**
  70267. * Computes the axis aligned bounding box measure for two given measures
  70268. * @param a Input measure
  70269. * @param b Input measure
  70270. * @param result the resulting bounding measure
  70271. */
  70272. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70273. /**
  70274. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70275. * @param transform the matrix to transform the measure before computing the AABB
  70276. * @param result the resulting AABB
  70277. */
  70278. transformToRef(transform: Matrix2D, result: Measure): void;
  70279. /**
  70280. * Check equality between this measure and another one
  70281. * @param other defines the other measures
  70282. * @returns true if both measures are equals
  70283. */
  70284. isEqualsTo(other: Measure): boolean;
  70285. /**
  70286. * Creates an empty measure
  70287. * @returns a new measure
  70288. */
  70289. static Empty(): Measure;
  70290. }
  70291. }
  70292. declare module BABYLON.GUI {
  70293. /**
  70294. * Interface used to define a control that can receive focus
  70295. */
  70296. export interface IFocusableControl {
  70297. /**
  70298. * Function called when the control receives the focus
  70299. */
  70300. onFocus(): void;
  70301. /**
  70302. * Function called when the control loses the focus
  70303. */
  70304. onBlur(): void;
  70305. /**
  70306. * Function called to let the control handle keyboard events
  70307. * @param evt defines the current keyboard event
  70308. */
  70309. processKeyboard(evt: KeyboardEvent): void;
  70310. /**
  70311. * Function called to get the list of controls that should not steal the focus from this control
  70312. * @returns an array of controls
  70313. */
  70314. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70315. }
  70316. /**
  70317. * Class used to create texture to support 2D GUI elements
  70318. * @see http://doc.babylonjs.com/how_to/gui
  70319. */
  70320. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70321. private _isDirty;
  70322. private _renderObserver;
  70323. private _resizeObserver;
  70324. private _preKeyboardObserver;
  70325. private _pointerMoveObserver;
  70326. private _pointerObserver;
  70327. private _canvasPointerOutObserver;
  70328. private _background;
  70329. /** @hidden */
  70330. _rootContainer: Container;
  70331. /** @hidden */
  70332. _lastPickedControl: Control;
  70333. /** @hidden */
  70334. _lastControlOver: {
  70335. [pointerId: number]: Control;
  70336. };
  70337. /** @hidden */
  70338. _lastControlDown: {
  70339. [pointerId: number]: Control;
  70340. };
  70341. /** @hidden */
  70342. _capturingControl: {
  70343. [pointerId: number]: Control;
  70344. };
  70345. /** @hidden */
  70346. _shouldBlockPointer: boolean;
  70347. /** @hidden */
  70348. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70349. /** @hidden */
  70350. _linkedControls: Control[];
  70351. private _isFullscreen;
  70352. private _fullscreenViewport;
  70353. private _idealWidth;
  70354. private _idealHeight;
  70355. private _useSmallestIdeal;
  70356. private _renderAtIdealSize;
  70357. private _focusedControl;
  70358. private _blockNextFocusCheck;
  70359. private _renderScale;
  70360. private _rootElement;
  70361. private _cursorChanged;
  70362. /** @hidden */
  70363. _numLayoutCalls: number;
  70364. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70365. get numLayoutCalls(): number;
  70366. /** @hidden */
  70367. _numRenderCalls: number;
  70368. /** Gets the number of render calls made the last time the ADT has been rendered */
  70369. get numRenderCalls(): number;
  70370. /**
  70371. * Define type to string to ensure compatibility across browsers
  70372. * Safari doesn't support DataTransfer constructor
  70373. */
  70374. private _clipboardData;
  70375. /**
  70376. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70377. */
  70378. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70379. /**
  70380. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70381. */
  70382. onControlPickedObservable: BABYLON.Observable<Control>;
  70383. /**
  70384. * BABYLON.Observable event triggered before layout is evaluated
  70385. */
  70386. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70387. /**
  70388. * BABYLON.Observable event triggered after the layout was evaluated
  70389. */
  70390. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70391. /**
  70392. * BABYLON.Observable event triggered before the texture is rendered
  70393. */
  70394. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70395. /**
  70396. * BABYLON.Observable event triggered after the texture was rendered
  70397. */
  70398. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70399. /**
  70400. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70401. */
  70402. premulAlpha: boolean;
  70403. /**
  70404. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70405. * Useful when you want more antialiasing
  70406. */
  70407. get renderScale(): number;
  70408. set renderScale(value: number);
  70409. /** Gets or sets the background color */
  70410. get background(): string;
  70411. set background(value: string);
  70412. /**
  70413. * Gets or sets the ideal width used to design controls.
  70414. * The GUI will then rescale everything accordingly
  70415. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70416. */
  70417. get idealWidth(): number;
  70418. set idealWidth(value: number);
  70419. /**
  70420. * Gets or sets the ideal height used to design controls.
  70421. * The GUI will then rescale everything accordingly
  70422. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70423. */
  70424. get idealHeight(): number;
  70425. set idealHeight(value: number);
  70426. /**
  70427. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70428. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70429. */
  70430. get useSmallestIdeal(): boolean;
  70431. set useSmallestIdeal(value: boolean);
  70432. /**
  70433. * Gets or sets a boolean indicating if adaptive scaling must be used
  70434. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70435. */
  70436. get renderAtIdealSize(): boolean;
  70437. set renderAtIdealSize(value: boolean);
  70438. /**
  70439. * Gets the ratio used when in "ideal mode"
  70440. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70441. * */
  70442. get idealRatio(): number;
  70443. /**
  70444. * Gets the underlying layer used to render the texture when in fullscreen mode
  70445. */
  70446. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70447. /**
  70448. * Gets the root container control
  70449. */
  70450. get rootContainer(): Container;
  70451. /**
  70452. * Returns an array containing the root container.
  70453. * This is mostly used to let the Inspector introspects the ADT
  70454. * @returns an array containing the rootContainer
  70455. */
  70456. getChildren(): Array<Container>;
  70457. /**
  70458. * Will return all controls that are inside this texture
  70459. * @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
  70460. * @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
  70461. * @return all child controls
  70462. */
  70463. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70464. /**
  70465. * Gets or sets the current focused control
  70466. */
  70467. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70468. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70469. /**
  70470. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70471. */
  70472. get isForeground(): boolean;
  70473. set isForeground(value: boolean);
  70474. /**
  70475. * Gets or set information about clipboardData
  70476. */
  70477. get clipboardData(): string;
  70478. set clipboardData(value: string);
  70479. /**
  70480. * Creates a new AdvancedDynamicTexture
  70481. * @param name defines the name of the texture
  70482. * @param width defines the width of the texture
  70483. * @param height defines the height of the texture
  70484. * @param scene defines the hosting scene
  70485. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70486. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70487. */
  70488. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70489. /**
  70490. * Get the current class name of the texture useful for serialization or dynamic coding.
  70491. * @returns "AdvancedDynamicTexture"
  70492. */
  70493. getClassName(): string;
  70494. /**
  70495. * Function used to execute a function on all controls
  70496. * @param func defines the function to execute
  70497. * @param container defines the container where controls belong. If null the root container will be used
  70498. */
  70499. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70500. private _useInvalidateRectOptimization;
  70501. /**
  70502. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70503. */
  70504. get useInvalidateRectOptimization(): boolean;
  70505. set useInvalidateRectOptimization(value: boolean);
  70506. private _invalidatedRectangle;
  70507. /**
  70508. * Invalidates a rectangle area on the gui texture
  70509. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70510. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70511. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70512. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70513. */
  70514. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70515. /**
  70516. * Marks the texture as dirty forcing a complete update
  70517. */
  70518. markAsDirty(): void;
  70519. /**
  70520. * Helper function used to create a new style
  70521. * @returns a new style
  70522. * @see http://doc.babylonjs.com/how_to/gui#styles
  70523. */
  70524. createStyle(): Style;
  70525. /**
  70526. * Adds a new control to the root container
  70527. * @param control defines the control to add
  70528. * @returns the current texture
  70529. */
  70530. addControl(control: Control): AdvancedDynamicTexture;
  70531. /**
  70532. * Removes a control from the root container
  70533. * @param control defines the control to remove
  70534. * @returns the current texture
  70535. */
  70536. removeControl(control: Control): AdvancedDynamicTexture;
  70537. /**
  70538. * Release all resources
  70539. */
  70540. dispose(): void;
  70541. private _onResize;
  70542. /** @hidden */
  70543. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70544. /**
  70545. * Get screen coordinates for a vector3
  70546. * @param position defines the position to project
  70547. * @param worldMatrix defines the world matrix to use
  70548. * @returns the projected position
  70549. */
  70550. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70551. private _checkUpdate;
  70552. private _clearMeasure;
  70553. private _render;
  70554. /** @hidden */
  70555. _changeCursor(cursor: string): void;
  70556. /** @hidden */
  70557. _registerLastControlDown(control: Control, pointerId: number): void;
  70558. private _doPicking;
  70559. /** @hidden */
  70560. _cleanControlAfterRemovalFromList(list: {
  70561. [pointerId: number]: Control;
  70562. }, control: Control): void;
  70563. /** @hidden */
  70564. _cleanControlAfterRemoval(control: Control): void;
  70565. /** Attach to all scene events required to support pointer events */
  70566. attach(): void;
  70567. /** @hidden */
  70568. private onClipboardCopy;
  70569. /** @hidden */
  70570. private onClipboardCut;
  70571. /** @hidden */
  70572. private onClipboardPaste;
  70573. /**
  70574. * Register the clipboard Events onto the canvas
  70575. */
  70576. registerClipboardEvents(): void;
  70577. /**
  70578. * Unregister the clipboard Events from the canvas
  70579. */
  70580. unRegisterClipboardEvents(): void;
  70581. /**
  70582. * Connect the texture to a hosting mesh to enable interactions
  70583. * @param mesh defines the mesh to attach to
  70584. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70585. */
  70586. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70587. /**
  70588. * Move the focus to a specific control
  70589. * @param control defines the control which will receive the focus
  70590. */
  70591. moveFocusToControl(control: IFocusableControl): void;
  70592. private _manageFocus;
  70593. private _attachToOnPointerOut;
  70594. /**
  70595. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70596. * @param mesh defines the mesh which will receive the texture
  70597. * @param width defines the texture width (1024 by default)
  70598. * @param height defines the texture height (1024 by default)
  70599. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70600. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70601. * @returns a new AdvancedDynamicTexture
  70602. */
  70603. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70604. /**
  70605. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70606. * In this mode the texture will rely on a layer for its rendering.
  70607. * This allows it to be treated like any other layer.
  70608. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70609. * LayerMask is set through advancedTexture.layer.layerMask
  70610. * @param name defines name for the texture
  70611. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70612. * @param scene defines the hsoting scene
  70613. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70614. * @returns a new AdvancedDynamicTexture
  70615. */
  70616. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70617. }
  70618. }
  70619. declare module BABYLON.GUI {
  70620. /**
  70621. * Root class used for all 2D controls
  70622. * @see http://doc.babylonjs.com/how_to/gui#controls
  70623. */
  70624. export class Control {
  70625. /** defines the name of the control */
  70626. name?: string | undefined;
  70627. /**
  70628. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70629. */
  70630. static AllowAlphaInheritance: boolean;
  70631. private _alpha;
  70632. private _alphaSet;
  70633. private _zIndex;
  70634. /** @hidden */
  70635. _host: AdvancedDynamicTexture;
  70636. /** Gets or sets the control parent */
  70637. parent: BABYLON.Nullable<Container>;
  70638. /** @hidden */
  70639. _currentMeasure: Measure;
  70640. private _fontFamily;
  70641. private _fontStyle;
  70642. private _fontWeight;
  70643. private _fontSize;
  70644. private _font;
  70645. /** @hidden */
  70646. _width: ValueAndUnit;
  70647. /** @hidden */
  70648. _height: ValueAndUnit;
  70649. /** @hidden */
  70650. protected _fontOffset: {
  70651. ascent: number;
  70652. height: number;
  70653. descent: number;
  70654. };
  70655. private _color;
  70656. private _style;
  70657. private _styleObserver;
  70658. /** @hidden */
  70659. protected _horizontalAlignment: number;
  70660. /** @hidden */
  70661. protected _verticalAlignment: number;
  70662. /** @hidden */
  70663. protected _isDirty: boolean;
  70664. /** @hidden */
  70665. protected _wasDirty: boolean;
  70666. /** @hidden */
  70667. _tempParentMeasure: Measure;
  70668. /** @hidden */
  70669. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70670. /** @hidden */
  70671. protected _cachedParentMeasure: Measure;
  70672. private _paddingLeft;
  70673. private _paddingRight;
  70674. private _paddingTop;
  70675. private _paddingBottom;
  70676. /** @hidden */
  70677. _left: ValueAndUnit;
  70678. /** @hidden */
  70679. _top: ValueAndUnit;
  70680. private _scaleX;
  70681. private _scaleY;
  70682. private _rotation;
  70683. private _transformCenterX;
  70684. private _transformCenterY;
  70685. /** @hidden */
  70686. _transformMatrix: Matrix2D;
  70687. /** @hidden */
  70688. protected _invertTransformMatrix: Matrix2D;
  70689. /** @hidden */
  70690. protected _transformedPosition: BABYLON.Vector2;
  70691. private _isMatrixDirty;
  70692. private _cachedOffsetX;
  70693. private _cachedOffsetY;
  70694. private _isVisible;
  70695. private _isHighlighted;
  70696. /** @hidden */
  70697. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70698. private _fontSet;
  70699. private _dummyVector2;
  70700. private _downCount;
  70701. private _enterCount;
  70702. private _doNotRender;
  70703. private _downPointerIds;
  70704. protected _isEnabled: boolean;
  70705. protected _disabledColor: string;
  70706. protected _disabledColorItem: string;
  70707. /** @hidden */
  70708. protected _rebuildLayout: boolean;
  70709. /** @hidden */
  70710. _customData: any;
  70711. /** @hidden */
  70712. _isClipped: boolean;
  70713. /** @hidden */
  70714. _automaticSize: boolean;
  70715. /** @hidden */
  70716. _tag: any;
  70717. /**
  70718. * 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
  70719. */
  70720. uniqueId: number;
  70721. /**
  70722. * Gets or sets an object used to store user defined information for the node
  70723. */
  70724. metadata: any;
  70725. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70726. isHitTestVisible: boolean;
  70727. /** Gets or sets a boolean indicating if the control can block pointer events */
  70728. isPointerBlocker: boolean;
  70729. /** Gets or sets a boolean indicating if the control can be focusable */
  70730. isFocusInvisible: boolean;
  70731. /**
  70732. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70733. * 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
  70734. */
  70735. clipChildren: boolean;
  70736. /**
  70737. * Gets or sets a boolean indicating that control content must be clipped
  70738. * 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
  70739. */
  70740. clipContent: boolean;
  70741. /**
  70742. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70743. */
  70744. useBitmapCache: boolean;
  70745. private _cacheData;
  70746. private _shadowOffsetX;
  70747. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70748. get shadowOffsetX(): number;
  70749. set shadowOffsetX(value: number);
  70750. private _shadowOffsetY;
  70751. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70752. get shadowOffsetY(): number;
  70753. set shadowOffsetY(value: number);
  70754. private _shadowBlur;
  70755. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70756. get shadowBlur(): number;
  70757. set shadowBlur(value: number);
  70758. private _shadowColor;
  70759. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70760. get shadowColor(): string;
  70761. set shadowColor(value: string);
  70762. /** Gets or sets the cursor to use when the control is hovered */
  70763. hoverCursor: string;
  70764. /** @hidden */
  70765. protected _linkOffsetX: ValueAndUnit;
  70766. /** @hidden */
  70767. protected _linkOffsetY: ValueAndUnit;
  70768. /** Gets the control type name */
  70769. get typeName(): string;
  70770. /**
  70771. * Get the current class name of the control.
  70772. * @returns current class name
  70773. */
  70774. getClassName(): string;
  70775. /**
  70776. * An event triggered when pointer wheel is scrolled
  70777. */
  70778. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  70779. /**
  70780. * An event triggered when the pointer move over the control.
  70781. */
  70782. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70783. /**
  70784. * An event triggered when the pointer move out of the control.
  70785. */
  70786. onPointerOutObservable: BABYLON.Observable<Control>;
  70787. /**
  70788. * An event triggered when the pointer taps the control
  70789. */
  70790. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70791. /**
  70792. * An event triggered when pointer up
  70793. */
  70794. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70795. /**
  70796. * An event triggered when a control is clicked on
  70797. */
  70798. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70799. /**
  70800. * An event triggered when pointer enters the control
  70801. */
  70802. onPointerEnterObservable: BABYLON.Observable<Control>;
  70803. /**
  70804. * An event triggered when the control is marked as dirty
  70805. */
  70806. onDirtyObservable: BABYLON.Observable<Control>;
  70807. /**
  70808. * An event triggered before drawing the control
  70809. */
  70810. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70811. /**
  70812. * An event triggered after the control was drawn
  70813. */
  70814. onAfterDrawObservable: BABYLON.Observable<Control>;
  70815. /**
  70816. * Get the hosting AdvancedDynamicTexture
  70817. */
  70818. get host(): AdvancedDynamicTexture;
  70819. /** Gets or set information about font offsets (used to render and align text) */
  70820. get fontOffset(): {
  70821. ascent: number;
  70822. height: number;
  70823. descent: number;
  70824. };
  70825. set fontOffset(offset: {
  70826. ascent: number;
  70827. height: number;
  70828. descent: number;
  70829. });
  70830. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70831. get alpha(): number;
  70832. set alpha(value: number);
  70833. /**
  70834. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70835. */
  70836. get isHighlighted(): boolean;
  70837. set isHighlighted(value: boolean);
  70838. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70839. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70840. */
  70841. get scaleX(): number;
  70842. set scaleX(value: number);
  70843. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70844. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70845. */
  70846. get scaleY(): number;
  70847. set scaleY(value: number);
  70848. /** Gets or sets the rotation angle (0 by default)
  70849. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70850. */
  70851. get rotation(): number;
  70852. set rotation(value: number);
  70853. /** Gets or sets the transformation center on Y axis (0 by default)
  70854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70855. */
  70856. get transformCenterY(): number;
  70857. set transformCenterY(value: number);
  70858. /** Gets or sets the transformation center on X axis (0 by default)
  70859. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70860. */
  70861. get transformCenterX(): number;
  70862. set transformCenterX(value: number);
  70863. /**
  70864. * Gets or sets the horizontal alignment
  70865. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70866. */
  70867. get horizontalAlignment(): number;
  70868. set horizontalAlignment(value: number);
  70869. /**
  70870. * Gets or sets the vertical alignment
  70871. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70872. */
  70873. get verticalAlignment(): number;
  70874. set verticalAlignment(value: number);
  70875. /**
  70876. * Gets or sets control width
  70877. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70878. */
  70879. get width(): string | number;
  70880. set width(value: string | number);
  70881. /**
  70882. * Gets or sets the control width in pixel
  70883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70884. */
  70885. get widthInPixels(): number;
  70886. set widthInPixels(value: number);
  70887. /**
  70888. * Gets or sets control height
  70889. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70890. */
  70891. get height(): string | number;
  70892. set height(value: string | number);
  70893. /**
  70894. * Gets or sets control height in pixel
  70895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70896. */
  70897. get heightInPixels(): number;
  70898. set heightInPixels(value: number);
  70899. /** Gets or set font family */
  70900. get fontFamily(): string;
  70901. set fontFamily(value: string);
  70902. /** Gets or sets font style */
  70903. get fontStyle(): string;
  70904. set fontStyle(value: string);
  70905. /** Gets or sets font weight */
  70906. get fontWeight(): string;
  70907. set fontWeight(value: string);
  70908. /**
  70909. * Gets or sets style
  70910. * @see http://doc.babylonjs.com/how_to/gui#styles
  70911. */
  70912. get style(): BABYLON.Nullable<Style>;
  70913. set style(value: BABYLON.Nullable<Style>);
  70914. /** @hidden */
  70915. get _isFontSizeInPercentage(): boolean;
  70916. /** Gets or sets font size in pixels */
  70917. get fontSizeInPixels(): number;
  70918. set fontSizeInPixels(value: number);
  70919. /** Gets or sets font size */
  70920. get fontSize(): string | number;
  70921. set fontSize(value: string | number);
  70922. /** Gets or sets foreground color */
  70923. get color(): string;
  70924. set color(value: string);
  70925. /** Gets or sets z index which is used to reorder controls on the z axis */
  70926. get zIndex(): number;
  70927. set zIndex(value: number);
  70928. /** Gets or sets a boolean indicating if the control can be rendered */
  70929. get notRenderable(): boolean;
  70930. set notRenderable(value: boolean);
  70931. /** Gets or sets a boolean indicating if the control is visible */
  70932. get isVisible(): boolean;
  70933. set isVisible(value: boolean);
  70934. /** Gets a boolean indicating that the control needs to update its rendering */
  70935. get isDirty(): boolean;
  70936. /**
  70937. * Gets the current linked mesh (or null if none)
  70938. */
  70939. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70940. /**
  70941. * Gets or sets a value indicating the padding to use on the left of the control
  70942. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70943. */
  70944. get paddingLeft(): string | number;
  70945. set paddingLeft(value: string | number);
  70946. /**
  70947. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70949. */
  70950. get paddingLeftInPixels(): number;
  70951. set paddingLeftInPixels(value: number);
  70952. /**
  70953. * Gets or sets a value indicating the padding to use on the right of the control
  70954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70955. */
  70956. get paddingRight(): string | number;
  70957. set paddingRight(value: string | number);
  70958. /**
  70959. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70961. */
  70962. get paddingRightInPixels(): number;
  70963. set paddingRightInPixels(value: number);
  70964. /**
  70965. * Gets or sets a value indicating the padding to use on the top of the control
  70966. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70967. */
  70968. get paddingTop(): string | number;
  70969. set paddingTop(value: string | number);
  70970. /**
  70971. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70973. */
  70974. get paddingTopInPixels(): number;
  70975. set paddingTopInPixels(value: number);
  70976. /**
  70977. * Gets or sets a value indicating the padding to use on the bottom of the control
  70978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70979. */
  70980. get paddingBottom(): string | number;
  70981. set paddingBottom(value: string | number);
  70982. /**
  70983. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70984. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70985. */
  70986. get paddingBottomInPixels(): number;
  70987. set paddingBottomInPixels(value: number);
  70988. /**
  70989. * Gets or sets a value indicating the left coordinate of the control
  70990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70991. */
  70992. get left(): string | number;
  70993. set left(value: string | number);
  70994. /**
  70995. * Gets or sets a value indicating the left coordinate in pixels of the control
  70996. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70997. */
  70998. get leftInPixels(): number;
  70999. set leftInPixels(value: number);
  71000. /**
  71001. * Gets or sets a value indicating the top coordinate of the control
  71002. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71003. */
  71004. get top(): string | number;
  71005. set top(value: string | number);
  71006. /**
  71007. * Gets or sets a value indicating the top coordinate in pixels of the control
  71008. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71009. */
  71010. get topInPixels(): number;
  71011. set topInPixels(value: number);
  71012. /**
  71013. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71014. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71015. */
  71016. get linkOffsetX(): string | number;
  71017. set linkOffsetX(value: string | number);
  71018. /**
  71019. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71020. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71021. */
  71022. get linkOffsetXInPixels(): number;
  71023. set linkOffsetXInPixels(value: number);
  71024. /**
  71025. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71026. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71027. */
  71028. get linkOffsetY(): string | number;
  71029. set linkOffsetY(value: string | number);
  71030. /**
  71031. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71032. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71033. */
  71034. get linkOffsetYInPixels(): number;
  71035. set linkOffsetYInPixels(value: number);
  71036. /** Gets the center coordinate on X axis */
  71037. get centerX(): number;
  71038. /** Gets the center coordinate on Y axis */
  71039. get centerY(): number;
  71040. /** Gets or sets if control is Enabled*/
  71041. get isEnabled(): boolean;
  71042. set isEnabled(value: boolean);
  71043. /** Gets or sets background color of control if it's disabled*/
  71044. get disabledColor(): string;
  71045. set disabledColor(value: string);
  71046. /** Gets or sets front color of control if it's disabled*/
  71047. get disabledColorItem(): string;
  71048. set disabledColorItem(value: string);
  71049. /**
  71050. * Creates a new control
  71051. * @param name defines the name of the control
  71052. */
  71053. constructor(
  71054. /** defines the name of the control */
  71055. name?: string | undefined);
  71056. /** @hidden */
  71057. protected _getTypeName(): string;
  71058. /**
  71059. * Gets the first ascendant in the hierarchy of the given type
  71060. * @param className defines the required type
  71061. * @returns the ascendant or null if not found
  71062. */
  71063. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71064. /** @hidden */
  71065. _resetFontCache(): void;
  71066. /**
  71067. * Determines if a container is an ascendant of the current control
  71068. * @param container defines the container to look for
  71069. * @returns true if the container is one of the ascendant of the control
  71070. */
  71071. isAscendant(container: Control): boolean;
  71072. /**
  71073. * Gets coordinates in local control space
  71074. * @param globalCoordinates defines the coordinates to transform
  71075. * @returns the new coordinates in local space
  71076. */
  71077. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71078. /**
  71079. * Gets coordinates in local control space
  71080. * @param globalCoordinates defines the coordinates to transform
  71081. * @param result defines the target vector2 where to store the result
  71082. * @returns the current control
  71083. */
  71084. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71085. /**
  71086. * Gets coordinates in parent local control space
  71087. * @param globalCoordinates defines the coordinates to transform
  71088. * @returns the new coordinates in parent local space
  71089. */
  71090. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71091. /**
  71092. * Move the current control to a vector3 position projected onto the screen.
  71093. * @param position defines the target position
  71094. * @param scene defines the hosting scene
  71095. */
  71096. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71097. /**
  71098. * Will store all controls that have this control as ascendant in a given array
  71099. * @param results defines the array where to store the descendants
  71100. * @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
  71101. * @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
  71102. */
  71103. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71104. /**
  71105. * Will return all controls that have this control as ascendant
  71106. * @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
  71107. * @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
  71108. * @return all child controls
  71109. */
  71110. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71111. /**
  71112. * Link current control with a target mesh
  71113. * @param mesh defines the mesh to link with
  71114. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71115. */
  71116. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71117. /** @hidden */
  71118. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71119. /** @hidden */
  71120. _offsetLeft(offset: number): void;
  71121. /** @hidden */
  71122. _offsetTop(offset: number): void;
  71123. /** @hidden */
  71124. _markMatrixAsDirty(): void;
  71125. /** @hidden */
  71126. _flagDescendantsAsMatrixDirty(): void;
  71127. /** @hidden */
  71128. _intersectsRect(rect: Measure): boolean;
  71129. /** @hidden */
  71130. protected invalidateRect(): void;
  71131. /** @hidden */
  71132. _markAsDirty(force?: boolean): void;
  71133. /** @hidden */
  71134. _markAllAsDirty(): void;
  71135. /** @hidden */
  71136. _link(host: AdvancedDynamicTexture): void;
  71137. /** @hidden */
  71138. protected _transform(context?: CanvasRenderingContext2D): void;
  71139. /** @hidden */
  71140. _renderHighlight(context: CanvasRenderingContext2D): void;
  71141. /** @hidden */
  71142. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71143. /** @hidden */
  71144. protected _applyStates(context: CanvasRenderingContext2D): void;
  71145. /** @hidden */
  71146. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71147. /** @hidden */
  71148. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71149. protected _evaluateClippingState(parentMeasure: Measure): void;
  71150. /** @hidden */
  71151. _measure(): void;
  71152. /** @hidden */
  71153. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71154. /** @hidden */
  71155. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71156. /** @hidden */
  71157. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71158. /** @hidden */
  71159. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71160. private static _ClipMeasure;
  71161. private _tmpMeasureA;
  71162. private _clip;
  71163. /** @hidden */
  71164. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71165. /** @hidden */
  71166. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71167. /**
  71168. * Tests if a given coordinates belong to the current control
  71169. * @param x defines x coordinate to test
  71170. * @param y defines y coordinate to test
  71171. * @returns true if the coordinates are inside the control
  71172. */
  71173. contains(x: number, y: number): boolean;
  71174. /** @hidden */
  71175. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71176. /** @hidden */
  71177. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71178. /** @hidden */
  71179. _onPointerEnter(target: Control): boolean;
  71180. /** @hidden */
  71181. _onPointerOut(target: Control, force?: boolean): void;
  71182. /** @hidden */
  71183. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71184. /** @hidden */
  71185. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71186. /** @hidden */
  71187. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71188. /** @hidden */
  71189. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71190. /** @hidden */
  71191. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71192. private _prepareFont;
  71193. /** Releases associated resources */
  71194. dispose(): void;
  71195. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71196. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71197. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71198. private static _VERTICAL_ALIGNMENT_TOP;
  71199. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71200. private static _VERTICAL_ALIGNMENT_CENTER;
  71201. /** HORIZONTAL_ALIGNMENT_LEFT */
  71202. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71203. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71204. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71205. /** HORIZONTAL_ALIGNMENT_CENTER */
  71206. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71207. /** VERTICAL_ALIGNMENT_TOP */
  71208. static get VERTICAL_ALIGNMENT_TOP(): number;
  71209. /** VERTICAL_ALIGNMENT_BOTTOM */
  71210. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71211. /** VERTICAL_ALIGNMENT_CENTER */
  71212. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71213. private static _FontHeightSizes;
  71214. /** @hidden */
  71215. static _GetFontOffset(font: string): {
  71216. ascent: number;
  71217. height: number;
  71218. descent: number;
  71219. };
  71220. /**
  71221. * Creates a stack panel that can be used to render headers
  71222. * @param control defines the control to associate with the header
  71223. * @param text defines the text of the header
  71224. * @param size defines the size of the header
  71225. * @param options defines options used to configure the header
  71226. * @returns a new StackPanel
  71227. * @ignore
  71228. * @hidden
  71229. */
  71230. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71231. isHorizontal: boolean;
  71232. controlFirst: boolean;
  71233. }) => any;
  71234. /** @hidden */
  71235. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71236. }
  71237. }
  71238. declare module BABYLON.GUI {
  71239. /**
  71240. * Root class for 2D containers
  71241. * @see http://doc.babylonjs.com/how_to/gui#containers
  71242. */
  71243. export class Container extends Control {
  71244. name?: string | undefined;
  71245. /** @hidden */
  71246. _children: Control[];
  71247. /** @hidden */
  71248. protected _measureForChildren: Measure;
  71249. /** @hidden */
  71250. protected _background: string;
  71251. /** @hidden */
  71252. protected _adaptWidthToChildren: boolean;
  71253. /** @hidden */
  71254. protected _adaptHeightToChildren: boolean;
  71255. /**
  71256. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71257. */
  71258. logLayoutCycleErrors: boolean;
  71259. /**
  71260. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71261. */
  71262. maxLayoutCycle: number;
  71263. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71264. get adaptHeightToChildren(): boolean;
  71265. set adaptHeightToChildren(value: boolean);
  71266. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71267. get adaptWidthToChildren(): boolean;
  71268. set adaptWidthToChildren(value: boolean);
  71269. /** Gets or sets background color */
  71270. get background(): string;
  71271. set background(value: string);
  71272. /** Gets the list of children */
  71273. get children(): Control[];
  71274. /**
  71275. * Creates a new Container
  71276. * @param name defines the name of the container
  71277. */
  71278. constructor(name?: string | undefined);
  71279. protected _getTypeName(): string;
  71280. _flagDescendantsAsMatrixDirty(): void;
  71281. /**
  71282. * Gets a child using its name
  71283. * @param name defines the child name to look for
  71284. * @returns the child control if found
  71285. */
  71286. getChildByName(name: string): BABYLON.Nullable<Control>;
  71287. /**
  71288. * Gets a child using its type and its name
  71289. * @param name defines the child name to look for
  71290. * @param type defines the child type to look for
  71291. * @returns the child control if found
  71292. */
  71293. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71294. /**
  71295. * Search for a specific control in children
  71296. * @param control defines the control to look for
  71297. * @returns true if the control is in child list
  71298. */
  71299. containsControl(control: Control): boolean;
  71300. /**
  71301. * Adds a new control to the current container
  71302. * @param control defines the control to add
  71303. * @returns the current container
  71304. */
  71305. addControl(control: BABYLON.Nullable<Control>): Container;
  71306. /**
  71307. * Removes all controls from the current container
  71308. * @returns the current container
  71309. */
  71310. clearControls(): Container;
  71311. /**
  71312. * Removes a control from the current container
  71313. * @param control defines the control to remove
  71314. * @returns the current container
  71315. */
  71316. removeControl(control: Control): Container;
  71317. /** @hidden */
  71318. _reOrderControl(control: Control): void;
  71319. /** @hidden */
  71320. _offsetLeft(offset: number): void;
  71321. /** @hidden */
  71322. _offsetTop(offset: number): void;
  71323. /** @hidden */
  71324. _markAllAsDirty(): void;
  71325. /** @hidden */
  71326. protected _localDraw(context: CanvasRenderingContext2D): void;
  71327. /** @hidden */
  71328. _link(host: AdvancedDynamicTexture): void;
  71329. /** @hidden */
  71330. protected _beforeLayout(): void;
  71331. /** @hidden */
  71332. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71333. /** @hidden */
  71334. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71335. protected _postMeasure(): void;
  71336. /** @hidden */
  71337. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71338. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71339. /** @hidden */
  71340. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71341. /** @hidden */
  71342. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71343. /** Releases associated resources */
  71344. dispose(): void;
  71345. }
  71346. }
  71347. declare module BABYLON.GUI {
  71348. /** Class used to create rectangle container */
  71349. export class Rectangle extends Container {
  71350. name?: string | undefined;
  71351. private _thickness;
  71352. private _cornerRadius;
  71353. /** Gets or sets border thickness */
  71354. get thickness(): number;
  71355. set thickness(value: number);
  71356. /** Gets or sets the corner radius angle */
  71357. get cornerRadius(): number;
  71358. set cornerRadius(value: number);
  71359. /**
  71360. * Creates a new Rectangle
  71361. * @param name defines the control name
  71362. */
  71363. constructor(name?: string | undefined);
  71364. protected _getTypeName(): string;
  71365. protected _localDraw(context: CanvasRenderingContext2D): void;
  71366. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71367. private _drawRoundedRect;
  71368. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71369. }
  71370. }
  71371. declare module BABYLON.GUI {
  71372. /**
  71373. * Enum that determines the text-wrapping mode to use.
  71374. */
  71375. export enum TextWrapping {
  71376. /**
  71377. * Clip the text when it's larger than Control.width; this is the default mode.
  71378. */
  71379. Clip = 0,
  71380. /**
  71381. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71382. */
  71383. WordWrap = 1,
  71384. /**
  71385. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71386. */
  71387. Ellipsis = 2
  71388. }
  71389. /**
  71390. * Class used to create text block control
  71391. */
  71392. export class TextBlock extends Control {
  71393. /**
  71394. * Defines the name of the control
  71395. */
  71396. name?: string | undefined;
  71397. private _text;
  71398. private _textWrapping;
  71399. private _textHorizontalAlignment;
  71400. private _textVerticalAlignment;
  71401. private _lines;
  71402. private _resizeToFit;
  71403. private _lineSpacing;
  71404. private _outlineWidth;
  71405. private _outlineColor;
  71406. /**
  71407. * An event triggered after the text is changed
  71408. */
  71409. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71410. /**
  71411. * An event triggered after the text was broken up into lines
  71412. */
  71413. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71414. /**
  71415. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71416. */
  71417. get lines(): any[];
  71418. /**
  71419. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71420. */
  71421. get resizeToFit(): boolean;
  71422. /**
  71423. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71424. */
  71425. set resizeToFit(value: boolean);
  71426. /**
  71427. * Gets or sets a boolean indicating if text must be wrapped
  71428. */
  71429. get textWrapping(): TextWrapping | boolean;
  71430. /**
  71431. * Gets or sets a boolean indicating if text must be wrapped
  71432. */
  71433. set textWrapping(value: TextWrapping | boolean);
  71434. /**
  71435. * Gets or sets text to display
  71436. */
  71437. get text(): string;
  71438. /**
  71439. * Gets or sets text to display
  71440. */
  71441. set text(value: string);
  71442. /**
  71443. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71444. */
  71445. get textHorizontalAlignment(): number;
  71446. /**
  71447. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71448. */
  71449. set textHorizontalAlignment(value: number);
  71450. /**
  71451. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71452. */
  71453. get textVerticalAlignment(): number;
  71454. /**
  71455. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71456. */
  71457. set textVerticalAlignment(value: number);
  71458. /**
  71459. * Gets or sets line spacing value
  71460. */
  71461. set lineSpacing(value: string | number);
  71462. /**
  71463. * Gets or sets line spacing value
  71464. */
  71465. get lineSpacing(): string | number;
  71466. /**
  71467. * Gets or sets outlineWidth of the text to display
  71468. */
  71469. get outlineWidth(): number;
  71470. /**
  71471. * Gets or sets outlineWidth of the text to display
  71472. */
  71473. set outlineWidth(value: number);
  71474. /**
  71475. * Gets or sets outlineColor of the text to display
  71476. */
  71477. get outlineColor(): string;
  71478. /**
  71479. * Gets or sets outlineColor of the text to display
  71480. */
  71481. set outlineColor(value: string);
  71482. /**
  71483. * Creates a new TextBlock object
  71484. * @param name defines the name of the control
  71485. * @param text defines the text to display (emptry string by default)
  71486. */
  71487. constructor(
  71488. /**
  71489. * Defines the name of the control
  71490. */
  71491. name?: string | undefined, text?: string);
  71492. protected _getTypeName(): string;
  71493. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71494. private _drawText;
  71495. /** @hidden */
  71496. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71497. protected _applyStates(context: CanvasRenderingContext2D): void;
  71498. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71499. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71500. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71501. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71502. protected _renderLines(context: CanvasRenderingContext2D): void;
  71503. /**
  71504. * Given a width constraint applied on the text block, find the expected height
  71505. * @returns expected height
  71506. */
  71507. computeExpectedHeight(): number;
  71508. dispose(): void;
  71509. }
  71510. }
  71511. declare module BABYLON.GUI {
  71512. /**
  71513. * Class used to create 2D images
  71514. */
  71515. export class Image extends Control {
  71516. name?: string | undefined;
  71517. private _workingCanvas;
  71518. private _domImage;
  71519. private _imageWidth;
  71520. private _imageHeight;
  71521. private _loaded;
  71522. private _stretch;
  71523. private _source;
  71524. private _autoScale;
  71525. private _sourceLeft;
  71526. private _sourceTop;
  71527. private _sourceWidth;
  71528. private _sourceHeight;
  71529. private _svgAttributesComputationCompleted;
  71530. private _isSVG;
  71531. private _cellWidth;
  71532. private _cellHeight;
  71533. private _cellId;
  71534. private _populateNinePatchSlicesFromImage;
  71535. private _sliceLeft;
  71536. private _sliceRight;
  71537. private _sliceTop;
  71538. private _sliceBottom;
  71539. private _detectPointerOnOpaqueOnly;
  71540. /**
  71541. * BABYLON.Observable notified when the content is loaded
  71542. */
  71543. onImageLoadedObservable: BABYLON.Observable<Image>;
  71544. /**
  71545. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71546. */
  71547. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71548. /**
  71549. * Gets a boolean indicating that the content is loaded
  71550. */
  71551. get isLoaded(): boolean;
  71552. /**
  71553. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71554. */
  71555. get populateNinePatchSlicesFromImage(): boolean;
  71556. set populateNinePatchSlicesFromImage(value: boolean);
  71557. /**
  71558. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71559. * Beware using this as this will comsume more memory as the image has to be stored twice
  71560. */
  71561. get detectPointerOnOpaqueOnly(): boolean;
  71562. set detectPointerOnOpaqueOnly(value: boolean);
  71563. /**
  71564. * Gets or sets the left value for slicing (9-patch)
  71565. */
  71566. get sliceLeft(): number;
  71567. set sliceLeft(value: number);
  71568. /**
  71569. * Gets or sets the right value for slicing (9-patch)
  71570. */
  71571. get sliceRight(): number;
  71572. set sliceRight(value: number);
  71573. /**
  71574. * Gets or sets the top value for slicing (9-patch)
  71575. */
  71576. get sliceTop(): number;
  71577. set sliceTop(value: number);
  71578. /**
  71579. * Gets or sets the bottom value for slicing (9-patch)
  71580. */
  71581. get sliceBottom(): number;
  71582. set sliceBottom(value: number);
  71583. /**
  71584. * Gets or sets the left coordinate in the source image
  71585. */
  71586. get sourceLeft(): number;
  71587. set sourceLeft(value: number);
  71588. /**
  71589. * Gets or sets the top coordinate in the source image
  71590. */
  71591. get sourceTop(): number;
  71592. set sourceTop(value: number);
  71593. /**
  71594. * Gets or sets the width to capture in the source image
  71595. */
  71596. get sourceWidth(): number;
  71597. set sourceWidth(value: number);
  71598. /**
  71599. * Gets or sets the height to capture in the source image
  71600. */
  71601. get sourceHeight(): number;
  71602. set sourceHeight(value: number);
  71603. /** Indicates if the format of the image is SVG */
  71604. get isSVG(): boolean;
  71605. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71606. get svgAttributesComputationCompleted(): boolean;
  71607. /**
  71608. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71609. * @see http://doc.babylonjs.com/how_to/gui#image
  71610. */
  71611. get autoScale(): boolean;
  71612. set autoScale(value: boolean);
  71613. /** Gets or sets the streching mode used by the image */
  71614. get stretch(): number;
  71615. set stretch(value: number);
  71616. /** @hidden */
  71617. _rotate90(n: number, preserveProperties?: boolean): Image;
  71618. private _handleRotationForSVGImage;
  71619. private _rotate90SourceProperties;
  71620. /**
  71621. * Gets or sets the internal DOM image used to render the control
  71622. */
  71623. set domImage(value: HTMLImageElement);
  71624. get domImage(): HTMLImageElement;
  71625. private _onImageLoaded;
  71626. private _extractNinePatchSliceDataFromImage;
  71627. /**
  71628. * Gets or sets image source url
  71629. */
  71630. set source(value: BABYLON.Nullable<string>);
  71631. /**
  71632. * Checks for svg document with icon id present
  71633. */
  71634. private _svgCheck;
  71635. /**
  71636. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71637. * given external svg file and icon id
  71638. */
  71639. private _getSVGAttribs;
  71640. /**
  71641. * Gets or sets the cell width to use when animation sheet is enabled
  71642. * @see http://doc.babylonjs.com/how_to/gui#image
  71643. */
  71644. get cellWidth(): number;
  71645. set cellWidth(value: number);
  71646. /**
  71647. * Gets or sets the cell height to use when animation sheet is enabled
  71648. * @see http://doc.babylonjs.com/how_to/gui#image
  71649. */
  71650. get cellHeight(): number;
  71651. set cellHeight(value: number);
  71652. /**
  71653. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71654. * @see http://doc.babylonjs.com/how_to/gui#image
  71655. */
  71656. get cellId(): number;
  71657. set cellId(value: number);
  71658. /**
  71659. * Creates a new Image
  71660. * @param name defines the control name
  71661. * @param url defines the image url
  71662. */
  71663. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71664. /**
  71665. * Tests if a given coordinates belong to the current control
  71666. * @param x defines x coordinate to test
  71667. * @param y defines y coordinate to test
  71668. * @returns true if the coordinates are inside the control
  71669. */
  71670. contains(x: number, y: number): boolean;
  71671. protected _getTypeName(): string;
  71672. /** Force the control to synchronize with its content */
  71673. synchronizeSizeWithContent(): void;
  71674. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71675. private _prepareWorkingCanvasForOpaqueDetection;
  71676. private _drawImage;
  71677. _draw(context: CanvasRenderingContext2D): void;
  71678. private _renderCornerPatch;
  71679. private _renderNinePatch;
  71680. dispose(): void;
  71681. /** STRETCH_NONE */
  71682. static readonly STRETCH_NONE: number;
  71683. /** STRETCH_FILL */
  71684. static readonly STRETCH_FILL: number;
  71685. /** STRETCH_UNIFORM */
  71686. static readonly STRETCH_UNIFORM: number;
  71687. /** STRETCH_EXTEND */
  71688. static readonly STRETCH_EXTEND: number;
  71689. /** NINE_PATCH */
  71690. static readonly STRETCH_NINE_PATCH: number;
  71691. }
  71692. }
  71693. declare module BABYLON.GUI {
  71694. /**
  71695. * Class used to create 2D buttons
  71696. */
  71697. export class Button extends Rectangle {
  71698. name?: string | undefined;
  71699. /**
  71700. * Function called to generate a pointer enter animation
  71701. */
  71702. pointerEnterAnimation: () => void;
  71703. /**
  71704. * Function called to generate a pointer out animation
  71705. */
  71706. pointerOutAnimation: () => void;
  71707. /**
  71708. * Function called to generate a pointer down animation
  71709. */
  71710. pointerDownAnimation: () => void;
  71711. /**
  71712. * Function called to generate a pointer up animation
  71713. */
  71714. pointerUpAnimation: () => void;
  71715. /**
  71716. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71717. */
  71718. delegatePickingToChildren: boolean;
  71719. private _image;
  71720. /**
  71721. * Returns the image part of the button (if any)
  71722. */
  71723. get image(): BABYLON.Nullable<Image>;
  71724. private _textBlock;
  71725. /**
  71726. * Returns the image part of the button (if any)
  71727. */
  71728. get textBlock(): BABYLON.Nullable<TextBlock>;
  71729. /**
  71730. * Creates a new Button
  71731. * @param name defines the name of the button
  71732. */
  71733. constructor(name?: string | undefined);
  71734. protected _getTypeName(): string;
  71735. /** @hidden */
  71736. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71737. /** @hidden */
  71738. _onPointerEnter(target: Control): boolean;
  71739. /** @hidden */
  71740. _onPointerOut(target: Control, force?: boolean): void;
  71741. /** @hidden */
  71742. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71743. /** @hidden */
  71744. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71745. /**
  71746. * Creates a new button made with an image and a text
  71747. * @param name defines the name of the button
  71748. * @param text defines the text of the button
  71749. * @param imageUrl defines the url of the image
  71750. * @returns a new Button
  71751. */
  71752. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71753. /**
  71754. * Creates a new button made with an image
  71755. * @param name defines the name of the button
  71756. * @param imageUrl defines the url of the image
  71757. * @returns a new Button
  71758. */
  71759. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71760. /**
  71761. * Creates a new button made with a text
  71762. * @param name defines the name of the button
  71763. * @param text defines the text of the button
  71764. * @returns a new Button
  71765. */
  71766. static CreateSimpleButton(name: string, text: string): Button;
  71767. /**
  71768. * Creates a new button made with an image and a centered text
  71769. * @param name defines the name of the button
  71770. * @param text defines the text of the button
  71771. * @param imageUrl defines the url of the image
  71772. * @returns a new Button
  71773. */
  71774. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71775. }
  71776. }
  71777. declare module BABYLON.GUI {
  71778. /**
  71779. * Class used to create a 2D stack panel container
  71780. */
  71781. export class StackPanel extends Container {
  71782. name?: string | undefined;
  71783. private _isVertical;
  71784. private _manualWidth;
  71785. private _manualHeight;
  71786. private _doNotTrackManualChanges;
  71787. /**
  71788. * Gets or sets a boolean indicating that layou warnings should be ignored
  71789. */
  71790. ignoreLayoutWarnings: boolean;
  71791. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71792. get isVertical(): boolean;
  71793. set isVertical(value: boolean);
  71794. /**
  71795. * Gets or sets panel width.
  71796. * This value should not be set when in horizontal mode as it will be computed automatically
  71797. */
  71798. set width(value: string | number);
  71799. get width(): string | number;
  71800. /**
  71801. * Gets or sets panel height.
  71802. * This value should not be set when in vertical mode as it will be computed automatically
  71803. */
  71804. set height(value: string | number);
  71805. get height(): string | number;
  71806. /**
  71807. * Creates a new StackPanel
  71808. * @param name defines control name
  71809. */
  71810. constructor(name?: string | undefined);
  71811. protected _getTypeName(): string;
  71812. /** @hidden */
  71813. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71814. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71815. protected _postMeasure(): void;
  71816. }
  71817. }
  71818. declare module BABYLON.GUI {
  71819. /**
  71820. * Class used to represent a 2D checkbox
  71821. */
  71822. export class Checkbox extends Control {
  71823. name?: string | undefined;
  71824. private _isChecked;
  71825. private _background;
  71826. private _checkSizeRatio;
  71827. private _thickness;
  71828. /** Gets or sets border thickness */
  71829. get thickness(): number;
  71830. set thickness(value: number);
  71831. /**
  71832. * BABYLON.Observable raised when isChecked property changes
  71833. */
  71834. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71835. /** Gets or sets a value indicating the ratio between overall size and check size */
  71836. get checkSizeRatio(): number;
  71837. set checkSizeRatio(value: number);
  71838. /** Gets or sets background color */
  71839. get background(): string;
  71840. set background(value: string);
  71841. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71842. get isChecked(): boolean;
  71843. set isChecked(value: boolean);
  71844. /**
  71845. * Creates a new CheckBox
  71846. * @param name defines the control name
  71847. */
  71848. constructor(name?: string | undefined);
  71849. protected _getTypeName(): string;
  71850. /** @hidden */
  71851. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71852. /** @hidden */
  71853. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71854. /**
  71855. * Utility function to easily create a checkbox with a header
  71856. * @param title defines the label to use for the header
  71857. * @param onValueChanged defines the callback to call when value changes
  71858. * @returns a StackPanel containing the checkbox and a textBlock
  71859. */
  71860. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71861. }
  71862. }
  71863. declare module BABYLON.GUI {
  71864. /**
  71865. * Class used to store key control properties
  71866. */
  71867. export class KeyPropertySet {
  71868. /** Width */
  71869. width?: string;
  71870. /** Height */
  71871. height?: string;
  71872. /** Left padding */
  71873. paddingLeft?: string;
  71874. /** Right padding */
  71875. paddingRight?: string;
  71876. /** Top padding */
  71877. paddingTop?: string;
  71878. /** Bottom padding */
  71879. paddingBottom?: string;
  71880. /** Foreground color */
  71881. color?: string;
  71882. /** Background color */
  71883. background?: string;
  71884. }
  71885. /**
  71886. * Class used to create virtual keyboard
  71887. */
  71888. export class VirtualKeyboard extends StackPanel {
  71889. /** BABYLON.Observable raised when a key is pressed */
  71890. onKeyPressObservable: BABYLON.Observable<string>;
  71891. /** Gets or sets default key button width */
  71892. defaultButtonWidth: string;
  71893. /** Gets or sets default key button height */
  71894. defaultButtonHeight: string;
  71895. /** Gets or sets default key button left padding */
  71896. defaultButtonPaddingLeft: string;
  71897. /** Gets or sets default key button right padding */
  71898. defaultButtonPaddingRight: string;
  71899. /** Gets or sets default key button top padding */
  71900. defaultButtonPaddingTop: string;
  71901. /** Gets or sets default key button bottom padding */
  71902. defaultButtonPaddingBottom: string;
  71903. /** Gets or sets default key button foreground color */
  71904. defaultButtonColor: string;
  71905. /** Gets or sets default key button background color */
  71906. defaultButtonBackground: string;
  71907. /** Gets or sets shift button foreground color */
  71908. shiftButtonColor: string;
  71909. /** Gets or sets shift button thickness*/
  71910. selectedShiftThickness: number;
  71911. /** Gets shift key state */
  71912. shiftState: number;
  71913. protected _getTypeName(): string;
  71914. private _createKey;
  71915. /**
  71916. * Adds a new row of keys
  71917. * @param keys defines the list of keys to add
  71918. * @param propertySets defines the associated property sets
  71919. */
  71920. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71921. /**
  71922. * Set the shift key to a specific state
  71923. * @param shiftState defines the new shift state
  71924. */
  71925. applyShiftState(shiftState: number): void;
  71926. private _currentlyConnectedInputText;
  71927. private _connectedInputTexts;
  71928. private _onKeyPressObserver;
  71929. /** Gets the input text control currently attached to the keyboard */
  71930. get connectedInputText(): BABYLON.Nullable<InputText>;
  71931. /**
  71932. * Connects the keyboard with an input text control
  71933. *
  71934. * @param input defines the target control
  71935. */
  71936. connect(input: InputText): void;
  71937. /**
  71938. * Disconnects the keyboard from connected InputText controls
  71939. *
  71940. * @param input optionally defines a target control, otherwise all are disconnected
  71941. */
  71942. disconnect(input?: InputText): void;
  71943. private _removeConnectedInputObservables;
  71944. /**
  71945. * Release all resources
  71946. */
  71947. dispose(): void;
  71948. /**
  71949. * Creates a new keyboard using a default layout
  71950. *
  71951. * @param name defines control name
  71952. * @returns a new VirtualKeyboard
  71953. */
  71954. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71955. }
  71956. }
  71957. declare module BABYLON.GUI {
  71958. /**
  71959. * Class used to create input text control
  71960. */
  71961. export class InputText extends Control implements IFocusableControl {
  71962. name?: string | undefined;
  71963. private _text;
  71964. private _placeholderText;
  71965. private _background;
  71966. private _focusedBackground;
  71967. private _focusedColor;
  71968. private _placeholderColor;
  71969. private _thickness;
  71970. private _margin;
  71971. private _autoStretchWidth;
  71972. private _maxWidth;
  71973. private _isFocused;
  71974. private _blinkTimeout;
  71975. private _blinkIsEven;
  71976. private _cursorOffset;
  71977. private _scrollLeft;
  71978. private _textWidth;
  71979. private _clickedCoordinate;
  71980. private _deadKey;
  71981. private _addKey;
  71982. private _currentKey;
  71983. private _isTextHighlightOn;
  71984. private _textHighlightColor;
  71985. private _highligherOpacity;
  71986. private _highlightedText;
  71987. private _startHighlightIndex;
  71988. private _endHighlightIndex;
  71989. private _cursorIndex;
  71990. private _onFocusSelectAll;
  71991. private _isPointerDown;
  71992. private _onClipboardObserver;
  71993. private _onPointerDblTapObserver;
  71994. /** @hidden */
  71995. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71996. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71997. promptMessage: string;
  71998. /** Force disable prompt on mobile device */
  71999. disableMobilePrompt: boolean;
  72000. /** BABYLON.Observable raised when the text changes */
  72001. onTextChangedObservable: BABYLON.Observable<InputText>;
  72002. /** BABYLON.Observable raised just before an entered character is to be added */
  72003. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72004. /** BABYLON.Observable raised when the control gets the focus */
  72005. onFocusObservable: BABYLON.Observable<InputText>;
  72006. /** BABYLON.Observable raised when the control loses the focus */
  72007. onBlurObservable: BABYLON.Observable<InputText>;
  72008. /**Observable raised when the text is highlighted */
  72009. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72010. /**Observable raised when copy event is triggered */
  72011. onTextCopyObservable: BABYLON.Observable<InputText>;
  72012. /** BABYLON.Observable raised when cut event is triggered */
  72013. onTextCutObservable: BABYLON.Observable<InputText>;
  72014. /** BABYLON.Observable raised when paste event is triggered */
  72015. onTextPasteObservable: BABYLON.Observable<InputText>;
  72016. /** BABYLON.Observable raised when a key event was processed */
  72017. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72018. /** Gets or sets the maximum width allowed by the control */
  72019. get maxWidth(): string | number;
  72020. /** Gets the maximum width allowed by the control in pixels */
  72021. get maxWidthInPixels(): number;
  72022. set maxWidth(value: string | number);
  72023. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72024. get highligherOpacity(): number;
  72025. set highligherOpacity(value: number);
  72026. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72027. get onFocusSelectAll(): boolean;
  72028. set onFocusSelectAll(value: boolean);
  72029. /** Gets or sets the text hightlight color */
  72030. get textHighlightColor(): string;
  72031. set textHighlightColor(value: string);
  72032. /** Gets or sets control margin */
  72033. get margin(): string;
  72034. /** Gets control margin in pixels */
  72035. get marginInPixels(): number;
  72036. set margin(value: string);
  72037. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72038. get autoStretchWidth(): boolean;
  72039. set autoStretchWidth(value: boolean);
  72040. /** Gets or sets border thickness */
  72041. get thickness(): number;
  72042. set thickness(value: number);
  72043. /** Gets or sets the background color when focused */
  72044. get focusedBackground(): string;
  72045. set focusedBackground(value: string);
  72046. /** Gets or sets the background color when focused */
  72047. get focusedColor(): string;
  72048. set focusedColor(value: string);
  72049. /** Gets or sets the background color */
  72050. get background(): string;
  72051. set background(value: string);
  72052. /** Gets or sets the placeholder color */
  72053. get placeholderColor(): string;
  72054. set placeholderColor(value: string);
  72055. /** Gets or sets the text displayed when the control is empty */
  72056. get placeholderText(): string;
  72057. set placeholderText(value: string);
  72058. /** Gets or sets the dead key flag */
  72059. get deadKey(): boolean;
  72060. set deadKey(flag: boolean);
  72061. /** Gets or sets the highlight text */
  72062. get highlightedText(): string;
  72063. set highlightedText(text: string);
  72064. /** Gets or sets if the current key should be added */
  72065. get addKey(): boolean;
  72066. set addKey(flag: boolean);
  72067. /** Gets or sets the value of the current key being entered */
  72068. get currentKey(): string;
  72069. set currentKey(key: string);
  72070. /** Gets or sets the text displayed in the control */
  72071. get text(): string;
  72072. set text(value: string);
  72073. /** Gets or sets control width */
  72074. get width(): string | number;
  72075. set width(value: string | number);
  72076. /**
  72077. * Creates a new InputText
  72078. * @param name defines the control name
  72079. * @param text defines the text of the control
  72080. */
  72081. constructor(name?: string | undefined, text?: string);
  72082. /** @hidden */
  72083. onBlur(): void;
  72084. /** @hidden */
  72085. onFocus(): void;
  72086. protected _getTypeName(): string;
  72087. /**
  72088. * Function called to get the list of controls that should not steal the focus from this control
  72089. * @returns an array of controls
  72090. */
  72091. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72092. /** @hidden */
  72093. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72094. /** @hidden */
  72095. private _updateValueFromCursorIndex;
  72096. /** @hidden */
  72097. private _processDblClick;
  72098. /** @hidden */
  72099. private _selectAllText;
  72100. /**
  72101. * Handles the keyboard event
  72102. * @param evt Defines the KeyboardEvent
  72103. */
  72104. processKeyboard(evt: KeyboardEvent): void;
  72105. /** @hidden */
  72106. private _onCopyText;
  72107. /** @hidden */
  72108. private _onCutText;
  72109. /** @hidden */
  72110. private _onPasteText;
  72111. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72112. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72113. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72114. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72115. protected _beforeRenderText(text: string): string;
  72116. dispose(): void;
  72117. }
  72118. }
  72119. declare module BABYLON.GUI {
  72120. /**
  72121. * Class used to create a 2D grid container
  72122. */
  72123. export class Grid extends Container {
  72124. name?: string | undefined;
  72125. private _rowDefinitions;
  72126. private _columnDefinitions;
  72127. private _cells;
  72128. private _childControls;
  72129. /**
  72130. * Gets the number of columns
  72131. */
  72132. get columnCount(): number;
  72133. /**
  72134. * Gets the number of rows
  72135. */
  72136. get rowCount(): number;
  72137. /** Gets the list of children */
  72138. get children(): Control[];
  72139. /** Gets the list of cells (e.g. the containers) */
  72140. get cells(): {
  72141. [key: string]: Container;
  72142. };
  72143. /**
  72144. * Gets the definition of a specific row
  72145. * @param index defines the index of the row
  72146. * @returns the row definition
  72147. */
  72148. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72149. /**
  72150. * Gets the definition of a specific column
  72151. * @param index defines the index of the column
  72152. * @returns the column definition
  72153. */
  72154. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72155. /**
  72156. * Adds a new row to the grid
  72157. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72158. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72159. * @returns the current grid
  72160. */
  72161. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72162. /**
  72163. * Adds a new column to the grid
  72164. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72165. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72166. * @returns the current grid
  72167. */
  72168. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72169. /**
  72170. * Update a row definition
  72171. * @param index defines the index of the row to update
  72172. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72173. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72174. * @returns the current grid
  72175. */
  72176. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72177. /**
  72178. * Update a column definition
  72179. * @param index defines the index of the column to update
  72180. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72181. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72182. * @returns the current grid
  72183. */
  72184. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72185. /**
  72186. * Gets the list of children stored in a specific cell
  72187. * @param row defines the row to check
  72188. * @param column defines the column to check
  72189. * @returns the list of controls
  72190. */
  72191. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72192. /**
  72193. * Gets a string representing the child cell info (row x column)
  72194. * @param child defines the control to get info from
  72195. * @returns a string containing the child cell info (row x column)
  72196. */
  72197. getChildCellInfo(child: Control): string;
  72198. private _removeCell;
  72199. private _offsetCell;
  72200. /**
  72201. * Remove a column definition at specified index
  72202. * @param index defines the index of the column to remove
  72203. * @returns the current grid
  72204. */
  72205. removeColumnDefinition(index: number): Grid;
  72206. /**
  72207. * Remove a row definition at specified index
  72208. * @param index defines the index of the row to remove
  72209. * @returns the current grid
  72210. */
  72211. removeRowDefinition(index: number): Grid;
  72212. /**
  72213. * Adds a new control to the current grid
  72214. * @param control defines the control to add
  72215. * @param row defines the row where to add the control (0 by default)
  72216. * @param column defines the column where to add the control (0 by default)
  72217. * @returns the current grid
  72218. */
  72219. addControl(control: Control, row?: number, column?: number): Grid;
  72220. /**
  72221. * Removes a control from the current container
  72222. * @param control defines the control to remove
  72223. * @returns the current container
  72224. */
  72225. removeControl(control: Control): Container;
  72226. /**
  72227. * Creates a new Grid
  72228. * @param name defines control name
  72229. */
  72230. constructor(name?: string | undefined);
  72231. protected _getTypeName(): string;
  72232. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72233. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72234. _flagDescendantsAsMatrixDirty(): void;
  72235. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72236. /** Releases associated resources */
  72237. dispose(): void;
  72238. }
  72239. }
  72240. declare module BABYLON.GUI {
  72241. /** Class used to create color pickers */
  72242. export class ColorPicker extends Control {
  72243. name?: string | undefined;
  72244. private static _Epsilon;
  72245. private _colorWheelCanvas;
  72246. private _value;
  72247. private _tmpColor;
  72248. private _pointerStartedOnSquare;
  72249. private _pointerStartedOnWheel;
  72250. private _squareLeft;
  72251. private _squareTop;
  72252. private _squareSize;
  72253. private _h;
  72254. private _s;
  72255. private _v;
  72256. private _lastPointerDownID;
  72257. /**
  72258. * BABYLON.Observable raised when the value changes
  72259. */
  72260. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72261. /** Gets or sets the color of the color picker */
  72262. get value(): BABYLON.Color3;
  72263. set value(value: BABYLON.Color3);
  72264. /**
  72265. * Gets or sets control width
  72266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72267. */
  72268. get width(): string | number;
  72269. set width(value: string | number);
  72270. /**
  72271. * Gets or sets control height
  72272. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72273. */
  72274. get height(): string | number;
  72275. /** Gets or sets control height */
  72276. set height(value: string | number);
  72277. /** Gets or sets control size */
  72278. get size(): string | number;
  72279. set size(value: string | number);
  72280. /**
  72281. * Creates a new ColorPicker
  72282. * @param name defines the control name
  72283. */
  72284. constructor(name?: string | undefined);
  72285. protected _getTypeName(): string;
  72286. /** @hidden */
  72287. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72288. private _updateSquareProps;
  72289. private _drawGradientSquare;
  72290. private _drawCircle;
  72291. private _createColorWheelCanvas;
  72292. /** @hidden */
  72293. _draw(context: CanvasRenderingContext2D): void;
  72294. private _pointerIsDown;
  72295. private _updateValueFromPointer;
  72296. private _isPointOnSquare;
  72297. private _isPointOnWheel;
  72298. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72299. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72300. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72301. /**
  72302. * This function expands the color picker by creating a color picker dialog with manual
  72303. * color value input and the ability to save colors into an array to be used later in
  72304. * subsequent launches of the dialogue.
  72305. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72306. * @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.
  72307. * @returns picked color as a hex string and the saved colors array as hex strings.
  72308. */
  72309. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72310. pickerWidth?: string;
  72311. pickerHeight?: string;
  72312. headerHeight?: string;
  72313. lastColor?: string;
  72314. swatchLimit?: number;
  72315. numSwatchesPerLine?: number;
  72316. savedColors?: Array<string>;
  72317. }): Promise<{
  72318. savedColors?: string[];
  72319. pickedColor: string;
  72320. }>;
  72321. }
  72322. }
  72323. declare module BABYLON.GUI {
  72324. /** Class used to create 2D ellipse containers */
  72325. export class Ellipse extends Container {
  72326. name?: string | undefined;
  72327. private _thickness;
  72328. /** Gets or sets border thickness */
  72329. get thickness(): number;
  72330. set thickness(value: number);
  72331. /**
  72332. * Creates a new Ellipse
  72333. * @param name defines the control name
  72334. */
  72335. constructor(name?: string | undefined);
  72336. protected _getTypeName(): string;
  72337. protected _localDraw(context: CanvasRenderingContext2D): void;
  72338. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72339. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72340. }
  72341. }
  72342. declare module BABYLON.GUI {
  72343. /**
  72344. * Class used to create a password control
  72345. */
  72346. export class InputPassword extends InputText {
  72347. protected _beforeRenderText(text: string): string;
  72348. }
  72349. }
  72350. declare module BABYLON.GUI {
  72351. /** Class used to render 2D lines */
  72352. export class Line extends Control {
  72353. name?: string | undefined;
  72354. private _lineWidth;
  72355. private _x1;
  72356. private _y1;
  72357. private _x2;
  72358. private _y2;
  72359. private _dash;
  72360. private _connectedControl;
  72361. private _connectedControlDirtyObserver;
  72362. /** Gets or sets the dash pattern */
  72363. get dash(): Array<number>;
  72364. set dash(value: Array<number>);
  72365. /** Gets or sets the control connected with the line end */
  72366. get connectedControl(): Control;
  72367. set connectedControl(value: Control);
  72368. /** Gets or sets start coordinates on X axis */
  72369. get x1(): string | number;
  72370. set x1(value: string | number);
  72371. /** Gets or sets start coordinates on Y axis */
  72372. get y1(): string | number;
  72373. set y1(value: string | number);
  72374. /** Gets or sets end coordinates on X axis */
  72375. get x2(): string | number;
  72376. set x2(value: string | number);
  72377. /** Gets or sets end coordinates on Y axis */
  72378. get y2(): string | number;
  72379. set y2(value: string | number);
  72380. /** Gets or sets line width */
  72381. get lineWidth(): number;
  72382. set lineWidth(value: number);
  72383. /** Gets or sets horizontal alignment */
  72384. set horizontalAlignment(value: number);
  72385. /** Gets or sets vertical alignment */
  72386. set verticalAlignment(value: number);
  72387. private get _effectiveX2();
  72388. private get _effectiveY2();
  72389. /**
  72390. * Creates a new Line
  72391. * @param name defines the control name
  72392. */
  72393. constructor(name?: string | undefined);
  72394. protected _getTypeName(): string;
  72395. _draw(context: CanvasRenderingContext2D): void;
  72396. _measure(): void;
  72397. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72398. /**
  72399. * Move one end of the line given 3D cartesian coordinates.
  72400. * @param position Targeted world position
  72401. * @param scene BABYLON.Scene
  72402. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72403. */
  72404. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72405. /**
  72406. * Move one end of the line to a position in screen absolute space.
  72407. * @param projectedPosition Position in screen absolute space (X, Y)
  72408. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72409. */
  72410. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72411. }
  72412. }
  72413. declare module BABYLON.GUI {
  72414. /**
  72415. * Class used to store a point for a MultiLine object.
  72416. * The point can be pure 2D coordinates, a mesh or a control
  72417. */
  72418. export class MultiLinePoint {
  72419. private _multiLine;
  72420. private _x;
  72421. private _y;
  72422. private _control;
  72423. private _mesh;
  72424. private _controlObserver;
  72425. private _meshObserver;
  72426. /** @hidden */
  72427. _point: BABYLON.Vector2;
  72428. /**
  72429. * Creates a new MultiLinePoint
  72430. * @param multiLine defines the source MultiLine object
  72431. */
  72432. constructor(multiLine: MultiLine);
  72433. /** Gets or sets x coordinate */
  72434. get x(): string | number;
  72435. set x(value: string | number);
  72436. /** Gets or sets y coordinate */
  72437. get y(): string | number;
  72438. set y(value: string | number);
  72439. /** Gets or sets the control associated with this point */
  72440. get control(): BABYLON.Nullable<Control>;
  72441. set control(value: BABYLON.Nullable<Control>);
  72442. /** Gets or sets the mesh associated with this point */
  72443. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72444. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72445. /** Resets links */
  72446. resetLinks(): void;
  72447. /**
  72448. * Gets a translation vector
  72449. * @returns the translation vector
  72450. */
  72451. translate(): BABYLON.Vector2;
  72452. private _translatePoint;
  72453. /** Release associated resources */
  72454. dispose(): void;
  72455. }
  72456. }
  72457. declare module BABYLON.GUI {
  72458. /**
  72459. * Class used to create multi line control
  72460. */
  72461. export class MultiLine extends Control {
  72462. name?: string | undefined;
  72463. private _lineWidth;
  72464. private _dash;
  72465. private _points;
  72466. private _minX;
  72467. private _minY;
  72468. private _maxX;
  72469. private _maxY;
  72470. /**
  72471. * Creates a new MultiLine
  72472. * @param name defines the control name
  72473. */
  72474. constructor(name?: string | undefined);
  72475. /** Gets or sets dash pattern */
  72476. get dash(): Array<number>;
  72477. set dash(value: Array<number>);
  72478. /**
  72479. * Gets point stored at specified index
  72480. * @param index defines the index to look for
  72481. * @returns the requested point if found
  72482. */
  72483. getAt(index: number): MultiLinePoint;
  72484. /** Function called when a point is updated */
  72485. onPointUpdate: () => void;
  72486. /**
  72487. * Adds new points to the point collection
  72488. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72489. * @returns the list of created MultiLinePoint
  72490. */
  72491. add(...items: (AbstractMesh | Control | {
  72492. x: string | number;
  72493. y: string | number;
  72494. })[]): MultiLinePoint[];
  72495. /**
  72496. * Adds a new point to the point collection
  72497. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72498. * @returns the created MultiLinePoint
  72499. */
  72500. push(item?: (AbstractMesh | Control | {
  72501. x: string | number;
  72502. y: string | number;
  72503. })): MultiLinePoint;
  72504. /**
  72505. * Remove a specific value or point from the active point collection
  72506. * @param value defines the value or point to remove
  72507. */
  72508. remove(value: number | MultiLinePoint): void;
  72509. /**
  72510. * Resets this object to initial state (no point)
  72511. */
  72512. reset(): void;
  72513. /**
  72514. * Resets all links
  72515. */
  72516. resetLinks(): void;
  72517. /** Gets or sets line width */
  72518. get lineWidth(): number;
  72519. set lineWidth(value: number);
  72520. set horizontalAlignment(value: number);
  72521. set verticalAlignment(value: number);
  72522. protected _getTypeName(): string;
  72523. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72524. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72525. _measure(): void;
  72526. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72527. dispose(): void;
  72528. }
  72529. }
  72530. declare module BABYLON.GUI {
  72531. /**
  72532. * Class used to create radio button controls
  72533. */
  72534. export class RadioButton extends Control {
  72535. name?: string | undefined;
  72536. private _isChecked;
  72537. private _background;
  72538. private _checkSizeRatio;
  72539. private _thickness;
  72540. /** Gets or sets border thickness */
  72541. get thickness(): number;
  72542. set thickness(value: number);
  72543. /** Gets or sets group name */
  72544. group: string;
  72545. /** BABYLON.Observable raised when isChecked is changed */
  72546. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72547. /** Gets or sets a value indicating the ratio between overall size and check size */
  72548. get checkSizeRatio(): number;
  72549. set checkSizeRatio(value: number);
  72550. /** Gets or sets background color */
  72551. get background(): string;
  72552. set background(value: string);
  72553. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72554. get isChecked(): boolean;
  72555. set isChecked(value: boolean);
  72556. /**
  72557. * Creates a new RadioButton
  72558. * @param name defines the control name
  72559. */
  72560. constructor(name?: string | undefined);
  72561. protected _getTypeName(): string;
  72562. _draw(context: CanvasRenderingContext2D): void;
  72563. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72564. /**
  72565. * Utility function to easily create a radio button with a header
  72566. * @param title defines the label to use for the header
  72567. * @param group defines the group to use for the radio button
  72568. * @param isChecked defines the initial state of the radio button
  72569. * @param onValueChanged defines the callback to call when value changes
  72570. * @returns a StackPanel containing the radio button and a textBlock
  72571. */
  72572. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72573. }
  72574. }
  72575. declare module BABYLON.GUI {
  72576. /**
  72577. * Class used to create slider controls
  72578. */
  72579. export class BaseSlider extends Control {
  72580. name?: string | undefined;
  72581. protected _thumbWidth: ValueAndUnit;
  72582. private _minimum;
  72583. private _maximum;
  72584. private _value;
  72585. private _isVertical;
  72586. protected _barOffset: ValueAndUnit;
  72587. private _isThumbClamped;
  72588. protected _displayThumb: boolean;
  72589. private _step;
  72590. private _lastPointerDownID;
  72591. protected _effectiveBarOffset: number;
  72592. protected _renderLeft: number;
  72593. protected _renderTop: number;
  72594. protected _renderWidth: number;
  72595. protected _renderHeight: number;
  72596. protected _backgroundBoxLength: number;
  72597. protected _backgroundBoxThickness: number;
  72598. protected _effectiveThumbThickness: number;
  72599. /** BABYLON.Observable raised when the sldier value changes */
  72600. onValueChangedObservable: BABYLON.Observable<number>;
  72601. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72602. get displayThumb(): boolean;
  72603. set displayThumb(value: boolean);
  72604. /** Gets or sets a step to apply to values (0 by default) */
  72605. get step(): number;
  72606. set step(value: number);
  72607. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72608. get barOffset(): string | number;
  72609. /** Gets main bar offset in pixels*/
  72610. get barOffsetInPixels(): number;
  72611. set barOffset(value: string | number);
  72612. /** Gets or sets thumb width */
  72613. get thumbWidth(): string | number;
  72614. /** Gets thumb width in pixels */
  72615. get thumbWidthInPixels(): number;
  72616. set thumbWidth(value: string | number);
  72617. /** Gets or sets minimum value */
  72618. get minimum(): number;
  72619. set minimum(value: number);
  72620. /** Gets or sets maximum value */
  72621. get maximum(): number;
  72622. set maximum(value: number);
  72623. /** Gets or sets current value */
  72624. get value(): number;
  72625. set value(value: number);
  72626. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72627. get isVertical(): boolean;
  72628. set isVertical(value: boolean);
  72629. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72630. get isThumbClamped(): boolean;
  72631. set isThumbClamped(value: boolean);
  72632. /**
  72633. * Creates a new BaseSlider
  72634. * @param name defines the control name
  72635. */
  72636. constructor(name?: string | undefined);
  72637. protected _getTypeName(): string;
  72638. protected _getThumbPosition(): number;
  72639. protected _getThumbThickness(type: string): number;
  72640. protected _prepareRenderingData(type: string): void;
  72641. private _pointerIsDown;
  72642. /** @hidden */
  72643. protected _updateValueFromPointer(x: number, y: number): void;
  72644. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72645. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72646. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72647. }
  72648. }
  72649. declare module BABYLON.GUI {
  72650. /**
  72651. * Class used to create slider controls
  72652. */
  72653. export class Slider extends BaseSlider {
  72654. name?: string | undefined;
  72655. private _background;
  72656. private _borderColor;
  72657. private _isThumbCircle;
  72658. protected _displayValueBar: boolean;
  72659. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72660. get displayValueBar(): boolean;
  72661. set displayValueBar(value: boolean);
  72662. /** Gets or sets border color */
  72663. get borderColor(): string;
  72664. set borderColor(value: string);
  72665. /** Gets or sets background color */
  72666. get background(): string;
  72667. set background(value: string);
  72668. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72669. get isThumbCircle(): boolean;
  72670. set isThumbCircle(value: boolean);
  72671. /**
  72672. * Creates a new Slider
  72673. * @param name defines the control name
  72674. */
  72675. constructor(name?: string | undefined);
  72676. protected _getTypeName(): string;
  72677. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72678. }
  72679. }
  72680. declare module BABYLON.GUI {
  72681. /** Class used to create a RadioGroup
  72682. * which contains groups of radio buttons
  72683. */
  72684. export class SelectorGroup {
  72685. /** name of SelectorGroup */
  72686. name: string;
  72687. private _groupPanel;
  72688. private _selectors;
  72689. private _groupHeader;
  72690. /**
  72691. * Creates a new SelectorGroup
  72692. * @param name of group, used as a group heading
  72693. */
  72694. constructor(
  72695. /** name of SelectorGroup */
  72696. name: string);
  72697. /** Gets the groupPanel of the SelectorGroup */
  72698. get groupPanel(): StackPanel;
  72699. /** Gets the selectors array */
  72700. get selectors(): StackPanel[];
  72701. /** Gets and sets the group header */
  72702. get header(): string;
  72703. set header(label: string);
  72704. /** @hidden */
  72705. private _addGroupHeader;
  72706. /** @hidden*/
  72707. _getSelector(selectorNb: number): StackPanel | undefined;
  72708. /** Removes the selector at the given position
  72709. * @param selectorNb the position of the selector within the group
  72710. */
  72711. removeSelector(selectorNb: number): void;
  72712. }
  72713. /** Class used to create a CheckboxGroup
  72714. * which contains groups of checkbox buttons
  72715. */
  72716. export class CheckboxGroup extends SelectorGroup {
  72717. /** Adds a checkbox as a control
  72718. * @param text is the label for the selector
  72719. * @param func is the function called when the Selector is checked
  72720. * @param checked is true when Selector is checked
  72721. */
  72722. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72723. /** @hidden */
  72724. _setSelectorLabel(selectorNb: number, label: string): void;
  72725. /** @hidden */
  72726. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72727. /** @hidden */
  72728. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72729. /** @hidden */
  72730. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72731. }
  72732. /** Class used to create a RadioGroup
  72733. * which contains groups of radio buttons
  72734. */
  72735. export class RadioGroup extends SelectorGroup {
  72736. private _selectNb;
  72737. /** Adds a radio button as a control
  72738. * @param label is the label for the selector
  72739. * @param func is the function called when the Selector is checked
  72740. * @param checked is true when Selector is checked
  72741. */
  72742. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72743. /** @hidden */
  72744. _setSelectorLabel(selectorNb: number, label: string): void;
  72745. /** @hidden */
  72746. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72747. /** @hidden */
  72748. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72749. /** @hidden */
  72750. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72751. }
  72752. /** Class used to create a SliderGroup
  72753. * which contains groups of slider buttons
  72754. */
  72755. export class SliderGroup extends SelectorGroup {
  72756. /**
  72757. * Adds a slider to the SelectorGroup
  72758. * @param label is the label for the SliderBar
  72759. * @param func is the function called when the Slider moves
  72760. * @param unit is a string describing the units used, eg degrees or metres
  72761. * @param min is the minimum value for the Slider
  72762. * @param max is the maximum value for the Slider
  72763. * @param value is the start value for the Slider between min and max
  72764. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72765. */
  72766. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72767. /** @hidden */
  72768. _setSelectorLabel(selectorNb: number, label: string): void;
  72769. /** @hidden */
  72770. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72771. /** @hidden */
  72772. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72773. /** @hidden */
  72774. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72775. }
  72776. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72777. * @see http://doc.babylonjs.com/how_to/selector
  72778. */
  72779. export class SelectionPanel extends Rectangle {
  72780. /** name of SelectionPanel */
  72781. name: string;
  72782. /** an array of SelectionGroups */
  72783. groups: SelectorGroup[];
  72784. private _panel;
  72785. private _buttonColor;
  72786. private _buttonBackground;
  72787. private _headerColor;
  72788. private _barColor;
  72789. private _barHeight;
  72790. private _spacerHeight;
  72791. private _labelColor;
  72792. private _groups;
  72793. private _bars;
  72794. /**
  72795. * Creates a new SelectionPanel
  72796. * @param name of SelectionPanel
  72797. * @param groups is an array of SelectionGroups
  72798. */
  72799. constructor(
  72800. /** name of SelectionPanel */
  72801. name: string,
  72802. /** an array of SelectionGroups */
  72803. groups?: SelectorGroup[]);
  72804. protected _getTypeName(): string;
  72805. /** Gets or sets the headerColor */
  72806. get headerColor(): string;
  72807. set headerColor(color: string);
  72808. private _setHeaderColor;
  72809. /** Gets or sets the button color */
  72810. get buttonColor(): string;
  72811. set buttonColor(color: string);
  72812. private _setbuttonColor;
  72813. /** Gets or sets the label color */
  72814. get labelColor(): string;
  72815. set labelColor(color: string);
  72816. private _setLabelColor;
  72817. /** Gets or sets the button background */
  72818. get buttonBackground(): string;
  72819. set buttonBackground(color: string);
  72820. private _setButtonBackground;
  72821. /** Gets or sets the color of separator bar */
  72822. get barColor(): string;
  72823. set barColor(color: string);
  72824. private _setBarColor;
  72825. /** Gets or sets the height of separator bar */
  72826. get barHeight(): string;
  72827. set barHeight(value: string);
  72828. private _setBarHeight;
  72829. /** Gets or sets the height of spacers*/
  72830. get spacerHeight(): string;
  72831. set spacerHeight(value: string);
  72832. private _setSpacerHeight;
  72833. /** Adds a bar between groups */
  72834. private _addSpacer;
  72835. /** Add a group to the selection panel
  72836. * @param group is the selector group to add
  72837. */
  72838. addGroup(group: SelectorGroup): void;
  72839. /** Remove the group from the given position
  72840. * @param groupNb is the position of the group in the list
  72841. */
  72842. removeGroup(groupNb: number): void;
  72843. /** Change a group header label
  72844. * @param label is the new group header label
  72845. * @param groupNb is the number of the group to relabel
  72846. * */
  72847. setHeaderName(label: string, groupNb: number): void;
  72848. /** Change selector label to the one given
  72849. * @param label is the new selector label
  72850. * @param groupNb is the number of the groupcontaining the selector
  72851. * @param selectorNb is the number of the selector within a group to relabel
  72852. * */
  72853. relabel(label: string, groupNb: number, selectorNb: number): void;
  72854. /** For a given group position remove the selector at the given position
  72855. * @param groupNb is the number of the group to remove the selector from
  72856. * @param selectorNb is the number of the selector within the group
  72857. */
  72858. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72859. /** For a given group position of correct type add a checkbox button
  72860. * @param groupNb is the number of the group to remove the selector from
  72861. * @param label is the label for the selector
  72862. * @param func is the function called when the Selector is checked
  72863. * @param checked is true when Selector is checked
  72864. */
  72865. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72866. /** For a given group position of correct type add a radio button
  72867. * @param groupNb is the number of the group to remove the selector from
  72868. * @param label is the label for the selector
  72869. * @param func is the function called when the Selector is checked
  72870. * @param checked is true when Selector is checked
  72871. */
  72872. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72873. /**
  72874. * For a given slider group add a slider
  72875. * @param groupNb is the number of the group to add the slider to
  72876. * @param label is the label for the Slider
  72877. * @param func is the function called when the Slider moves
  72878. * @param unit is a string describing the units used, eg degrees or metres
  72879. * @param min is the minimum value for the Slider
  72880. * @param max is the maximum value for the Slider
  72881. * @param value is the start value for the Slider between min and max
  72882. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72883. */
  72884. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72885. }
  72886. }
  72887. declare module BABYLON.GUI {
  72888. /**
  72889. * Class used to hold a the container for ScrollViewer
  72890. * @hidden
  72891. */
  72892. export class _ScrollViewerWindow extends Container {
  72893. parentClientWidth: number;
  72894. parentClientHeight: number;
  72895. private _freezeControls;
  72896. private _parentMeasure;
  72897. private _oldLeft;
  72898. private _oldTop;
  72899. get freezeControls(): boolean;
  72900. set freezeControls(value: boolean);
  72901. private _bucketWidth;
  72902. private _bucketHeight;
  72903. private _buckets;
  72904. private _bucketLen;
  72905. get bucketWidth(): number;
  72906. get bucketHeight(): number;
  72907. setBucketSizes(width: number, height: number): void;
  72908. private _useBuckets;
  72909. private _makeBuckets;
  72910. private _dispatchInBuckets;
  72911. private _updateMeasures;
  72912. private _updateChildrenMeasures;
  72913. /**
  72914. * Creates a new ScrollViewerWindow
  72915. * @param name of ScrollViewerWindow
  72916. */
  72917. constructor(name?: string);
  72918. protected _getTypeName(): string;
  72919. /** @hidden */
  72920. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72921. /** @hidden */
  72922. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72923. private _scrollChildren;
  72924. private _scrollChildrenWithBuckets;
  72925. /** @hidden */
  72926. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72927. protected _postMeasure(): void;
  72928. }
  72929. }
  72930. declare module BABYLON.GUI {
  72931. /**
  72932. * Class used to create slider controls
  72933. */
  72934. export class ScrollBar extends BaseSlider {
  72935. name?: string | undefined;
  72936. private _background;
  72937. private _borderColor;
  72938. private _tempMeasure;
  72939. /** Gets or sets border color */
  72940. get borderColor(): string;
  72941. set borderColor(value: string);
  72942. /** Gets or sets background color */
  72943. get background(): string;
  72944. set background(value: string);
  72945. /**
  72946. * Creates a new Slider
  72947. * @param name defines the control name
  72948. */
  72949. constructor(name?: string | undefined);
  72950. protected _getTypeName(): string;
  72951. protected _getThumbThickness(): number;
  72952. _draw(context: CanvasRenderingContext2D): void;
  72953. private _first;
  72954. private _originX;
  72955. private _originY;
  72956. /** @hidden */
  72957. protected _updateValueFromPointer(x: number, y: number): void;
  72958. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72959. }
  72960. }
  72961. declare module BABYLON.GUI {
  72962. /**
  72963. * Class used to create slider controls
  72964. */
  72965. export class ImageScrollBar extends BaseSlider {
  72966. name?: string | undefined;
  72967. private _backgroundBaseImage;
  72968. private _backgroundImage;
  72969. private _thumbImage;
  72970. private _thumbBaseImage;
  72971. private _thumbLength;
  72972. private _thumbHeight;
  72973. private _barImageHeight;
  72974. private _tempMeasure;
  72975. /** Number of 90° rotation to apply on the images when in vertical mode */
  72976. num90RotationInVerticalMode: number;
  72977. /**
  72978. * Gets or sets the image used to render the background for horizontal bar
  72979. */
  72980. get backgroundImage(): Image;
  72981. set backgroundImage(value: Image);
  72982. /**
  72983. * Gets or sets the image used to render the thumb
  72984. */
  72985. get thumbImage(): Image;
  72986. set thumbImage(value: Image);
  72987. /**
  72988. * Gets or sets the length of the thumb
  72989. */
  72990. get thumbLength(): number;
  72991. set thumbLength(value: number);
  72992. /**
  72993. * Gets or sets the height of the thumb
  72994. */
  72995. get thumbHeight(): number;
  72996. set thumbHeight(value: number);
  72997. /**
  72998. * Gets or sets the height of the bar image
  72999. */
  73000. get barImageHeight(): number;
  73001. set barImageHeight(value: number);
  73002. /**
  73003. * Creates a new ImageScrollBar
  73004. * @param name defines the control name
  73005. */
  73006. constructor(name?: string | undefined);
  73007. protected _getTypeName(): string;
  73008. protected _getThumbThickness(): number;
  73009. _draw(context: CanvasRenderingContext2D): void;
  73010. private _first;
  73011. private _originX;
  73012. private _originY;
  73013. /** @hidden */
  73014. protected _updateValueFromPointer(x: number, y: number): void;
  73015. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73016. }
  73017. }
  73018. declare module BABYLON.GUI {
  73019. /**
  73020. * Class used to hold a viewer window and sliders in a grid
  73021. */
  73022. export class ScrollViewer extends Rectangle {
  73023. private _grid;
  73024. private _horizontalBarSpace;
  73025. private _verticalBarSpace;
  73026. private _dragSpace;
  73027. private _horizontalBar;
  73028. private _verticalBar;
  73029. private _barColor;
  73030. private _barBackground;
  73031. private _barImage;
  73032. private _horizontalBarImage;
  73033. private _verticalBarImage;
  73034. private _barBackgroundImage;
  73035. private _horizontalBarBackgroundImage;
  73036. private _verticalBarBackgroundImage;
  73037. private _barSize;
  73038. private _window;
  73039. private _pointerIsOver;
  73040. private _wheelPrecision;
  73041. private _onWheelObserver;
  73042. private _clientWidth;
  73043. private _clientHeight;
  73044. private _useImageBar;
  73045. private _thumbLength;
  73046. private _thumbHeight;
  73047. private _barImageHeight;
  73048. private _horizontalBarImageHeight;
  73049. private _verticalBarImageHeight;
  73050. /**
  73051. * Gets the horizontal scrollbar
  73052. */
  73053. get horizontalBar(): ScrollBar | ImageScrollBar;
  73054. /**
  73055. * Gets the vertical scrollbar
  73056. */
  73057. get verticalBar(): ScrollBar | ImageScrollBar;
  73058. /**
  73059. * Adds a new control to the current container
  73060. * @param control defines the control to add
  73061. * @returns the current container
  73062. */
  73063. addControl(control: BABYLON.Nullable<Control>): Container;
  73064. /**
  73065. * Removes a control from the current container
  73066. * @param control defines the control to remove
  73067. * @returns the current container
  73068. */
  73069. removeControl(control: Control): Container;
  73070. /** Gets the list of children */
  73071. get children(): Control[];
  73072. _flagDescendantsAsMatrixDirty(): void;
  73073. /**
  73074. * Freezes or unfreezes the controls in the window.
  73075. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73076. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73077. */
  73078. get freezeControls(): boolean;
  73079. set freezeControls(value: boolean);
  73080. /** Gets the bucket width */
  73081. get bucketWidth(): number;
  73082. /** Gets the bucket height */
  73083. get bucketHeight(): number;
  73084. /**
  73085. * Sets the bucket sizes.
  73086. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73087. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73088. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73089. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73090. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73091. * used), that's why it is not enabled by default.
  73092. * @param width width of the bucket
  73093. * @param height height of the bucket
  73094. */
  73095. setBucketSizes(width: number, height: number): void;
  73096. private _forceHorizontalBar;
  73097. private _forceVerticalBar;
  73098. /**
  73099. * Forces the horizontal scroll bar to be displayed
  73100. */
  73101. get forceHorizontalBar(): boolean;
  73102. set forceHorizontalBar(value: boolean);
  73103. /**
  73104. * Forces the vertical scroll bar to be displayed
  73105. */
  73106. get forceVerticalBar(): boolean;
  73107. set forceVerticalBar(value: boolean);
  73108. /**
  73109. * Creates a new ScrollViewer
  73110. * @param name of ScrollViewer
  73111. */
  73112. constructor(name?: string, isImageBased?: boolean);
  73113. /** Reset the scroll viewer window to initial size */
  73114. resetWindow(): void;
  73115. protected _getTypeName(): string;
  73116. private _buildClientSizes;
  73117. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73118. protected _postMeasure(): void;
  73119. /**
  73120. * Gets or sets the mouse wheel precision
  73121. * from 0 to 1 with a default value of 0.05
  73122. * */
  73123. get wheelPrecision(): number;
  73124. set wheelPrecision(value: number);
  73125. /** Gets or sets the scroll bar container background color */
  73126. get scrollBackground(): string;
  73127. set scrollBackground(color: string);
  73128. /** Gets or sets the bar color */
  73129. get barColor(): string;
  73130. set barColor(color: string);
  73131. /** Gets or sets the bar image */
  73132. get thumbImage(): Image;
  73133. set thumbImage(value: Image);
  73134. /** Gets or sets the horizontal bar image */
  73135. get horizontalThumbImage(): Image;
  73136. set horizontalThumbImage(value: Image);
  73137. /** Gets or sets the vertical bar image */
  73138. get verticalThumbImage(): Image;
  73139. set verticalThumbImage(value: Image);
  73140. /** Gets or sets the size of the bar */
  73141. get barSize(): number;
  73142. set barSize(value: number);
  73143. /** Gets or sets the length of the thumb */
  73144. get thumbLength(): number;
  73145. set thumbLength(value: number);
  73146. /** Gets or sets the height of the thumb */
  73147. get thumbHeight(): number;
  73148. set thumbHeight(value: number);
  73149. /** Gets or sets the height of the bar image */
  73150. get barImageHeight(): number;
  73151. set barImageHeight(value: number);
  73152. /** Gets or sets the height of the horizontal bar image */
  73153. get horizontalBarImageHeight(): number;
  73154. set horizontalBarImageHeight(value: number);
  73155. /** Gets or sets the height of the vertical bar image */
  73156. get verticalBarImageHeight(): number;
  73157. set verticalBarImageHeight(value: number);
  73158. /** Gets or sets the bar background */
  73159. get barBackground(): string;
  73160. set barBackground(color: string);
  73161. /** Gets or sets the bar background image */
  73162. get barImage(): Image;
  73163. set barImage(value: Image);
  73164. /** Gets or sets the horizontal bar background image */
  73165. get horizontalBarImage(): Image;
  73166. set horizontalBarImage(value: Image);
  73167. /** Gets or sets the vertical bar background image */
  73168. get verticalBarImage(): Image;
  73169. set verticalBarImage(value: Image);
  73170. private _setWindowPosition;
  73171. /** @hidden */
  73172. private _updateScroller;
  73173. _link(host: AdvancedDynamicTexture): void;
  73174. /** @hidden */
  73175. private _addBar;
  73176. /** @hidden */
  73177. private _attachWheel;
  73178. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73179. /** Releases associated resources */
  73180. dispose(): void;
  73181. }
  73182. }
  73183. declare module BABYLON.GUI {
  73184. /** Class used to render a grid */
  73185. export class DisplayGrid extends Control {
  73186. name?: string | undefined;
  73187. private _cellWidth;
  73188. private _cellHeight;
  73189. private _minorLineTickness;
  73190. private _minorLineColor;
  73191. private _majorLineTickness;
  73192. private _majorLineColor;
  73193. private _majorLineFrequency;
  73194. private _background;
  73195. private _displayMajorLines;
  73196. private _displayMinorLines;
  73197. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73198. get displayMinorLines(): boolean;
  73199. set displayMinorLines(value: boolean);
  73200. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73201. get displayMajorLines(): boolean;
  73202. set displayMajorLines(value: boolean);
  73203. /** Gets or sets background color (Black by default) */
  73204. get background(): string;
  73205. set background(value: string);
  73206. /** Gets or sets the width of each cell (20 by default) */
  73207. get cellWidth(): number;
  73208. set cellWidth(value: number);
  73209. /** Gets or sets the height of each cell (20 by default) */
  73210. get cellHeight(): number;
  73211. set cellHeight(value: number);
  73212. /** Gets or sets the tickness of minor lines (1 by default) */
  73213. get minorLineTickness(): number;
  73214. set minorLineTickness(value: number);
  73215. /** Gets or sets the color of minor lines (DarkGray by default) */
  73216. get minorLineColor(): string;
  73217. set minorLineColor(value: string);
  73218. /** Gets or sets the tickness of major lines (2 by default) */
  73219. get majorLineTickness(): number;
  73220. set majorLineTickness(value: number);
  73221. /** Gets or sets the color of major lines (White by default) */
  73222. get majorLineColor(): string;
  73223. set majorLineColor(value: string);
  73224. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73225. get majorLineFrequency(): number;
  73226. set majorLineFrequency(value: number);
  73227. /**
  73228. * Creates a new GridDisplayRectangle
  73229. * @param name defines the control name
  73230. */
  73231. constructor(name?: string | undefined);
  73232. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73233. protected _getTypeName(): string;
  73234. }
  73235. }
  73236. declare module BABYLON.GUI {
  73237. /**
  73238. * Class used to create slider controls based on images
  73239. */
  73240. export class ImageBasedSlider extends BaseSlider {
  73241. name?: string | undefined;
  73242. private _backgroundImage;
  73243. private _thumbImage;
  73244. private _valueBarImage;
  73245. private _tempMeasure;
  73246. get displayThumb(): boolean;
  73247. set displayThumb(value: boolean);
  73248. /**
  73249. * Gets or sets the image used to render the background
  73250. */
  73251. get backgroundImage(): Image;
  73252. set backgroundImage(value: Image);
  73253. /**
  73254. * Gets or sets the image used to render the value bar
  73255. */
  73256. get valueBarImage(): Image;
  73257. set valueBarImage(value: Image);
  73258. /**
  73259. * Gets or sets the image used to render the thumb
  73260. */
  73261. get thumbImage(): Image;
  73262. set thumbImage(value: Image);
  73263. /**
  73264. * Creates a new ImageBasedSlider
  73265. * @param name defines the control name
  73266. */
  73267. constructor(name?: string | undefined);
  73268. protected _getTypeName(): string;
  73269. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73270. }
  73271. }
  73272. declare module BABYLON.GUI {
  73273. /**
  73274. * Forcing an export so that this code will execute
  73275. * @hidden
  73276. */
  73277. const name = "Statics";
  73278. }
  73279. declare module BABYLON.GUI {
  73280. /**
  73281. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73282. */
  73283. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73284. /**
  73285. * Define the instrumented AdvancedDynamicTexture.
  73286. */
  73287. texture: AdvancedDynamicTexture;
  73288. private _captureRenderTime;
  73289. private _renderTime;
  73290. private _captureLayoutTime;
  73291. private _layoutTime;
  73292. private _onBeginRenderObserver;
  73293. private _onEndRenderObserver;
  73294. private _onBeginLayoutObserver;
  73295. private _onEndLayoutObserver;
  73296. /**
  73297. * Gets the perf counter used to capture render time
  73298. */
  73299. get renderTimeCounter(): BABYLON.PerfCounter;
  73300. /**
  73301. * Gets the perf counter used to capture layout time
  73302. */
  73303. get layoutTimeCounter(): BABYLON.PerfCounter;
  73304. /**
  73305. * Enable or disable the render time capture
  73306. */
  73307. get captureRenderTime(): boolean;
  73308. set captureRenderTime(value: boolean);
  73309. /**
  73310. * Enable or disable the layout time capture
  73311. */
  73312. get captureLayoutTime(): boolean;
  73313. set captureLayoutTime(value: boolean);
  73314. /**
  73315. * Instantiates a new advanced dynamic texture instrumentation.
  73316. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73317. * @param texture Defines the AdvancedDynamicTexture to instrument
  73318. */
  73319. constructor(
  73320. /**
  73321. * Define the instrumented AdvancedDynamicTexture.
  73322. */
  73323. texture: AdvancedDynamicTexture);
  73324. /**
  73325. * Dispose and release associated resources.
  73326. */
  73327. dispose(): void;
  73328. }
  73329. }
  73330. declare module BABYLON.GUI {
  73331. /**
  73332. * Class used to load GUI via XML.
  73333. */
  73334. export class XmlLoader {
  73335. private _nodes;
  73336. private _nodeTypes;
  73337. private _isLoaded;
  73338. private _objectAttributes;
  73339. private _parentClass;
  73340. /**
  73341. * Create a new xml loader
  73342. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73343. */
  73344. constructor(parentClass?: null);
  73345. private _getChainElement;
  73346. private _getClassAttribute;
  73347. private _createGuiElement;
  73348. private _parseGrid;
  73349. private _parseElement;
  73350. private _prepareSourceElement;
  73351. private _parseElementsFromSource;
  73352. private _parseXml;
  73353. /**
  73354. * Gets if the loading has finished.
  73355. * @returns whether the loading has finished or not
  73356. */
  73357. isLoaded(): boolean;
  73358. /**
  73359. * Gets a loaded node / control by id.
  73360. * @param id the Controls id set in the xml
  73361. * @returns element of type Control
  73362. */
  73363. getNodeById(id: string): any;
  73364. /**
  73365. * Gets all loaded nodes / controls
  73366. * @returns Array of controls
  73367. */
  73368. getNodes(): any;
  73369. /**
  73370. * Initiates the xml layout loading
  73371. * @param xmlFile defines the xml layout to load
  73372. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73373. * @param callback defines the callback called on layout load.
  73374. */
  73375. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73376. }
  73377. }
  73378. declare module BABYLON.GUI {
  73379. /**
  73380. * Class used to create containers for controls
  73381. */
  73382. export class Container3D extends Control3D {
  73383. private _blockLayout;
  73384. /**
  73385. * Gets the list of child controls
  73386. */
  73387. protected _children: Control3D[];
  73388. /**
  73389. * Gets the list of child controls
  73390. */
  73391. get children(): Array<Control3D>;
  73392. /**
  73393. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73394. * This is helpful to optimize layout operation when adding multiple children in a row
  73395. */
  73396. get blockLayout(): boolean;
  73397. set blockLayout(value: boolean);
  73398. /**
  73399. * Creates a new container
  73400. * @param name defines the container name
  73401. */
  73402. constructor(name?: string);
  73403. /**
  73404. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73405. * @returns the current container
  73406. */
  73407. updateLayout(): Container3D;
  73408. /**
  73409. * Gets a boolean indicating if the given control is in the children of this control
  73410. * @param control defines the control to check
  73411. * @returns true if the control is in the child list
  73412. */
  73413. containsControl(control: Control3D): boolean;
  73414. /**
  73415. * Adds a control to the children of this control
  73416. * @param control defines the control to add
  73417. * @returns the current container
  73418. */
  73419. addControl(control: Control3D): Container3D;
  73420. /**
  73421. * This function will be called everytime a new control is added
  73422. */
  73423. protected _arrangeChildren(): void;
  73424. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73425. /**
  73426. * Removes a control from the children of this control
  73427. * @param control defines the control to remove
  73428. * @returns the current container
  73429. */
  73430. removeControl(control: Control3D): Container3D;
  73431. protected _getTypeName(): string;
  73432. /**
  73433. * Releases all associated resources
  73434. */
  73435. dispose(): void;
  73436. /** Control rotation will remain unchanged */
  73437. static readonly UNSET_ORIENTATION: number;
  73438. /** Control will rotate to make it look at sphere central axis */
  73439. static readonly FACEORIGIN_ORIENTATION: number;
  73440. /** Control will rotate to make it look back at sphere central axis */
  73441. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73442. /** Control will rotate to look at z axis (0, 0, 1) */
  73443. static readonly FACEFORWARD_ORIENTATION: number;
  73444. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73445. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73446. }
  73447. }
  73448. declare module BABYLON.GUI {
  73449. /**
  73450. * Class used to manage 3D user interface
  73451. * @see http://doc.babylonjs.com/how_to/gui3d
  73452. */
  73453. export class GUI3DManager implements BABYLON.IDisposable {
  73454. private _scene;
  73455. private _sceneDisposeObserver;
  73456. private _utilityLayer;
  73457. private _rootContainer;
  73458. private _pointerObserver;
  73459. private _pointerOutObserver;
  73460. /** @hidden */
  73461. _lastPickedControl: Control3D;
  73462. /** @hidden */
  73463. _lastControlOver: {
  73464. [pointerId: number]: Control3D;
  73465. };
  73466. /** @hidden */
  73467. _lastControlDown: {
  73468. [pointerId: number]: Control3D;
  73469. };
  73470. /**
  73471. * BABYLON.Observable raised when the point picked by the pointer events changed
  73472. */
  73473. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73474. /** @hidden */
  73475. _sharedMaterials: {
  73476. [key: string]: BABYLON.Material;
  73477. };
  73478. /** Gets the hosting scene */
  73479. get scene(): BABYLON.Scene;
  73480. /** Gets associated utility layer */
  73481. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73482. /**
  73483. * Creates a new GUI3DManager
  73484. * @param scene
  73485. */
  73486. constructor(scene?: BABYLON.Scene);
  73487. private _handlePointerOut;
  73488. private _doPicking;
  73489. /**
  73490. * Gets the root container
  73491. */
  73492. get rootContainer(): Container3D;
  73493. /**
  73494. * Gets a boolean indicating if the given control is in the root child list
  73495. * @param control defines the control to check
  73496. * @returns true if the control is in the root child list
  73497. */
  73498. containsControl(control: Control3D): boolean;
  73499. /**
  73500. * Adds a control to the root child list
  73501. * @param control defines the control to add
  73502. * @returns the current manager
  73503. */
  73504. addControl(control: Control3D): GUI3DManager;
  73505. /**
  73506. * Removes a control from the root child list
  73507. * @param control defines the control to remove
  73508. * @returns the current container
  73509. */
  73510. removeControl(control: Control3D): GUI3DManager;
  73511. /**
  73512. * Releases all associated resources
  73513. */
  73514. dispose(): void;
  73515. }
  73516. }
  73517. declare module BABYLON.GUI {
  73518. /**
  73519. * Class used to transport BABYLON.Vector3 information for pointer events
  73520. */
  73521. export class Vector3WithInfo extends BABYLON.Vector3 {
  73522. /** defines the current mouse button index */
  73523. buttonIndex: number;
  73524. /**
  73525. * Creates a new Vector3WithInfo
  73526. * @param source defines the vector3 data to transport
  73527. * @param buttonIndex defines the current mouse button index
  73528. */
  73529. constructor(source: BABYLON.Vector3,
  73530. /** defines the current mouse button index */
  73531. buttonIndex?: number);
  73532. }
  73533. }
  73534. declare module BABYLON.GUI {
  73535. /**
  73536. * Class used as base class for controls
  73537. */
  73538. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73539. /** Defines the control name */
  73540. name?: string | undefined;
  73541. /** @hidden */
  73542. _host: GUI3DManager;
  73543. private _node;
  73544. private _downCount;
  73545. private _enterCount;
  73546. private _downPointerIds;
  73547. private _isVisible;
  73548. /** Gets or sets the control position in world space */
  73549. get position(): BABYLON.Vector3;
  73550. set position(value: BABYLON.Vector3);
  73551. /** Gets or sets the control scaling in world space */
  73552. get scaling(): BABYLON.Vector3;
  73553. set scaling(value: BABYLON.Vector3);
  73554. /** Callback used to start pointer enter animation */
  73555. pointerEnterAnimation: () => void;
  73556. /** Callback used to start pointer out animation */
  73557. pointerOutAnimation: () => void;
  73558. /** Callback used to start pointer down animation */
  73559. pointerDownAnimation: () => void;
  73560. /** Callback used to start pointer up animation */
  73561. pointerUpAnimation: () => void;
  73562. /**
  73563. * An event triggered when the pointer move over the control
  73564. */
  73565. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73566. /**
  73567. * An event triggered when the pointer move out of the control
  73568. */
  73569. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73570. /**
  73571. * An event triggered when the pointer taps the control
  73572. */
  73573. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73574. /**
  73575. * An event triggered when pointer is up
  73576. */
  73577. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73578. /**
  73579. * An event triggered when a control is clicked on (with a mouse)
  73580. */
  73581. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73582. /**
  73583. * An event triggered when pointer enters the control
  73584. */
  73585. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73586. /**
  73587. * Gets or sets the parent container
  73588. */
  73589. parent: BABYLON.Nullable<Container3D>;
  73590. private _behaviors;
  73591. /**
  73592. * Gets the list of attached behaviors
  73593. * @see http://doc.babylonjs.com/features/behaviour
  73594. */
  73595. get behaviors(): BABYLON.Behavior<Control3D>[];
  73596. /**
  73597. * Attach a behavior to the control
  73598. * @see http://doc.babylonjs.com/features/behaviour
  73599. * @param behavior defines the behavior to attach
  73600. * @returns the current control
  73601. */
  73602. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73603. /**
  73604. * Remove an attached behavior
  73605. * @see http://doc.babylonjs.com/features/behaviour
  73606. * @param behavior defines the behavior to attach
  73607. * @returns the current control
  73608. */
  73609. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73610. /**
  73611. * Gets an attached behavior by name
  73612. * @param name defines the name of the behavior to look for
  73613. * @see http://doc.babylonjs.com/features/behaviour
  73614. * @returns null if behavior was not found else the requested behavior
  73615. */
  73616. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73617. /** Gets or sets a boolean indicating if the control is visible */
  73618. get isVisible(): boolean;
  73619. set isVisible(value: boolean);
  73620. /**
  73621. * Creates a new control
  73622. * @param name defines the control name
  73623. */
  73624. constructor(
  73625. /** Defines the control name */
  73626. name?: string | undefined);
  73627. /**
  73628. * Gets a string representing the class name
  73629. */
  73630. get typeName(): string;
  73631. /**
  73632. * Get the current class name of the control.
  73633. * @returns current class name
  73634. */
  73635. getClassName(): string;
  73636. protected _getTypeName(): string;
  73637. /**
  73638. * Gets the transform node used by this control
  73639. */
  73640. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73641. /**
  73642. * Gets the mesh used to render this control
  73643. */
  73644. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73645. /**
  73646. * Link the control as child of the given node
  73647. * @param node defines the node to link to. Use null to unlink the control
  73648. * @returns the current control
  73649. */
  73650. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73651. /** @hidden **/
  73652. _prepareNode(scene: BABYLON.Scene): void;
  73653. /**
  73654. * Node creation.
  73655. * Can be overriden by children
  73656. * @param scene defines the scene where the node must be attached
  73657. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73658. */
  73659. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73660. /**
  73661. * Affect a material to the given mesh
  73662. * @param mesh defines the mesh which will represent the control
  73663. */
  73664. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73665. /** @hidden */
  73666. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73667. /** @hidden */
  73668. _onPointerEnter(target: Control3D): boolean;
  73669. /** @hidden */
  73670. _onPointerOut(target: Control3D): void;
  73671. /** @hidden */
  73672. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73673. /** @hidden */
  73674. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73675. /** @hidden */
  73676. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73677. /** @hidden */
  73678. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73679. /** @hidden */
  73680. _disposeNode(): void;
  73681. /**
  73682. * Releases all associated resources
  73683. */
  73684. dispose(): void;
  73685. }
  73686. }
  73687. declare module BABYLON.GUI {
  73688. /**
  73689. * Class used as a root to all buttons
  73690. */
  73691. export class AbstractButton3D extends Control3D {
  73692. /**
  73693. * Creates a new button
  73694. * @param name defines the control name
  73695. */
  73696. constructor(name?: string);
  73697. protected _getTypeName(): string;
  73698. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73699. }
  73700. }
  73701. declare module BABYLON.GUI {
  73702. /**
  73703. * Class used to create a button in 3D
  73704. */
  73705. export class Button3D extends AbstractButton3D {
  73706. /** @hidden */
  73707. protected _currentMaterial: BABYLON.Material;
  73708. private _facadeTexture;
  73709. private _content;
  73710. private _contentResolution;
  73711. private _contentScaleRatio;
  73712. /**
  73713. * Gets or sets the texture resolution used to render content (512 by default)
  73714. */
  73715. get contentResolution(): BABYLON.int;
  73716. set contentResolution(value: BABYLON.int);
  73717. /**
  73718. * Gets or sets the texture scale ratio used to render content (2 by default)
  73719. */
  73720. get contentScaleRatio(): number;
  73721. set contentScaleRatio(value: number);
  73722. protected _disposeFacadeTexture(): void;
  73723. protected _resetContent(): void;
  73724. /**
  73725. * Creates a new button
  73726. * @param name defines the control name
  73727. */
  73728. constructor(name?: string);
  73729. /**
  73730. * Gets or sets the GUI 2D content used to display the button's facade
  73731. */
  73732. get content(): Control;
  73733. set content(value: Control);
  73734. /**
  73735. * Apply the facade texture (created from the content property).
  73736. * This function can be overloaded by child classes
  73737. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73738. */
  73739. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73740. protected _getTypeName(): string;
  73741. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73742. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73743. /**
  73744. * Releases all associated resources
  73745. */
  73746. dispose(): void;
  73747. }
  73748. }
  73749. declare module BABYLON.GUI {
  73750. /**
  73751. * Abstract class used to create a container panel deployed on the surface of a volume
  73752. */
  73753. export abstract class VolumeBasedPanel extends Container3D {
  73754. private _columns;
  73755. private _rows;
  73756. private _rowThenColum;
  73757. private _orientation;
  73758. protected _cellWidth: number;
  73759. protected _cellHeight: number;
  73760. /**
  73761. * Gets or sets the distance between elements
  73762. */
  73763. margin: number;
  73764. /**
  73765. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73766. * | Value | Type | Description |
  73767. * | ----- | ----------------------------------- | ----------- |
  73768. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73769. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73770. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73771. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73772. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73773. */
  73774. get orientation(): number;
  73775. set orientation(value: number);
  73776. /**
  73777. * Gets or sets the number of columns requested (10 by default).
  73778. * The panel will automatically compute the number of rows based on number of child controls.
  73779. */
  73780. get columns(): BABYLON.int;
  73781. set columns(value: BABYLON.int);
  73782. /**
  73783. * Gets or sets a the number of rows requested.
  73784. * The panel will automatically compute the number of columns based on number of child controls.
  73785. */
  73786. get rows(): BABYLON.int;
  73787. set rows(value: BABYLON.int);
  73788. /**
  73789. * Creates new VolumeBasedPanel
  73790. */
  73791. constructor();
  73792. protected _arrangeChildren(): void;
  73793. /** Child classes must implement this function to provide correct control positioning */
  73794. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73795. /** Child classes can implement this function to provide additional processing */
  73796. protected _finalProcessing(): void;
  73797. }
  73798. }
  73799. declare module BABYLON.GUI {
  73800. /**
  73801. * Class used to create a container panel deployed on the surface of a cylinder
  73802. */
  73803. export class CylinderPanel extends VolumeBasedPanel {
  73804. private _radius;
  73805. /**
  73806. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73807. */
  73808. get radius(): BABYLON.float;
  73809. set radius(value: BABYLON.float);
  73810. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73811. private _cylindricalMapping;
  73812. }
  73813. }
  73814. declare module BABYLON.GUI {
  73815. /** @hidden */
  73816. export var fluentVertexShader: {
  73817. name: string;
  73818. shader: string;
  73819. };
  73820. }
  73821. declare module BABYLON.GUI {
  73822. /** @hidden */
  73823. export var fluentPixelShader: {
  73824. name: string;
  73825. shader: string;
  73826. };
  73827. }
  73828. declare module BABYLON.GUI {
  73829. /** @hidden */
  73830. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73831. INNERGLOW: boolean;
  73832. BORDER: boolean;
  73833. HOVERLIGHT: boolean;
  73834. TEXTURE: boolean;
  73835. constructor();
  73836. }
  73837. /**
  73838. * Class used to render controls with fluent desgin
  73839. */
  73840. export class FluentMaterial extends BABYLON.PushMaterial {
  73841. /**
  73842. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73843. */
  73844. innerGlowColorIntensity: number;
  73845. /**
  73846. * Gets or sets the inner glow color (white by default)
  73847. */
  73848. innerGlowColor: BABYLON.Color3;
  73849. /**
  73850. * Gets or sets alpha value (default is 1.0)
  73851. */
  73852. alpha: number;
  73853. /**
  73854. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73855. */
  73856. albedoColor: BABYLON.Color3;
  73857. /**
  73858. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73859. */
  73860. renderBorders: boolean;
  73861. /**
  73862. * Gets or sets border width (default is 0.5)
  73863. */
  73864. borderWidth: number;
  73865. /**
  73866. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73867. */
  73868. edgeSmoothingValue: number;
  73869. /**
  73870. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73871. */
  73872. borderMinValue: number;
  73873. /**
  73874. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73875. */
  73876. renderHoverLight: boolean;
  73877. /**
  73878. * Gets or sets the radius used to render the hover light (default is 1.0)
  73879. */
  73880. hoverRadius: number;
  73881. /**
  73882. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73883. */
  73884. hoverColor: BABYLON.Color4;
  73885. /**
  73886. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73887. */
  73888. hoverPosition: BABYLON.Vector3;
  73889. private _albedoTexture;
  73890. /** Gets or sets the texture to use for albedo color */
  73891. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73892. /**
  73893. * Creates a new Fluent material
  73894. * @param name defines the name of the material
  73895. * @param scene defines the hosting scene
  73896. */
  73897. constructor(name: string, scene: BABYLON.Scene);
  73898. needAlphaBlending(): boolean;
  73899. needAlphaTesting(): boolean;
  73900. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73901. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73902. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73903. getActiveTextures(): BABYLON.BaseTexture[];
  73904. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73905. dispose(forceDisposeEffect?: boolean): void;
  73906. clone(name: string): FluentMaterial;
  73907. serialize(): any;
  73908. getClassName(): string;
  73909. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73910. }
  73911. }
  73912. declare module BABYLON.GUI {
  73913. /**
  73914. * Class used to create a holographic button in 3D
  73915. */
  73916. export class HolographicButton extends Button3D {
  73917. private _backPlate;
  73918. private _textPlate;
  73919. private _frontPlate;
  73920. private _text;
  73921. private _imageUrl;
  73922. private _shareMaterials;
  73923. private _frontMaterial;
  73924. private _backMaterial;
  73925. private _plateMaterial;
  73926. private _pickedPointObserver;
  73927. private _tooltipFade;
  73928. private _tooltipTextBlock;
  73929. private _tooltipTexture;
  73930. private _tooltipMesh;
  73931. private _tooltipHoverObserver;
  73932. private _tooltipOutObserver;
  73933. private _disposeTooltip;
  73934. /**
  73935. * Rendering ground id of all the mesh in the button
  73936. */
  73937. set renderingGroupId(id: number);
  73938. get renderingGroupId(): number;
  73939. /**
  73940. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73941. */
  73942. set tooltipText(text: BABYLON.Nullable<string>);
  73943. get tooltipText(): BABYLON.Nullable<string>;
  73944. /**
  73945. * Gets or sets text for the button
  73946. */
  73947. get text(): string;
  73948. set text(value: string);
  73949. /**
  73950. * Gets or sets the image url for the button
  73951. */
  73952. get imageUrl(): string;
  73953. set imageUrl(value: string);
  73954. /**
  73955. * Gets the back material used by this button
  73956. */
  73957. get backMaterial(): FluentMaterial;
  73958. /**
  73959. * Gets the front material used by this button
  73960. */
  73961. get frontMaterial(): FluentMaterial;
  73962. /**
  73963. * Gets the plate material used by this button
  73964. */
  73965. get plateMaterial(): BABYLON.StandardMaterial;
  73966. /**
  73967. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73968. */
  73969. get shareMaterials(): boolean;
  73970. /**
  73971. * Creates a new button
  73972. * @param name defines the control name
  73973. */
  73974. constructor(name?: string, shareMaterials?: boolean);
  73975. protected _getTypeName(): string;
  73976. private _rebuildContent;
  73977. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73978. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73979. private _createBackMaterial;
  73980. private _createFrontMaterial;
  73981. private _createPlateMaterial;
  73982. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73983. /**
  73984. * Releases all associated resources
  73985. */
  73986. dispose(): void;
  73987. }
  73988. }
  73989. declare module BABYLON.GUI {
  73990. /**
  73991. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73992. */
  73993. export class MeshButton3D extends Button3D {
  73994. /** @hidden */
  73995. protected _currentMesh: BABYLON.Mesh;
  73996. /**
  73997. * Creates a new 3D button based on a mesh
  73998. * @param mesh mesh to become a 3D button
  73999. * @param name defines the control name
  74000. */
  74001. constructor(mesh: BABYLON.Mesh, name?: string);
  74002. protected _getTypeName(): string;
  74003. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74004. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74005. }
  74006. }
  74007. declare module BABYLON.GUI {
  74008. /**
  74009. * Class used to create a container panel deployed on the surface of a plane
  74010. */
  74011. export class PlanePanel extends VolumeBasedPanel {
  74012. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74013. }
  74014. }
  74015. declare module BABYLON.GUI {
  74016. /**
  74017. * Class used to create a container panel where items get randomized planar mapping
  74018. */
  74019. export class ScatterPanel extends VolumeBasedPanel {
  74020. private _iteration;
  74021. /**
  74022. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74023. */
  74024. get iteration(): BABYLON.float;
  74025. set iteration(value: BABYLON.float);
  74026. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74027. private _scatterMapping;
  74028. protected _finalProcessing(): void;
  74029. }
  74030. }
  74031. declare module BABYLON.GUI {
  74032. /**
  74033. * Class used to create a container panel deployed on the surface of a sphere
  74034. */
  74035. export class SpherePanel extends VolumeBasedPanel {
  74036. private _radius;
  74037. /**
  74038. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74039. */
  74040. get radius(): BABYLON.float;
  74041. set radius(value: BABYLON.float);
  74042. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74043. private _sphericalMapping;
  74044. }
  74045. }
  74046. declare module BABYLON.GUI {
  74047. /**
  74048. * Class used to create a stack panel in 3D on XY plane
  74049. */
  74050. export class StackPanel3D extends Container3D {
  74051. private _isVertical;
  74052. /**
  74053. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74054. */
  74055. get isVertical(): boolean;
  74056. set isVertical(value: boolean);
  74057. /**
  74058. * Gets or sets the distance between elements
  74059. */
  74060. margin: number;
  74061. /**
  74062. * Creates new StackPanel
  74063. * @param isVertical
  74064. */
  74065. constructor(isVertical?: boolean);
  74066. protected _arrangeChildren(): void;
  74067. }
  74068. }
  74069. declare module BABYLON {
  74070. /**
  74071. * Configuration for glTF validation
  74072. */
  74073. export interface IGLTFValidationConfiguration {
  74074. /**
  74075. * The url of the glTF validator.
  74076. */
  74077. url: string;
  74078. }
  74079. /**
  74080. * glTF validation
  74081. */
  74082. export class GLTFValidation {
  74083. /**
  74084. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74085. */
  74086. static Configuration: IGLTFValidationConfiguration;
  74087. private static _LoadScriptPromise;
  74088. /**
  74089. * Validate a glTF asset using the glTF-Validator.
  74090. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74091. * @param rootUrl The root url for the glTF
  74092. * @param fileName The file name for the glTF
  74093. * @param getExternalResource The callback to get external resources for the glTF validator
  74094. * @returns A promise that resolves with the glTF validation results once complete
  74095. */
  74096. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74097. }
  74098. }
  74099. declare module BABYLON {
  74100. /**
  74101. * Mode that determines the coordinate system to use.
  74102. */
  74103. export enum GLTFLoaderCoordinateSystemMode {
  74104. /**
  74105. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74106. */
  74107. AUTO = 0,
  74108. /**
  74109. * Sets the useRightHandedSystem flag on the scene.
  74110. */
  74111. FORCE_RIGHT_HANDED = 1
  74112. }
  74113. /**
  74114. * Mode that determines what animations will start.
  74115. */
  74116. export enum GLTFLoaderAnimationStartMode {
  74117. /**
  74118. * No animation will start.
  74119. */
  74120. NONE = 0,
  74121. /**
  74122. * The first animation will start.
  74123. */
  74124. FIRST = 1,
  74125. /**
  74126. * All animations will start.
  74127. */
  74128. ALL = 2
  74129. }
  74130. /**
  74131. * Interface that contains the data for the glTF asset.
  74132. */
  74133. export interface IGLTFLoaderData {
  74134. /**
  74135. * The object that represents the glTF JSON.
  74136. */
  74137. json: Object;
  74138. /**
  74139. * The BIN chunk of a binary glTF.
  74140. */
  74141. bin: Nullable<IDataBuffer>;
  74142. }
  74143. /**
  74144. * Interface for extending the loader.
  74145. */
  74146. export interface IGLTFLoaderExtension {
  74147. /**
  74148. * The name of this extension.
  74149. */
  74150. readonly name: string;
  74151. /**
  74152. * Defines whether this extension is enabled.
  74153. */
  74154. enabled: boolean;
  74155. /**
  74156. * Defines the order of this extension.
  74157. * The loader sorts the extensions using these values when loading.
  74158. */
  74159. order?: number;
  74160. }
  74161. /**
  74162. * Loader state.
  74163. */
  74164. export enum GLTFLoaderState {
  74165. /**
  74166. * The asset is loading.
  74167. */
  74168. LOADING = 0,
  74169. /**
  74170. * The asset is ready for rendering.
  74171. */
  74172. READY = 1,
  74173. /**
  74174. * The asset is completely loaded.
  74175. */
  74176. COMPLETE = 2
  74177. }
  74178. /** @hidden */
  74179. export interface IImportMeshAsyncOutput {
  74180. meshes: AbstractMesh[];
  74181. particleSystems: IParticleSystem[];
  74182. skeletons: Skeleton[];
  74183. animationGroups: AnimationGroup[];
  74184. lights: Light[];
  74185. transformNodes: TransformNode[];
  74186. }
  74187. /** @hidden */
  74188. export interface IGLTFLoader extends IDisposable {
  74189. readonly state: Nullable<GLTFLoaderState>;
  74190. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74191. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74192. }
  74193. /**
  74194. * File loader for loading glTF files into a scene.
  74195. */
  74196. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74197. /** @hidden */
  74198. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74199. /** @hidden */
  74200. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74201. /**
  74202. * Raised when the asset has been parsed
  74203. */
  74204. onParsedObservable: Observable<IGLTFLoaderData>;
  74205. private _onParsedObserver;
  74206. /**
  74207. * Raised when the asset has been parsed
  74208. */
  74209. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74210. /**
  74211. * 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.
  74212. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74213. * Defaults to true.
  74214. * @hidden
  74215. */
  74216. static IncrementalLoading: boolean;
  74217. /**
  74218. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74219. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74220. * @hidden
  74221. */
  74222. static HomogeneousCoordinates: boolean;
  74223. /**
  74224. * The coordinate system mode. Defaults to AUTO.
  74225. */
  74226. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74227. /**
  74228. * The animation start mode. Defaults to FIRST.
  74229. */
  74230. animationStartMode: GLTFLoaderAnimationStartMode;
  74231. /**
  74232. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74233. */
  74234. compileMaterials: boolean;
  74235. /**
  74236. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74237. */
  74238. useClipPlane: boolean;
  74239. /**
  74240. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74241. */
  74242. compileShadowGenerators: boolean;
  74243. /**
  74244. * Defines if the Alpha blended materials are only applied as coverage.
  74245. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74246. * If true, no extra effects are applied to transparent pixels.
  74247. */
  74248. transparencyAsCoverage: boolean;
  74249. /**
  74250. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74251. * Enabling will disable offline support and glTF validator.
  74252. * Defaults to false.
  74253. */
  74254. useRangeRequests: boolean;
  74255. /**
  74256. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74257. */
  74258. createInstances: boolean;
  74259. /**
  74260. * Function called before loading a url referenced by the asset.
  74261. */
  74262. preprocessUrlAsync: (url: string) => Promise<string>;
  74263. /**
  74264. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74265. */
  74266. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74267. private _onMeshLoadedObserver;
  74268. /**
  74269. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74270. */
  74271. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74272. /**
  74273. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74274. */
  74275. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74276. private _onTextureLoadedObserver;
  74277. /**
  74278. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74279. */
  74280. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74281. /**
  74282. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74283. */
  74284. readonly onMaterialLoadedObservable: Observable<Material>;
  74285. private _onMaterialLoadedObserver;
  74286. /**
  74287. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74288. */
  74289. set onMaterialLoaded(callback: (material: Material) => void);
  74290. /**
  74291. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74292. */
  74293. readonly onCameraLoadedObservable: Observable<Camera>;
  74294. private _onCameraLoadedObserver;
  74295. /**
  74296. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74297. */
  74298. set onCameraLoaded(callback: (camera: Camera) => void);
  74299. /**
  74300. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74301. * For assets with LODs, raised when all of the LODs are complete.
  74302. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74303. */
  74304. readonly onCompleteObservable: Observable<void>;
  74305. private _onCompleteObserver;
  74306. /**
  74307. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74308. * For assets with LODs, raised when all of the LODs are complete.
  74309. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74310. */
  74311. set onComplete(callback: () => void);
  74312. /**
  74313. * Observable raised when an error occurs.
  74314. */
  74315. readonly onErrorObservable: Observable<any>;
  74316. private _onErrorObserver;
  74317. /**
  74318. * Callback raised when an error occurs.
  74319. */
  74320. set onError(callback: (reason: any) => void);
  74321. /**
  74322. * Observable raised after the loader is disposed.
  74323. */
  74324. readonly onDisposeObservable: Observable<void>;
  74325. private _onDisposeObserver;
  74326. /**
  74327. * Callback raised after the loader is disposed.
  74328. */
  74329. set onDispose(callback: () => void);
  74330. /**
  74331. * Observable raised after a loader extension is created.
  74332. * Set additional options for a loader extension in this event.
  74333. */
  74334. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74335. private _onExtensionLoadedObserver;
  74336. /**
  74337. * Callback raised after a loader extension is created.
  74338. */
  74339. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74340. /**
  74341. * Defines if the loader logging is enabled.
  74342. */
  74343. get loggingEnabled(): boolean;
  74344. set loggingEnabled(value: boolean);
  74345. /**
  74346. * Defines if the loader should capture performance counters.
  74347. */
  74348. get capturePerformanceCounters(): boolean;
  74349. set capturePerformanceCounters(value: boolean);
  74350. /**
  74351. * Defines if the loader should validate the asset.
  74352. */
  74353. validate: boolean;
  74354. /**
  74355. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74356. */
  74357. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74358. private _onValidatedObserver;
  74359. /**
  74360. * Callback raised after a loader extension is created.
  74361. */
  74362. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74363. private _loader;
  74364. /**
  74365. * Name of the loader ("gltf")
  74366. */
  74367. name: string;
  74368. /** @hidden */
  74369. extensions: ISceneLoaderPluginExtensions;
  74370. /**
  74371. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74372. */
  74373. dispose(): void;
  74374. /** @hidden */
  74375. _clear(): void;
  74376. /** @hidden */
  74377. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74378. /** @hidden */
  74379. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74380. /** @hidden */
  74381. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74382. meshes: AbstractMesh[];
  74383. particleSystems: IParticleSystem[];
  74384. skeletons: Skeleton[];
  74385. animationGroups: AnimationGroup[];
  74386. }>;
  74387. /** @hidden */
  74388. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74389. /** @hidden */
  74390. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74391. /** @hidden */
  74392. canDirectLoad(data: string): boolean;
  74393. /** @hidden */
  74394. directLoad(scene: Scene, data: string): any;
  74395. /**
  74396. * The callback that allows custom handling of the root url based on the response url.
  74397. * @param rootUrl the original root url
  74398. * @param responseURL the response url if available
  74399. * @returns the new root url
  74400. */
  74401. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74402. /** @hidden */
  74403. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74404. /**
  74405. * The loader state or null if the loader is not active.
  74406. */
  74407. get loaderState(): Nullable<GLTFLoaderState>;
  74408. /**
  74409. * Returns a promise that resolves when the asset is completely loaded.
  74410. * @returns a promise that resolves when the asset is completely loaded.
  74411. */
  74412. whenCompleteAsync(): Promise<void>;
  74413. private _validate;
  74414. private _getLoader;
  74415. private _parseJson;
  74416. private _unpackBinaryAsync;
  74417. private _unpackBinaryV1Async;
  74418. private _unpackBinaryV2Async;
  74419. private static _parseVersion;
  74420. private static _compareVersion;
  74421. private static readonly _logSpaces;
  74422. private _logIndentLevel;
  74423. private _loggingEnabled;
  74424. /** @hidden */
  74425. _log: (message: string) => void;
  74426. /** @hidden */
  74427. _logOpen(message: string): void;
  74428. /** @hidden */
  74429. _logClose(): void;
  74430. private _logEnabled;
  74431. private _logDisabled;
  74432. private _capturePerformanceCounters;
  74433. /** @hidden */
  74434. _startPerformanceCounter: (counterName: string) => void;
  74435. /** @hidden */
  74436. _endPerformanceCounter: (counterName: string) => void;
  74437. private _startPerformanceCounterEnabled;
  74438. private _startPerformanceCounterDisabled;
  74439. private _endPerformanceCounterEnabled;
  74440. private _endPerformanceCounterDisabled;
  74441. }
  74442. }
  74443. declare module BABYLON.GLTF1 {
  74444. /**
  74445. * Enums
  74446. * @hidden
  74447. */
  74448. export enum EComponentType {
  74449. BYTE = 5120,
  74450. UNSIGNED_BYTE = 5121,
  74451. SHORT = 5122,
  74452. UNSIGNED_SHORT = 5123,
  74453. FLOAT = 5126
  74454. }
  74455. /** @hidden */
  74456. export enum EShaderType {
  74457. FRAGMENT = 35632,
  74458. VERTEX = 35633
  74459. }
  74460. /** @hidden */
  74461. export enum EParameterType {
  74462. BYTE = 5120,
  74463. UNSIGNED_BYTE = 5121,
  74464. SHORT = 5122,
  74465. UNSIGNED_SHORT = 5123,
  74466. INT = 5124,
  74467. UNSIGNED_INT = 5125,
  74468. FLOAT = 5126,
  74469. FLOAT_VEC2 = 35664,
  74470. FLOAT_VEC3 = 35665,
  74471. FLOAT_VEC4 = 35666,
  74472. INT_VEC2 = 35667,
  74473. INT_VEC3 = 35668,
  74474. INT_VEC4 = 35669,
  74475. BOOL = 35670,
  74476. BOOL_VEC2 = 35671,
  74477. BOOL_VEC3 = 35672,
  74478. BOOL_VEC4 = 35673,
  74479. FLOAT_MAT2 = 35674,
  74480. FLOAT_MAT3 = 35675,
  74481. FLOAT_MAT4 = 35676,
  74482. SAMPLER_2D = 35678
  74483. }
  74484. /** @hidden */
  74485. export enum ETextureWrapMode {
  74486. CLAMP_TO_EDGE = 33071,
  74487. MIRRORED_REPEAT = 33648,
  74488. REPEAT = 10497
  74489. }
  74490. /** @hidden */
  74491. export enum ETextureFilterType {
  74492. NEAREST = 9728,
  74493. LINEAR = 9728,
  74494. NEAREST_MIPMAP_NEAREST = 9984,
  74495. LINEAR_MIPMAP_NEAREST = 9985,
  74496. NEAREST_MIPMAP_LINEAR = 9986,
  74497. LINEAR_MIPMAP_LINEAR = 9987
  74498. }
  74499. /** @hidden */
  74500. export enum ETextureFormat {
  74501. ALPHA = 6406,
  74502. RGB = 6407,
  74503. RGBA = 6408,
  74504. LUMINANCE = 6409,
  74505. LUMINANCE_ALPHA = 6410
  74506. }
  74507. /** @hidden */
  74508. export enum ECullingType {
  74509. FRONT = 1028,
  74510. BACK = 1029,
  74511. FRONT_AND_BACK = 1032
  74512. }
  74513. /** @hidden */
  74514. export enum EBlendingFunction {
  74515. ZERO = 0,
  74516. ONE = 1,
  74517. SRC_COLOR = 768,
  74518. ONE_MINUS_SRC_COLOR = 769,
  74519. DST_COLOR = 774,
  74520. ONE_MINUS_DST_COLOR = 775,
  74521. SRC_ALPHA = 770,
  74522. ONE_MINUS_SRC_ALPHA = 771,
  74523. DST_ALPHA = 772,
  74524. ONE_MINUS_DST_ALPHA = 773,
  74525. CONSTANT_COLOR = 32769,
  74526. ONE_MINUS_CONSTANT_COLOR = 32770,
  74527. CONSTANT_ALPHA = 32771,
  74528. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74529. SRC_ALPHA_SATURATE = 776
  74530. }
  74531. /** @hidden */
  74532. export interface IGLTFProperty {
  74533. extensions?: {
  74534. [key: string]: any;
  74535. };
  74536. extras?: Object;
  74537. }
  74538. /** @hidden */
  74539. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74540. name?: string;
  74541. }
  74542. /** @hidden */
  74543. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74544. bufferView: string;
  74545. byteOffset: number;
  74546. byteStride: number;
  74547. count: number;
  74548. type: string;
  74549. componentType: EComponentType;
  74550. max?: number[];
  74551. min?: number[];
  74552. name?: string;
  74553. }
  74554. /** @hidden */
  74555. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74556. buffer: string;
  74557. byteOffset: number;
  74558. byteLength: number;
  74559. byteStride: number;
  74560. target?: number;
  74561. }
  74562. /** @hidden */
  74563. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74564. uri: string;
  74565. byteLength?: number;
  74566. type?: string;
  74567. }
  74568. /** @hidden */
  74569. export interface IGLTFShader extends IGLTFChildRootProperty {
  74570. uri: string;
  74571. type: EShaderType;
  74572. }
  74573. /** @hidden */
  74574. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74575. attributes: string[];
  74576. fragmentShader: string;
  74577. vertexShader: string;
  74578. }
  74579. /** @hidden */
  74580. export interface IGLTFTechniqueParameter {
  74581. type: number;
  74582. count?: number;
  74583. semantic?: string;
  74584. node?: string;
  74585. value?: number | boolean | string | Array<any>;
  74586. source?: string;
  74587. babylonValue?: any;
  74588. }
  74589. /** @hidden */
  74590. export interface IGLTFTechniqueCommonProfile {
  74591. lightingModel: string;
  74592. texcoordBindings: Object;
  74593. parameters?: Array<any>;
  74594. }
  74595. /** @hidden */
  74596. export interface IGLTFTechniqueStatesFunctions {
  74597. blendColor?: number[];
  74598. blendEquationSeparate?: number[];
  74599. blendFuncSeparate?: number[];
  74600. colorMask: boolean[];
  74601. cullFace: number[];
  74602. }
  74603. /** @hidden */
  74604. export interface IGLTFTechniqueStates {
  74605. enable: number[];
  74606. functions: IGLTFTechniqueStatesFunctions;
  74607. }
  74608. /** @hidden */
  74609. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74610. parameters: {
  74611. [key: string]: IGLTFTechniqueParameter;
  74612. };
  74613. program: string;
  74614. attributes: {
  74615. [key: string]: string;
  74616. };
  74617. uniforms: {
  74618. [key: string]: string;
  74619. };
  74620. states: IGLTFTechniqueStates;
  74621. }
  74622. /** @hidden */
  74623. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74624. technique?: string;
  74625. values: string[];
  74626. }
  74627. /** @hidden */
  74628. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74629. attributes: {
  74630. [key: string]: string;
  74631. };
  74632. indices: string;
  74633. material: string;
  74634. mode?: number;
  74635. }
  74636. /** @hidden */
  74637. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74638. primitives: IGLTFMeshPrimitive[];
  74639. }
  74640. /** @hidden */
  74641. export interface IGLTFImage extends IGLTFChildRootProperty {
  74642. uri: string;
  74643. }
  74644. /** @hidden */
  74645. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74646. magFilter?: number;
  74647. minFilter?: number;
  74648. wrapS?: number;
  74649. wrapT?: number;
  74650. }
  74651. /** @hidden */
  74652. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74653. sampler: string;
  74654. source: string;
  74655. format?: ETextureFormat;
  74656. internalFormat?: ETextureFormat;
  74657. target?: number;
  74658. type?: number;
  74659. babylonTexture?: Texture;
  74660. }
  74661. /** @hidden */
  74662. export interface IGLTFAmbienLight {
  74663. color?: number[];
  74664. }
  74665. /** @hidden */
  74666. export interface IGLTFDirectionalLight {
  74667. color?: number[];
  74668. }
  74669. /** @hidden */
  74670. export interface IGLTFPointLight {
  74671. color?: number[];
  74672. constantAttenuation?: number;
  74673. linearAttenuation?: number;
  74674. quadraticAttenuation?: number;
  74675. }
  74676. /** @hidden */
  74677. export interface IGLTFSpotLight {
  74678. color?: number[];
  74679. constantAttenuation?: number;
  74680. fallOfAngle?: number;
  74681. fallOffExponent?: number;
  74682. linearAttenuation?: number;
  74683. quadraticAttenuation?: number;
  74684. }
  74685. /** @hidden */
  74686. export interface IGLTFLight extends IGLTFChildRootProperty {
  74687. type: string;
  74688. }
  74689. /** @hidden */
  74690. export interface IGLTFCameraOrthographic {
  74691. xmag: number;
  74692. ymag: number;
  74693. zfar: number;
  74694. znear: number;
  74695. }
  74696. /** @hidden */
  74697. export interface IGLTFCameraPerspective {
  74698. aspectRatio: number;
  74699. yfov: number;
  74700. zfar: number;
  74701. znear: number;
  74702. }
  74703. /** @hidden */
  74704. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74705. type: string;
  74706. }
  74707. /** @hidden */
  74708. export interface IGLTFAnimationChannelTarget {
  74709. id: string;
  74710. path: string;
  74711. }
  74712. /** @hidden */
  74713. export interface IGLTFAnimationChannel {
  74714. sampler: string;
  74715. target: IGLTFAnimationChannelTarget;
  74716. }
  74717. /** @hidden */
  74718. export interface IGLTFAnimationSampler {
  74719. input: string;
  74720. output: string;
  74721. interpolation?: string;
  74722. }
  74723. /** @hidden */
  74724. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74725. channels?: IGLTFAnimationChannel[];
  74726. parameters?: {
  74727. [key: string]: string;
  74728. };
  74729. samplers?: {
  74730. [key: string]: IGLTFAnimationSampler;
  74731. };
  74732. }
  74733. /** @hidden */
  74734. export interface IGLTFNodeInstanceSkin {
  74735. skeletons: string[];
  74736. skin: string;
  74737. meshes: string[];
  74738. }
  74739. /** @hidden */
  74740. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74741. bindShapeMatrix: number[];
  74742. inverseBindMatrices: string;
  74743. jointNames: string[];
  74744. babylonSkeleton?: Skeleton;
  74745. }
  74746. /** @hidden */
  74747. export interface IGLTFNode extends IGLTFChildRootProperty {
  74748. camera?: string;
  74749. children: string[];
  74750. skin?: string;
  74751. jointName?: string;
  74752. light?: string;
  74753. matrix: number[];
  74754. mesh?: string;
  74755. meshes?: string[];
  74756. rotation?: number[];
  74757. scale?: number[];
  74758. translation?: number[];
  74759. babylonNode?: Node;
  74760. }
  74761. /** @hidden */
  74762. export interface IGLTFScene extends IGLTFChildRootProperty {
  74763. nodes: string[];
  74764. }
  74765. /** @hidden */
  74766. export interface IGLTFRuntime {
  74767. extensions: {
  74768. [key: string]: any;
  74769. };
  74770. accessors: {
  74771. [key: string]: IGLTFAccessor;
  74772. };
  74773. buffers: {
  74774. [key: string]: IGLTFBuffer;
  74775. };
  74776. bufferViews: {
  74777. [key: string]: IGLTFBufferView;
  74778. };
  74779. meshes: {
  74780. [key: string]: IGLTFMesh;
  74781. };
  74782. lights: {
  74783. [key: string]: IGLTFLight;
  74784. };
  74785. cameras: {
  74786. [key: string]: IGLTFCamera;
  74787. };
  74788. nodes: {
  74789. [key: string]: IGLTFNode;
  74790. };
  74791. images: {
  74792. [key: string]: IGLTFImage;
  74793. };
  74794. textures: {
  74795. [key: string]: IGLTFTexture;
  74796. };
  74797. shaders: {
  74798. [key: string]: IGLTFShader;
  74799. };
  74800. programs: {
  74801. [key: string]: IGLTFProgram;
  74802. };
  74803. samplers: {
  74804. [key: string]: IGLTFSampler;
  74805. };
  74806. techniques: {
  74807. [key: string]: IGLTFTechnique;
  74808. };
  74809. materials: {
  74810. [key: string]: IGLTFMaterial;
  74811. };
  74812. animations: {
  74813. [key: string]: IGLTFAnimation;
  74814. };
  74815. skins: {
  74816. [key: string]: IGLTFSkins;
  74817. };
  74818. currentScene?: Object;
  74819. scenes: {
  74820. [key: string]: IGLTFScene;
  74821. };
  74822. extensionsUsed: string[];
  74823. extensionsRequired?: string[];
  74824. buffersCount: number;
  74825. shaderscount: number;
  74826. scene: Scene;
  74827. rootUrl: string;
  74828. loadedBufferCount: number;
  74829. loadedBufferViews: {
  74830. [name: string]: ArrayBufferView;
  74831. };
  74832. loadedShaderCount: number;
  74833. importOnlyMeshes: boolean;
  74834. importMeshesNames?: string[];
  74835. dummyNodes: Node[];
  74836. forAssetContainer: boolean;
  74837. }
  74838. /** @hidden */
  74839. export interface INodeToRoot {
  74840. bone: Bone;
  74841. node: IGLTFNode;
  74842. id: string;
  74843. }
  74844. /** @hidden */
  74845. export interface IJointNode {
  74846. node: IGLTFNode;
  74847. id: string;
  74848. }
  74849. }
  74850. declare module BABYLON.GLTF1 {
  74851. /**
  74852. * Utils functions for GLTF
  74853. * @hidden
  74854. */
  74855. export class GLTFUtils {
  74856. /**
  74857. * Sets the given "parameter" matrix
  74858. * @param scene: the Scene object
  74859. * @param source: the source node where to pick the matrix
  74860. * @param parameter: the GLTF technique parameter
  74861. * @param uniformName: the name of the shader's uniform
  74862. * @param shaderMaterial: the shader material
  74863. */
  74864. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74865. /**
  74866. * Sets the given "parameter" matrix
  74867. * @param shaderMaterial: the shader material
  74868. * @param uniform: the name of the shader's uniform
  74869. * @param value: the value of the uniform
  74870. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74871. */
  74872. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74873. /**
  74874. * Returns the wrap mode of the texture
  74875. * @param mode: the mode value
  74876. */
  74877. static GetWrapMode(mode: number): number;
  74878. /**
  74879. * Returns the byte stride giving an accessor
  74880. * @param accessor: the GLTF accessor objet
  74881. */
  74882. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74883. /**
  74884. * Returns the texture filter mode giving a mode value
  74885. * @param mode: the filter mode value
  74886. */
  74887. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74888. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74889. /**
  74890. * Returns a buffer from its accessor
  74891. * @param gltfRuntime: the GLTF runtime
  74892. * @param accessor: the GLTF accessor
  74893. */
  74894. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74895. /**
  74896. * Decodes a buffer view into a string
  74897. * @param view: the buffer view
  74898. */
  74899. static DecodeBufferToText(view: ArrayBufferView): string;
  74900. /**
  74901. * Returns the default material of gltf. Related to
  74902. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74903. * @param scene: the Babylon.js scene
  74904. */
  74905. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74906. private static _DefaultMaterial;
  74907. }
  74908. }
  74909. declare module BABYLON.GLTF1 {
  74910. /**
  74911. * Implementation of the base glTF spec
  74912. * @hidden
  74913. */
  74914. export class GLTFLoaderBase {
  74915. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74916. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74917. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74918. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74919. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74920. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74921. }
  74922. /**
  74923. * glTF V1 Loader
  74924. * @hidden
  74925. */
  74926. export class GLTFLoader implements IGLTFLoader {
  74927. static Extensions: {
  74928. [name: string]: GLTFLoaderExtension;
  74929. };
  74930. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74931. state: Nullable<GLTFLoaderState>;
  74932. dispose(): void;
  74933. private _importMeshAsync;
  74934. /**
  74935. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74936. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74937. * @param scene the scene the meshes should be added to
  74938. * @param forAssetContainer defines if the entities must be stored in the scene
  74939. * @param data gltf data containing information of the meshes in a loaded file
  74940. * @param rootUrl root url to load from
  74941. * @param onProgress event that fires when loading progress has occured
  74942. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74943. */
  74944. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  74945. private _loadAsync;
  74946. /**
  74947. * Imports all objects from a loaded gltf file and adds them to the scene
  74948. * @param scene the scene the objects should be added to
  74949. * @param data gltf data containing information of the meshes in a loaded file
  74950. * @param rootUrl root url to load from
  74951. * @param onProgress event that fires when loading progress has occured
  74952. * @returns a promise which completes when objects have been loaded to the scene
  74953. */
  74954. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74955. private _loadShadersAsync;
  74956. private _loadBuffersAsync;
  74957. private _createNodes;
  74958. }
  74959. /** @hidden */
  74960. export abstract class GLTFLoaderExtension {
  74961. private _name;
  74962. constructor(name: string);
  74963. get name(): string;
  74964. /**
  74965. * Defines an override for loading the runtime
  74966. * Return true to stop further extensions from loading the runtime
  74967. */
  74968. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74969. /**
  74970. * Defines an onverride for creating gltf runtime
  74971. * Return true to stop further extensions from creating the runtime
  74972. */
  74973. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74974. /**
  74975. * Defines an override for loading buffers
  74976. * Return true to stop further extensions from loading this buffer
  74977. */
  74978. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74979. /**
  74980. * Defines an override for loading texture buffers
  74981. * Return true to stop further extensions from loading this texture data
  74982. */
  74983. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74984. /**
  74985. * Defines an override for creating textures
  74986. * Return true to stop further extensions from loading this texture
  74987. */
  74988. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74989. /**
  74990. * Defines an override for loading shader strings
  74991. * Return true to stop further extensions from loading this shader data
  74992. */
  74993. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74994. /**
  74995. * Defines an override for loading materials
  74996. * Return true to stop further extensions from loading this material
  74997. */
  74998. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74999. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75000. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75001. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75002. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75003. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75004. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75005. private static LoadTextureBufferAsync;
  75006. private static CreateTextureAsync;
  75007. private static ApplyExtensions;
  75008. }
  75009. }
  75010. declare module BABYLON.GLTF1 {
  75011. /** @hidden */
  75012. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75013. private _bin;
  75014. constructor();
  75015. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75016. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75017. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75018. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75019. }
  75020. }
  75021. declare module BABYLON.GLTF1 {
  75022. /** @hidden */
  75023. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75024. constructor();
  75025. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75026. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75027. private _loadTexture;
  75028. }
  75029. }
  75030. declare module BABYLON.GLTF2.Loader {
  75031. /**
  75032. * Loader interface with an index field.
  75033. */
  75034. export interface IArrayItem {
  75035. /**
  75036. * The index of this item in the array.
  75037. */
  75038. index: number;
  75039. }
  75040. /**
  75041. * Loader interface with additional members.
  75042. */
  75043. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75044. /** @hidden */
  75045. _data?: Promise<ArrayBufferView>;
  75046. /** @hidden */
  75047. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75048. }
  75049. /**
  75050. * Loader interface with additional members.
  75051. */
  75052. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75053. }
  75054. /** @hidden */
  75055. export interface _IAnimationSamplerData {
  75056. input: Float32Array;
  75057. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75058. output: Float32Array;
  75059. }
  75060. /**
  75061. * Loader interface with additional members.
  75062. */
  75063. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75064. /** @hidden */
  75065. _data?: Promise<_IAnimationSamplerData>;
  75066. }
  75067. /**
  75068. * Loader interface with additional members.
  75069. */
  75070. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75071. channels: IAnimationChannel[];
  75072. samplers: IAnimationSampler[];
  75073. /** @hidden */
  75074. _babylonAnimationGroup?: AnimationGroup;
  75075. }
  75076. /**
  75077. * Loader interface with additional members.
  75078. */
  75079. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75080. /** @hidden */
  75081. _data?: Promise<ArrayBufferView>;
  75082. }
  75083. /**
  75084. * Loader interface with additional members.
  75085. */
  75086. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75087. /** @hidden */
  75088. _data?: Promise<ArrayBufferView>;
  75089. /** @hidden */
  75090. _babylonBuffer?: Promise<Buffer>;
  75091. }
  75092. /**
  75093. * Loader interface with additional members.
  75094. */
  75095. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75096. }
  75097. /**
  75098. * Loader interface with additional members.
  75099. */
  75100. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75101. /** @hidden */
  75102. _data?: Promise<ArrayBufferView>;
  75103. }
  75104. /**
  75105. * Loader interface with additional members.
  75106. */
  75107. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75108. }
  75109. /**
  75110. * Loader interface with additional members.
  75111. */
  75112. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75113. }
  75114. /**
  75115. * Loader interface with additional members.
  75116. */
  75117. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75118. baseColorTexture?: ITextureInfo;
  75119. metallicRoughnessTexture?: ITextureInfo;
  75120. }
  75121. /**
  75122. * Loader interface with additional members.
  75123. */
  75124. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75125. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75126. normalTexture?: IMaterialNormalTextureInfo;
  75127. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75128. emissiveTexture?: ITextureInfo;
  75129. /** @hidden */
  75130. _data?: {
  75131. [babylonDrawMode: number]: {
  75132. babylonMaterial: Material;
  75133. babylonMeshes: AbstractMesh[];
  75134. promise: Promise<void>;
  75135. };
  75136. };
  75137. }
  75138. /**
  75139. * Loader interface with additional members.
  75140. */
  75141. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75142. primitives: IMeshPrimitive[];
  75143. }
  75144. /**
  75145. * Loader interface with additional members.
  75146. */
  75147. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75148. /** @hidden */
  75149. _instanceData?: {
  75150. babylonSourceMesh: Mesh;
  75151. promise: Promise<any>;
  75152. };
  75153. }
  75154. /**
  75155. * Loader interface with additional members.
  75156. */
  75157. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75158. /**
  75159. * The parent glTF node.
  75160. */
  75161. parent?: INode;
  75162. /** @hidden */
  75163. _babylonTransformNode?: TransformNode;
  75164. /** @hidden */
  75165. _primitiveBabylonMeshes?: AbstractMesh[];
  75166. /** @hidden */
  75167. _babylonBones?: Bone[];
  75168. /** @hidden */
  75169. _numMorphTargets?: number;
  75170. }
  75171. /** @hidden */
  75172. export interface _ISamplerData {
  75173. noMipMaps: boolean;
  75174. samplingMode: number;
  75175. wrapU: number;
  75176. wrapV: number;
  75177. }
  75178. /**
  75179. * Loader interface with additional members.
  75180. */
  75181. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75182. /** @hidden */
  75183. _data?: _ISamplerData;
  75184. }
  75185. /**
  75186. * Loader interface with additional members.
  75187. */
  75188. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75189. }
  75190. /**
  75191. * Loader interface with additional members.
  75192. */
  75193. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75194. /** @hidden */
  75195. _data?: {
  75196. babylonSkeleton: Skeleton;
  75197. promise: Promise<void>;
  75198. };
  75199. }
  75200. /**
  75201. * Loader interface with additional members.
  75202. */
  75203. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75204. }
  75205. /**
  75206. * Loader interface with additional members.
  75207. */
  75208. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75209. }
  75210. /**
  75211. * Loader interface with additional members.
  75212. */
  75213. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75214. accessors?: IAccessor[];
  75215. animations?: IAnimation[];
  75216. buffers?: IBuffer[];
  75217. bufferViews?: IBufferView[];
  75218. cameras?: ICamera[];
  75219. images?: IImage[];
  75220. materials?: IMaterial[];
  75221. meshes?: IMesh[];
  75222. nodes?: INode[];
  75223. samplers?: ISampler[];
  75224. scenes?: IScene[];
  75225. skins?: ISkin[];
  75226. textures?: ITexture[];
  75227. }
  75228. }
  75229. declare module BABYLON.GLTF2 {
  75230. /**
  75231. * Interface for a glTF loader extension.
  75232. */
  75233. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75234. /**
  75235. * Called after the loader state changes to LOADING.
  75236. */
  75237. onLoading?(): void;
  75238. /**
  75239. * Called after the loader state changes to READY.
  75240. */
  75241. onReady?(): void;
  75242. /**
  75243. * Define this method to modify the default behavior when loading scenes.
  75244. * @param context The context when loading the asset
  75245. * @param scene The glTF scene property
  75246. * @returns A promise that resolves when the load is complete or null if not handled
  75247. */
  75248. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75249. /**
  75250. * Define this method to modify the default behavior when loading nodes.
  75251. * @param context The context when loading the asset
  75252. * @param node The glTF node property
  75253. * @param assign A function called synchronously after parsing the glTF properties
  75254. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75255. */
  75256. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75257. /**
  75258. * Define this method to modify the default behavior when loading cameras.
  75259. * @param context The context when loading the asset
  75260. * @param camera The glTF camera property
  75261. * @param assign A function called synchronously after parsing the glTF properties
  75262. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75263. */
  75264. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75265. /**
  75266. * @hidden
  75267. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75268. * @param context The context when loading the asset
  75269. * @param primitive The glTF mesh primitive property
  75270. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75271. */
  75272. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75273. /**
  75274. * @hidden
  75275. * Define this method to modify the default behavior when loading data for mesh primitives.
  75276. * @param context The context when loading the asset
  75277. * @param name The mesh name when loading the asset
  75278. * @param node The glTF node when loading the asset
  75279. * @param mesh The glTF mesh when loading the asset
  75280. * @param primitive The glTF mesh primitive property
  75281. * @param assign A function called synchronously after parsing the glTF properties
  75282. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75283. */
  75284. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75285. /**
  75286. * @hidden
  75287. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75288. * @param context The context when loading the asset
  75289. * @param material The glTF material property
  75290. * @param assign A function called synchronously after parsing the glTF properties
  75291. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75292. */
  75293. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75294. /**
  75295. * Define this method to modify the default behavior when creating materials.
  75296. * @param context The context when loading the asset
  75297. * @param material The glTF material property
  75298. * @param babylonDrawMode The draw mode for the Babylon material
  75299. * @returns The Babylon material or null if not handled
  75300. */
  75301. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75302. /**
  75303. * Define this method to modify the default behavior when loading material properties.
  75304. * @param context The context when loading the asset
  75305. * @param material The glTF material property
  75306. * @param babylonMaterial The Babylon material
  75307. * @returns A promise that resolves when the load is complete or null if not handled
  75308. */
  75309. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75310. /**
  75311. * Define this method to modify the default behavior when loading texture infos.
  75312. * @param context The context when loading the asset
  75313. * @param textureInfo The glTF texture info property
  75314. * @param assign A function called synchronously after parsing the glTF properties
  75315. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75316. */
  75317. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75318. /**
  75319. * @hidden
  75320. * Define this method to modify the default behavior when loading textures.
  75321. * @param context The context when loading the asset
  75322. * @param texture The glTF texture property
  75323. * @param assign A function called synchronously after parsing the glTF properties
  75324. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75325. */
  75326. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75327. /**
  75328. * Define this method to modify the default behavior when loading animations.
  75329. * @param context The context when loading the asset
  75330. * @param animation The glTF animation property
  75331. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75332. */
  75333. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75334. /**
  75335. * @hidden
  75336. * Define this method to modify the default behavior when loading skins.
  75337. * @param context The context when loading the asset
  75338. * @param node The glTF node property
  75339. * @param skin The glTF skin property
  75340. * @returns A promise that resolves when the load is complete or null if not handled
  75341. */
  75342. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75343. /**
  75344. * @hidden
  75345. * Define this method to modify the default behavior when loading uris.
  75346. * @param context The context when loading the asset
  75347. * @param property The glTF property associated with the uri
  75348. * @param uri The uri to load
  75349. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75350. */
  75351. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75352. /**
  75353. * Define this method to modify the default behavior when loading buffer views.
  75354. * @param context The context when loading the asset
  75355. * @param bufferView The glTF buffer view property
  75356. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75357. */
  75358. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75359. /**
  75360. * Define this method to modify the default behavior when loading buffers.
  75361. * @param context The context when loading the asset
  75362. * @param buffer The glTF buffer property
  75363. * @param byteOffset The byte offset to load
  75364. * @param byteLength The byte length to load
  75365. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75366. */
  75367. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75368. }
  75369. }
  75370. declare module BABYLON.GLTF2 {
  75371. /**
  75372. * Helper class for working with arrays when loading the glTF asset
  75373. */
  75374. export class ArrayItem {
  75375. /**
  75376. * Gets an item from the given array.
  75377. * @param context The context when loading the asset
  75378. * @param array The array to get the item from
  75379. * @param index The index to the array
  75380. * @returns The array item
  75381. */
  75382. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75383. /**
  75384. * Assign an `index` field to each item of the given array.
  75385. * @param array The array of items
  75386. */
  75387. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75388. }
  75389. /**
  75390. * The glTF 2.0 loader
  75391. */
  75392. export class GLTFLoader implements IGLTFLoader {
  75393. /** @hidden */
  75394. _completePromises: Promise<any>[];
  75395. /** @hidden */
  75396. _forAssetContainer: boolean;
  75397. /** Storage */
  75398. _babylonLights: Light[];
  75399. private _disposed;
  75400. private _parent;
  75401. private _state;
  75402. private _extensions;
  75403. private _rootUrl;
  75404. private _fileName;
  75405. private _uniqueRootUrl;
  75406. private _gltf;
  75407. private _bin;
  75408. private _babylonScene;
  75409. private _rootBabylonMesh;
  75410. private _defaultBabylonMaterialData;
  75411. private _progressCallback?;
  75412. private _requests;
  75413. private static _RegisteredExtensions;
  75414. /**
  75415. * The default glTF sampler.
  75416. */
  75417. static readonly DefaultSampler: ISampler;
  75418. /**
  75419. * Registers a loader extension.
  75420. * @param name The name of the loader extension.
  75421. * @param factory The factory function that creates the loader extension.
  75422. */
  75423. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75424. /**
  75425. * Unregisters a loader extension.
  75426. * @param name The name of the loader extension.
  75427. * @returns A boolean indicating whether the extension has been unregistered
  75428. */
  75429. static UnregisterExtension(name: string): boolean;
  75430. /**
  75431. * The loader state.
  75432. */
  75433. get state(): Nullable<GLTFLoaderState>;
  75434. /**
  75435. * The object that represents the glTF JSON.
  75436. */
  75437. get gltf(): IGLTF;
  75438. /**
  75439. * The BIN chunk of a binary glTF.
  75440. */
  75441. get bin(): Nullable<IDataBuffer>;
  75442. /**
  75443. * The parent file loader.
  75444. */
  75445. get parent(): GLTFFileLoader;
  75446. /**
  75447. * The Babylon scene when loading the asset.
  75448. */
  75449. get babylonScene(): Scene;
  75450. /**
  75451. * The root Babylon mesh when loading the asset.
  75452. */
  75453. get rootBabylonMesh(): Mesh;
  75454. /** @hidden */
  75455. constructor(parent: GLTFFileLoader);
  75456. /** @hidden */
  75457. dispose(): void;
  75458. /** @hidden */
  75459. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75460. /** @hidden */
  75461. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75462. private _loadAsync;
  75463. private _loadData;
  75464. private _setupData;
  75465. private _loadExtensions;
  75466. private _checkExtensions;
  75467. private _setState;
  75468. private _createRootNode;
  75469. /**
  75470. * Loads a glTF scene.
  75471. * @param context The context when loading the asset
  75472. * @param scene The glTF scene property
  75473. * @returns A promise that resolves when the load is complete
  75474. */
  75475. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75476. private _forEachPrimitive;
  75477. private _getMeshes;
  75478. private _getTransformNodes;
  75479. private _getSkeletons;
  75480. private _getAnimationGroups;
  75481. private _startAnimations;
  75482. /**
  75483. * Loads a glTF node.
  75484. * @param context The context when loading the asset
  75485. * @param node The glTF node property
  75486. * @param assign A function called synchronously after parsing the glTF properties
  75487. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75488. */
  75489. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75490. private _loadMeshAsync;
  75491. /**
  75492. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75493. * @param context The context when loading the asset
  75494. * @param name The mesh name when loading the asset
  75495. * @param node The glTF node when loading the asset
  75496. * @param mesh The glTF mesh when loading the asset
  75497. * @param primitive The glTF mesh primitive property
  75498. * @param assign A function called synchronously after parsing the glTF properties
  75499. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75500. */
  75501. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75502. private _loadVertexDataAsync;
  75503. private _createMorphTargets;
  75504. private _loadMorphTargetsAsync;
  75505. private _loadMorphTargetVertexDataAsync;
  75506. private static _LoadTransform;
  75507. private _loadSkinAsync;
  75508. private _loadBones;
  75509. private _loadBone;
  75510. private _loadSkinInverseBindMatricesDataAsync;
  75511. private _updateBoneMatrices;
  75512. private _getNodeMatrix;
  75513. /**
  75514. * Loads a glTF camera.
  75515. * @param context The context when loading the asset
  75516. * @param camera The glTF camera property
  75517. * @param assign A function called synchronously after parsing the glTF properties
  75518. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75519. */
  75520. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75521. private _loadAnimationsAsync;
  75522. /**
  75523. * Loads a glTF animation.
  75524. * @param context The context when loading the asset
  75525. * @param animation The glTF animation property
  75526. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75527. */
  75528. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75529. /**
  75530. * @hidden Loads a glTF animation channel.
  75531. * @param context The context when loading the asset
  75532. * @param animationContext The context of the animation when loading the asset
  75533. * @param animation The glTF animation property
  75534. * @param channel The glTF animation channel property
  75535. * @param babylonAnimationGroup The babylon animation group property
  75536. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75537. * @returns A void promise when the channel load is complete
  75538. */
  75539. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75540. private _loadAnimationSamplerAsync;
  75541. private _loadBufferAsync;
  75542. /**
  75543. * Loads a glTF buffer view.
  75544. * @param context The context when loading the asset
  75545. * @param bufferView The glTF buffer view property
  75546. * @returns A promise that resolves with the loaded data when the load is complete
  75547. */
  75548. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75549. private _loadAccessorAsync;
  75550. private _loadFloatAccessorAsync;
  75551. private _loadIndicesAccessorAsync;
  75552. private _loadVertexBufferViewAsync;
  75553. private _loadVertexAccessorAsync;
  75554. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75555. /** @hidden */
  75556. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75557. private _createDefaultMaterial;
  75558. /**
  75559. * Creates a Babylon material from a glTF material.
  75560. * @param context The context when loading the asset
  75561. * @param material The glTF material property
  75562. * @param babylonDrawMode The draw mode for the Babylon material
  75563. * @returns The Babylon material
  75564. */
  75565. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75566. /**
  75567. * Loads properties from a glTF material into a Babylon material.
  75568. * @param context The context when loading the asset
  75569. * @param material The glTF material property
  75570. * @param babylonMaterial The Babylon material
  75571. * @returns A promise that resolves when the load is complete
  75572. */
  75573. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75574. /**
  75575. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75576. * @param context The context when loading the asset
  75577. * @param material The glTF material property
  75578. * @param babylonMaterial The Babylon material
  75579. * @returns A promise that resolves when the load is complete
  75580. */
  75581. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75582. /**
  75583. * Loads the alpha properties from a glTF material into a Babylon material.
  75584. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75585. * @param context The context when loading the asset
  75586. * @param material The glTF material property
  75587. * @param babylonMaterial The Babylon material
  75588. */
  75589. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75590. /**
  75591. * Loads a glTF texture info.
  75592. * @param context The context when loading the asset
  75593. * @param textureInfo The glTF texture info property
  75594. * @param assign A function called synchronously after parsing the glTF properties
  75595. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75596. */
  75597. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75598. /** @hidden */
  75599. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75600. /** @hidden */
  75601. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75602. private _loadSampler;
  75603. /**
  75604. * Loads a glTF image.
  75605. * @param context The context when loading the asset
  75606. * @param image The glTF image property
  75607. * @returns A promise that resolves with the loaded data when the load is complete
  75608. */
  75609. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75610. /**
  75611. * Loads a glTF uri.
  75612. * @param context The context when loading the asset
  75613. * @param property The glTF property associated with the uri
  75614. * @param uri The base64 or relative uri
  75615. * @returns A promise that resolves with the loaded data when the load is complete
  75616. */
  75617. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75618. private _onProgress;
  75619. /**
  75620. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75621. * @param babylonObject the Babylon object with metadata
  75622. * @param pointer the JSON pointer
  75623. */
  75624. static AddPointerMetadata(babylonObject: {
  75625. metadata: any;
  75626. }, pointer: string): void;
  75627. private static _GetTextureWrapMode;
  75628. private static _GetTextureSamplingMode;
  75629. private static _GetTypedArrayConstructor;
  75630. private static _GetTypedArray;
  75631. private static _GetNumComponents;
  75632. private static _ValidateUri;
  75633. private static _GetDrawMode;
  75634. private _compileMaterialsAsync;
  75635. private _compileShadowGeneratorsAsync;
  75636. private _forEachExtensions;
  75637. private _applyExtensions;
  75638. private _extensionsOnLoading;
  75639. private _extensionsOnReady;
  75640. private _extensionsLoadSceneAsync;
  75641. private _extensionsLoadNodeAsync;
  75642. private _extensionsLoadCameraAsync;
  75643. private _extensionsLoadVertexDataAsync;
  75644. private _extensionsLoadMeshPrimitiveAsync;
  75645. private _extensionsLoadMaterialAsync;
  75646. private _extensionsCreateMaterial;
  75647. private _extensionsLoadMaterialPropertiesAsync;
  75648. private _extensionsLoadTextureInfoAsync;
  75649. private _extensionsLoadTextureAsync;
  75650. private _extensionsLoadAnimationAsync;
  75651. private _extensionsLoadSkinAsync;
  75652. private _extensionsLoadUriAsync;
  75653. private _extensionsLoadBufferViewAsync;
  75654. private _extensionsLoadBufferAsync;
  75655. /**
  75656. * Helper method called by a loader extension to load an glTF extension.
  75657. * @param context The context when loading the asset
  75658. * @param property The glTF property to load the extension from
  75659. * @param extensionName The name of the extension to load
  75660. * @param actionAsync The action to run
  75661. * @returns The promise returned by actionAsync or null if the extension does not exist
  75662. */
  75663. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75664. /**
  75665. * Helper method called by a loader extension to load a glTF extra.
  75666. * @param context The context when loading the asset
  75667. * @param property The glTF property to load the extra from
  75668. * @param extensionName The name of the extension to load
  75669. * @param actionAsync The action to run
  75670. * @returns The promise returned by actionAsync or null if the extra does not exist
  75671. */
  75672. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75673. /**
  75674. * Checks for presence of an extension.
  75675. * @param name The name of the extension to check
  75676. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75677. */
  75678. isExtensionUsed(name: string): boolean;
  75679. /**
  75680. * Increments the indentation level and logs a message.
  75681. * @param message The message to log
  75682. */
  75683. logOpen(message: string): void;
  75684. /**
  75685. * Decrements the indentation level.
  75686. */
  75687. logClose(): void;
  75688. /**
  75689. * Logs a message
  75690. * @param message The message to log
  75691. */
  75692. log(message: string): void;
  75693. /**
  75694. * Starts a performance counter.
  75695. * @param counterName The name of the performance counter
  75696. */
  75697. startPerformanceCounter(counterName: string): void;
  75698. /**
  75699. * Ends a performance counter.
  75700. * @param counterName The name of the performance counter
  75701. */
  75702. endPerformanceCounter(counterName: string): void;
  75703. }
  75704. }
  75705. declare module BABYLON.GLTF2.Loader.Extensions {
  75706. /**
  75707. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75708. */
  75709. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75710. /**
  75711. * The name of this extension.
  75712. */
  75713. readonly name: string;
  75714. /**
  75715. * Defines whether this extension is enabled.
  75716. */
  75717. enabled: boolean;
  75718. private _loader;
  75719. private _lights?;
  75720. /** @hidden */
  75721. constructor(loader: GLTFLoader);
  75722. /** @hidden */
  75723. dispose(): void;
  75724. /** @hidden */
  75725. onLoading(): void;
  75726. /** @hidden */
  75727. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75728. private _loadLightAsync;
  75729. }
  75730. }
  75731. declare module BABYLON.GLTF2.Loader.Extensions {
  75732. /**
  75733. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75734. */
  75735. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75736. /**
  75737. * The name of this extension.
  75738. */
  75739. readonly name: string;
  75740. /**
  75741. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75742. */
  75743. dracoCompression?: DracoCompression;
  75744. /**
  75745. * Defines whether this extension is enabled.
  75746. */
  75747. enabled: boolean;
  75748. private _loader;
  75749. /** @hidden */
  75750. constructor(loader: GLTFLoader);
  75751. /** @hidden */
  75752. dispose(): void;
  75753. /** @hidden */
  75754. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75755. }
  75756. }
  75757. declare module BABYLON.GLTF2.Loader.Extensions {
  75758. /**
  75759. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  75760. */
  75761. export class KHR_lights implements IGLTFLoaderExtension {
  75762. /**
  75763. * The name of this extension.
  75764. */
  75765. readonly name: string;
  75766. /**
  75767. * Defines whether this extension is enabled.
  75768. */
  75769. enabled: boolean;
  75770. private _loader;
  75771. private _lights?;
  75772. /** @hidden */
  75773. constructor(loader: GLTFLoader);
  75774. /** @hidden */
  75775. dispose(): void;
  75776. /** @hidden */
  75777. onLoading(): void;
  75778. /** @hidden */
  75779. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75780. }
  75781. }
  75782. declare module BABYLON.GLTF2.Loader.Extensions {
  75783. /**
  75784. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75785. */
  75786. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75787. /**
  75788. * The name of this extension.
  75789. */
  75790. readonly name: string;
  75791. /**
  75792. * Defines whether this extension is enabled.
  75793. */
  75794. enabled: boolean;
  75795. /**
  75796. * Defines a number that determines the order the extensions are applied.
  75797. */
  75798. order: number;
  75799. private _loader;
  75800. /** @hidden */
  75801. constructor(loader: GLTFLoader);
  75802. /** @hidden */
  75803. dispose(): void;
  75804. /** @hidden */
  75805. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75806. private _loadSpecularGlossinessPropertiesAsync;
  75807. }
  75808. }
  75809. declare module BABYLON.GLTF2.Loader.Extensions {
  75810. /**
  75811. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75812. */
  75813. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75814. /**
  75815. * The name of this extension.
  75816. */
  75817. readonly name: string;
  75818. /**
  75819. * Defines whether this extension is enabled.
  75820. */
  75821. enabled: boolean;
  75822. /**
  75823. * Defines a number that determines the order the extensions are applied.
  75824. */
  75825. order: number;
  75826. private _loader;
  75827. /** @hidden */
  75828. constructor(loader: GLTFLoader);
  75829. /** @hidden */
  75830. dispose(): void;
  75831. /** @hidden */
  75832. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75833. private _loadUnlitPropertiesAsync;
  75834. }
  75835. }
  75836. declare module BABYLON.GLTF2.Loader.Extensions {
  75837. /**
  75838. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75839. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75840. * !!! Experimental Extension Subject to Changes !!!
  75841. */
  75842. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75843. /**
  75844. * The name of this extension.
  75845. */
  75846. readonly name: string;
  75847. /**
  75848. * Defines whether this extension is enabled.
  75849. */
  75850. enabled: boolean;
  75851. /**
  75852. * Defines a number that determines the order the extensions are applied.
  75853. */
  75854. order: number;
  75855. private _loader;
  75856. /** @hidden */
  75857. constructor(loader: GLTFLoader);
  75858. /** @hidden */
  75859. dispose(): void;
  75860. /** @hidden */
  75861. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75862. private _loadClearCoatPropertiesAsync;
  75863. }
  75864. }
  75865. declare module BABYLON.GLTF2.Loader.Extensions {
  75866. /**
  75867. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75868. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75869. * !!! Experimental Extension Subject to Changes !!!
  75870. */
  75871. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75872. /**
  75873. * The name of this extension.
  75874. */
  75875. readonly name: string;
  75876. /**
  75877. * Defines whether this extension is enabled.
  75878. */
  75879. enabled: boolean;
  75880. /**
  75881. * Defines a number that determines the order the extensions are applied.
  75882. */
  75883. order: number;
  75884. private _loader;
  75885. /** @hidden */
  75886. constructor(loader: GLTFLoader);
  75887. /** @hidden */
  75888. dispose(): void;
  75889. /** @hidden */
  75890. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75891. private _loadSheenPropertiesAsync;
  75892. }
  75893. }
  75894. declare module BABYLON.GLTF2.Loader.Extensions {
  75895. /**
  75896. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75897. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75898. * !!! Experimental Extension Subject to Changes !!!
  75899. */
  75900. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75901. /**
  75902. * The name of this extension.
  75903. */
  75904. readonly name: string;
  75905. /**
  75906. * Defines whether this extension is enabled.
  75907. */
  75908. enabled: boolean;
  75909. /**
  75910. * Defines a number that determines the order the extensions are applied.
  75911. */
  75912. order: number;
  75913. private _loader;
  75914. /** @hidden */
  75915. constructor(loader: GLTFLoader);
  75916. /** @hidden */
  75917. dispose(): void;
  75918. /** @hidden */
  75919. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75920. private _loadSpecularPropertiesAsync;
  75921. }
  75922. }
  75923. declare module BABYLON.GLTF2.Loader.Extensions {
  75924. /**
  75925. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75926. */
  75927. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75928. /**
  75929. * The name of this extension.
  75930. */
  75931. readonly name: string;
  75932. /**
  75933. * Defines whether this extension is enabled.
  75934. */
  75935. enabled: boolean;
  75936. /** @hidden */
  75937. constructor(loader: GLTFLoader);
  75938. /** @hidden */
  75939. dispose(): void;
  75940. }
  75941. }
  75942. declare module BABYLON.GLTF2.Loader.Extensions {
  75943. /**
  75944. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  75945. * !!! Experimental Extension Subject to Changes !!!
  75946. */
  75947. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  75948. /** The name of this extension. */
  75949. readonly name: string;
  75950. /** Defines whether this extension is enabled. */
  75951. enabled: boolean;
  75952. private _loader;
  75953. /** @hidden */
  75954. constructor(loader: GLTFLoader);
  75955. /** @hidden */
  75956. dispose(): void;
  75957. /** @hidden */
  75958. loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75959. }
  75960. }
  75961. declare module BABYLON.GLTF2.Loader.Extensions {
  75962. /**
  75963. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  75964. */
  75965. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75966. /**
  75967. * The name of this extension.
  75968. */
  75969. readonly name: string;
  75970. /**
  75971. * Defines whether this extension is enabled.
  75972. */
  75973. enabled: boolean;
  75974. private _loader;
  75975. /** @hidden */
  75976. constructor(loader: GLTFLoader);
  75977. /** @hidden */
  75978. dispose(): void;
  75979. /** @hidden */
  75980. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75981. }
  75982. }
  75983. declare module BABYLON.GLTF2.Loader.Extensions {
  75984. /**
  75985. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75986. */
  75987. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75988. /**
  75989. * The name of this extension.
  75990. */
  75991. readonly name: string;
  75992. /**
  75993. * Defines whether this extension is enabled.
  75994. */
  75995. enabled: boolean;
  75996. private _loader;
  75997. private _clips;
  75998. private _emitters;
  75999. /** @hidden */
  76000. constructor(loader: GLTFLoader);
  76001. /** @hidden */
  76002. dispose(): void;
  76003. /** @hidden */
  76004. onLoading(): void;
  76005. /** @hidden */
  76006. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76007. /** @hidden */
  76008. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76009. /** @hidden */
  76010. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76011. private _loadClipAsync;
  76012. private _loadEmitterAsync;
  76013. private _getEventAction;
  76014. private _loadAnimationEventAsync;
  76015. }
  76016. }
  76017. declare module BABYLON.GLTF2.Loader.Extensions {
  76018. /**
  76019. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76020. */
  76021. export class MSFT_lod implements IGLTFLoaderExtension {
  76022. /**
  76023. * The name of this extension.
  76024. */
  76025. readonly name: string;
  76026. /**
  76027. * Defines whether this extension is enabled.
  76028. */
  76029. enabled: boolean;
  76030. /**
  76031. * Defines a number that determines the order the extensions are applied.
  76032. */
  76033. order: number;
  76034. /**
  76035. * Maximum number of LODs to load, starting from the lowest LOD.
  76036. */
  76037. maxLODsToLoad: number;
  76038. /**
  76039. * Observable raised when all node LODs of one level are loaded.
  76040. * The event data is the index of the loaded LOD starting from zero.
  76041. * Dispose the loader to cancel the loading of the next level of LODs.
  76042. */
  76043. onNodeLODsLoadedObservable: Observable<number>;
  76044. /**
  76045. * Observable raised when all material LODs of one level are loaded.
  76046. * The event data is the index of the loaded LOD starting from zero.
  76047. * Dispose the loader to cancel the loading of the next level of LODs.
  76048. */
  76049. onMaterialLODsLoadedObservable: Observable<number>;
  76050. private _loader;
  76051. private _nodeIndexLOD;
  76052. private _nodeSignalLODs;
  76053. private _nodePromiseLODs;
  76054. private _materialIndexLOD;
  76055. private _materialSignalLODs;
  76056. private _materialPromiseLODs;
  76057. private _indexLOD;
  76058. private _bufferLODs;
  76059. /** @hidden */
  76060. constructor(loader: GLTFLoader);
  76061. /** @hidden */
  76062. dispose(): void;
  76063. /** @hidden */
  76064. onReady(): void;
  76065. /** @hidden */
  76066. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76067. /** @hidden */
  76068. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76069. /** @hidden */
  76070. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76071. /** @hidden */
  76072. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76073. /** @hidden */
  76074. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76075. private _loadBufferLOD;
  76076. /**
  76077. * Gets an array of LOD properties from lowest to highest.
  76078. */
  76079. private _getLODs;
  76080. private _disposeTransformNode;
  76081. private _disposeMaterials;
  76082. }
  76083. }
  76084. declare module BABYLON.GLTF2.Loader.Extensions {
  76085. /** @hidden */
  76086. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76087. readonly name: string;
  76088. enabled: boolean;
  76089. private _loader;
  76090. constructor(loader: GLTFLoader);
  76091. dispose(): void;
  76092. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76093. }
  76094. }
  76095. declare module BABYLON.GLTF2.Loader.Extensions {
  76096. /** @hidden */
  76097. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76098. readonly name: string;
  76099. enabled: boolean;
  76100. private _loader;
  76101. constructor(loader: GLTFLoader);
  76102. dispose(): void;
  76103. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76104. }
  76105. }
  76106. declare module BABYLON.GLTF2.Loader.Extensions {
  76107. /**
  76108. * Store glTF extras (if present) in BJS objects' metadata
  76109. */
  76110. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76111. /**
  76112. * The name of this extension.
  76113. */
  76114. readonly name: string;
  76115. /**
  76116. * Defines whether this extension is enabled.
  76117. */
  76118. enabled: boolean;
  76119. private _loader;
  76120. private _assignExtras;
  76121. /** @hidden */
  76122. constructor(loader: GLTFLoader);
  76123. /** @hidden */
  76124. dispose(): void;
  76125. /** @hidden */
  76126. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76127. /** @hidden */
  76128. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76129. /** @hidden */
  76130. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76131. }
  76132. }
  76133. declare module BABYLON {
  76134. /**
  76135. * Class reading and parsing the MTL file bundled with the obj file.
  76136. */
  76137. export class MTLFileLoader {
  76138. /**
  76139. * Invert Y-Axis of referenced textures on load
  76140. */
  76141. static INVERT_TEXTURE_Y: boolean;
  76142. /**
  76143. * All material loaded from the mtl will be set here
  76144. */
  76145. materials: StandardMaterial[];
  76146. /**
  76147. * This function will read the mtl file and create each material described inside
  76148. * This function could be improve by adding :
  76149. * -some component missing (Ni, Tf...)
  76150. * -including the specific options available
  76151. *
  76152. * @param scene defines the scene the material will be created in
  76153. * @param data defines the mtl data to parse
  76154. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76155. * @param forAssetContainer defines if the material should be registered in the scene
  76156. */
  76157. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76158. /**
  76159. * Gets the texture for the material.
  76160. *
  76161. * If the material is imported from input file,
  76162. * We sanitize the url to ensure it takes the textre from aside the material.
  76163. *
  76164. * @param rootUrl The root url to load from
  76165. * @param value The value stored in the mtl
  76166. * @return The Texture
  76167. */
  76168. private static _getTexture;
  76169. }
  76170. }
  76171. declare module BABYLON {
  76172. /**
  76173. * Options for loading OBJ/MTL files
  76174. */
  76175. type MeshLoadOptions = {
  76176. /**
  76177. * Defines if UVs are optimized by default during load.
  76178. */
  76179. OptimizeWithUV: boolean;
  76180. /**
  76181. * Defines custom scaling of UV coordinates of loaded meshes.
  76182. */
  76183. UVScaling: Vector2;
  76184. /**
  76185. * Invert model on y-axis (does a model scaling inversion)
  76186. */
  76187. InvertY: boolean;
  76188. /**
  76189. * Invert Y-Axis of referenced textures on load
  76190. */
  76191. InvertTextureY: boolean;
  76192. /**
  76193. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76194. */
  76195. ImportVertexColors: boolean;
  76196. /**
  76197. * Compute the normals for the model, even if normals are present in the file.
  76198. */
  76199. ComputeNormals: boolean;
  76200. /**
  76201. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76202. */
  76203. SkipMaterials: boolean;
  76204. /**
  76205. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76206. */
  76207. MaterialLoadingFailsSilently: boolean;
  76208. };
  76209. /**
  76210. * OBJ file type loader.
  76211. * This is a babylon scene loader plugin.
  76212. */
  76213. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76214. /**
  76215. * Defines if UVs are optimized by default during load.
  76216. */
  76217. static OPTIMIZE_WITH_UV: boolean;
  76218. /**
  76219. * Invert model on y-axis (does a model scaling inversion)
  76220. */
  76221. static INVERT_Y: boolean;
  76222. /**
  76223. * Invert Y-Axis of referenced textures on load
  76224. */
  76225. static get INVERT_TEXTURE_Y(): boolean;
  76226. static set INVERT_TEXTURE_Y(value: boolean);
  76227. /**
  76228. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76229. */
  76230. static IMPORT_VERTEX_COLORS: boolean;
  76231. /**
  76232. * Compute the normals for the model, even if normals are present in the file.
  76233. */
  76234. static COMPUTE_NORMALS: boolean;
  76235. /**
  76236. * Defines custom scaling of UV coordinates of loaded meshes.
  76237. */
  76238. static UV_SCALING: Vector2;
  76239. /**
  76240. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76241. */
  76242. static SKIP_MATERIALS: boolean;
  76243. /**
  76244. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76245. *
  76246. * Defaults to true for backwards compatibility.
  76247. */
  76248. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76249. /**
  76250. * Defines the name of the plugin.
  76251. */
  76252. name: string;
  76253. /**
  76254. * Defines the extension the plugin is able to load.
  76255. */
  76256. extensions: string;
  76257. /** @hidden */
  76258. obj: RegExp;
  76259. /** @hidden */
  76260. group: RegExp;
  76261. /** @hidden */
  76262. mtllib: RegExp;
  76263. /** @hidden */
  76264. usemtl: RegExp;
  76265. /** @hidden */
  76266. smooth: RegExp;
  76267. /** @hidden */
  76268. vertexPattern: RegExp;
  76269. /** @hidden */
  76270. normalPattern: RegExp;
  76271. /** @hidden */
  76272. uvPattern: RegExp;
  76273. /** @hidden */
  76274. facePattern1: RegExp;
  76275. /** @hidden */
  76276. facePattern2: RegExp;
  76277. /** @hidden */
  76278. facePattern3: RegExp;
  76279. /** @hidden */
  76280. facePattern4: RegExp;
  76281. /** @hidden */
  76282. facePattern5: RegExp;
  76283. private _forAssetContainer;
  76284. private _meshLoadOptions;
  76285. /**
  76286. * Creates loader for .OBJ files
  76287. *
  76288. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76289. */
  76290. constructor(meshLoadOptions?: MeshLoadOptions);
  76291. private static get currentMeshLoadOptions();
  76292. /**
  76293. * Calls synchronously the MTL file attached to this obj.
  76294. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76295. * Without this function materials are not displayed in the first frame (but displayed after).
  76296. * In consequence it is impossible to get material information in your HTML file
  76297. *
  76298. * @param url The URL of the MTL file
  76299. * @param rootUrl
  76300. * @param onSuccess Callback function to be called when the MTL file is loaded
  76301. * @private
  76302. */
  76303. private _loadMTL;
  76304. /**
  76305. * Instantiates a OBJ file loader plugin.
  76306. * @returns the created plugin
  76307. */
  76308. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76309. /**
  76310. * If the data string can be loaded directly.
  76311. *
  76312. * @param data string containing the file data
  76313. * @returns if the data can be loaded directly
  76314. */
  76315. canDirectLoad(data: string): boolean;
  76316. /**
  76317. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76318. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76319. * @param scene the scene the meshes should be added to
  76320. * @param data the OBJ data to load
  76321. * @param rootUrl root url to load from
  76322. * @param onProgress event that fires when loading progress has occured
  76323. * @param fileName Defines the name of the file to load
  76324. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76325. */
  76326. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76327. meshes: AbstractMesh[];
  76328. particleSystems: IParticleSystem[];
  76329. skeletons: Skeleton[];
  76330. animationGroups: AnimationGroup[];
  76331. }>;
  76332. /**
  76333. * Imports all objects from the loaded OBJ data and adds them to the scene
  76334. * @param scene the scene the objects should be added to
  76335. * @param data the OBJ data to load
  76336. * @param rootUrl root url to load from
  76337. * @param onProgress event that fires when loading progress has occured
  76338. * @param fileName Defines the name of the file to load
  76339. * @returns a promise which completes when objects have been loaded to the scene
  76340. */
  76341. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76342. /**
  76343. * Load into an asset container.
  76344. * @param scene The scene to load into
  76345. * @param data The data to import
  76346. * @param rootUrl The root url for scene and resources
  76347. * @param onProgress The callback when the load progresses
  76348. * @param fileName Defines the name of the file to load
  76349. * @returns The loaded asset container
  76350. */
  76351. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76352. /**
  76353. * Read the OBJ file and create an Array of meshes.
  76354. * Each mesh contains all information given by the OBJ and the MTL file.
  76355. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76356. *
  76357. * @param meshesNames
  76358. * @param scene Scene The scene where are displayed the data
  76359. * @param data String The content of the obj file
  76360. * @param rootUrl String The path to the folder
  76361. * @returns Array<AbstractMesh>
  76362. * @private
  76363. */
  76364. private _parseSolid;
  76365. }
  76366. }
  76367. declare module BABYLON {
  76368. /**
  76369. * STL file type loader.
  76370. * This is a babylon scene loader plugin.
  76371. */
  76372. export class STLFileLoader implements ISceneLoaderPlugin {
  76373. /** @hidden */
  76374. solidPattern: RegExp;
  76375. /** @hidden */
  76376. facetsPattern: RegExp;
  76377. /** @hidden */
  76378. normalPattern: RegExp;
  76379. /** @hidden */
  76380. vertexPattern: RegExp;
  76381. /**
  76382. * Defines the name of the plugin.
  76383. */
  76384. name: string;
  76385. /**
  76386. * Defines the extensions the stl loader is able to load.
  76387. * force data to come in as an ArrayBuffer
  76388. * we'll convert to string if it looks like it's an ASCII .stl
  76389. */
  76390. extensions: ISceneLoaderPluginExtensions;
  76391. /**
  76392. * Import meshes into a scene.
  76393. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76394. * @param scene The scene to import into
  76395. * @param data The data to import
  76396. * @param rootUrl The root url for scene and resources
  76397. * @param meshes The meshes array to import into
  76398. * @param particleSystems The particle systems array to import into
  76399. * @param skeletons The skeletons array to import into
  76400. * @param onError The callback when import fails
  76401. * @returns True if successful or false otherwise
  76402. */
  76403. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76404. /**
  76405. * Load into a scene.
  76406. * @param scene The scene to load into
  76407. * @param data The data to import
  76408. * @param rootUrl The root url for scene and resources
  76409. * @param onError The callback when import fails
  76410. * @returns true if successful or false otherwise
  76411. */
  76412. load(scene: Scene, data: any, rootUrl: string): boolean;
  76413. /**
  76414. * Load into an asset container.
  76415. * @param scene The scene to load into
  76416. * @param data The data to import
  76417. * @param rootUrl The root url for scene and resources
  76418. * @param onError The callback when import fails
  76419. * @returns The loaded asset container
  76420. */
  76421. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76422. private _isBinary;
  76423. private _parseBinary;
  76424. private _parseASCII;
  76425. }
  76426. }
  76427. declare module BABYLON {
  76428. /**
  76429. * Class for generating OBJ data from a Babylon scene.
  76430. */
  76431. export class OBJExport {
  76432. /**
  76433. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76434. * @param mesh defines the list of meshes to serialize
  76435. * @param materials defines if materials should be exported
  76436. * @param matlibname defines the name of the associated mtl file
  76437. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76438. * @returns the OBJ content
  76439. */
  76440. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76441. /**
  76442. * Exports the material(s) of a mesh in .MTL file format (text)
  76443. * @param mesh defines the mesh to extract the material from
  76444. * @returns the mtl content
  76445. */
  76446. static MTL(mesh: Mesh): string;
  76447. }
  76448. }
  76449. declare module BABYLON {
  76450. /** @hidden */
  76451. export var __IGLTFExporterExtension: number;
  76452. /**
  76453. * Interface for extending the exporter
  76454. * @hidden
  76455. */
  76456. export interface IGLTFExporterExtension {
  76457. /**
  76458. * The name of this extension
  76459. */
  76460. readonly name: string;
  76461. /**
  76462. * Defines whether this extension is enabled
  76463. */
  76464. enabled: boolean;
  76465. /**
  76466. * Defines whether this extension is required
  76467. */
  76468. required: boolean;
  76469. }
  76470. }
  76471. declare module BABYLON.GLTF2.Exporter {
  76472. /** @hidden */
  76473. export var __IGLTFExporterExtensionV2: number;
  76474. /**
  76475. * Interface for a glTF exporter extension
  76476. * @hidden
  76477. */
  76478. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76479. /**
  76480. * Define this method to modify the default behavior before exporting a texture
  76481. * @param context The context when loading the asset
  76482. * @param babylonTexture The Babylon.js texture
  76483. * @param mimeType The mime-type of the generated image
  76484. * @returns A promise that resolves with the exported texture
  76485. */
  76486. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76487. /**
  76488. * Define this method to get notified when a texture info is created
  76489. * @param context The context when loading the asset
  76490. * @param textureInfo The glTF texture info
  76491. * @param babylonTexture The Babylon.js texture
  76492. */
  76493. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76494. /**
  76495. * Define this method to modify the default behavior when exporting texture info
  76496. * @param context The context when loading the asset
  76497. * @param meshPrimitive glTF mesh primitive
  76498. * @param babylonSubMesh Babylon submesh
  76499. * @param binaryWriter glTF serializer binary writer instance
  76500. * @returns nullable IMeshPrimitive promise
  76501. */
  76502. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76503. /**
  76504. * Define this method to modify the default behavior when exporting a node
  76505. * @param context The context when exporting the node
  76506. * @param node glTF node
  76507. * @param babylonNode BabylonJS node
  76508. * @returns nullable INode promise
  76509. */
  76510. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76511. [key: number]: number;
  76512. }): Promise<Nullable<INode>>;
  76513. /**
  76514. * Define this method to modify the default behavior when exporting a material
  76515. * @param material glTF material
  76516. * @param babylonMaterial BabylonJS material
  76517. * @returns nullable IMaterial promise
  76518. */
  76519. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76520. /**
  76521. * Define this method to return additional textures to export from a material
  76522. * @param material glTF material
  76523. * @param babylonMaterial BabylonJS material
  76524. * @returns List of textures
  76525. */
  76526. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76527. /** Gets a boolean indicating that this extension was used */
  76528. wasUsed: boolean;
  76529. /** Gets a boolean indicating that this extension is required for the file to work */
  76530. required: boolean;
  76531. /**
  76532. * Called after the exporter state changes to EXPORTING
  76533. */
  76534. onExporting?(): void;
  76535. }
  76536. }
  76537. declare module BABYLON.GLTF2.Exporter {
  76538. /**
  76539. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76540. * @hidden
  76541. */
  76542. export class _GLTFMaterialExporter {
  76543. /**
  76544. * Represents the dielectric specular values for R, G and B
  76545. */
  76546. private static readonly _DielectricSpecular;
  76547. /**
  76548. * Allows the maximum specular power to be defined for material calculations
  76549. */
  76550. private static readonly _MaxSpecularPower;
  76551. /**
  76552. * Mapping to store textures
  76553. */
  76554. private _textureMap;
  76555. /**
  76556. * Numeric tolerance value
  76557. */
  76558. private static readonly _Epsilon;
  76559. /**
  76560. * Reference to the glTF Exporter
  76561. */
  76562. private _exporter;
  76563. constructor(exporter: _Exporter);
  76564. /**
  76565. * Specifies if two colors are approximately equal in value
  76566. * @param color1 first color to compare to
  76567. * @param color2 second color to compare to
  76568. * @param epsilon threshold value
  76569. */
  76570. private static FuzzyEquals;
  76571. /**
  76572. * Gets the materials from a Babylon scene and converts them to glTF materials
  76573. * @param scene babylonjs scene
  76574. * @param mimeType texture mime type
  76575. * @param images array of images
  76576. * @param textures array of textures
  76577. * @param materials array of materials
  76578. * @param imageData mapping of texture names to base64 textures
  76579. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76580. */
  76581. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76582. /**
  76583. * Makes a copy of the glTF material without the texture parameters
  76584. * @param originalMaterial original glTF material
  76585. * @returns glTF material without texture parameters
  76586. */
  76587. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76588. /**
  76589. * Specifies if the material has any texture parameters present
  76590. * @param material glTF Material
  76591. * @returns boolean specifying if texture parameters are present
  76592. */
  76593. _hasTexturesPresent(material: IMaterial): boolean;
  76594. /**
  76595. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76596. * @param babylonStandardMaterial
  76597. * @returns glTF Metallic Roughness Material representation
  76598. */
  76599. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76600. /**
  76601. * Computes the metallic factor
  76602. * @param diffuse diffused value
  76603. * @param specular specular value
  76604. * @param oneMinusSpecularStrength one minus the specular strength
  76605. * @returns metallic value
  76606. */
  76607. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76608. /**
  76609. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76610. * @param glTFMaterial glTF material
  76611. * @param babylonMaterial Babylon material
  76612. */
  76613. private static _SetAlphaMode;
  76614. /**
  76615. * Converts a Babylon Standard Material to a glTF Material
  76616. * @param babylonStandardMaterial BJS Standard 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 materials array of glTF material interfaces
  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. */
  76624. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76625. private _finishMaterial;
  76626. /**
  76627. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76628. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76629. * @param mimeType mime type to use for the textures
  76630. * @param images array of glTF image interfaces
  76631. * @param textures array of glTF texture interfaces
  76632. * @param materials array of glTF material interfaces
  76633. * @param imageData map of image file name to data
  76634. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76635. */
  76636. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76637. /**
  76638. * Converts an image typed array buffer to a base64 image
  76639. * @param buffer typed array buffer
  76640. * @param width width of the image
  76641. * @param height height of the image
  76642. * @param mimeType mimetype of the image
  76643. * @returns base64 image string
  76644. */
  76645. private _createBase64FromCanvasAsync;
  76646. /**
  76647. * Generates a white texture based on the specified width and height
  76648. * @param width width of the texture in pixels
  76649. * @param height height of the texture in pixels
  76650. * @param scene babylonjs scene
  76651. * @returns white texture
  76652. */
  76653. private _createWhiteTexture;
  76654. /**
  76655. * 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
  76656. * @param texture1 first texture to resize
  76657. * @param texture2 second texture to resize
  76658. * @param scene babylonjs scene
  76659. * @returns resized textures or null
  76660. */
  76661. private _resizeTexturesToSameDimensions;
  76662. /**
  76663. * Converts an array of pixels to a Float32Array
  76664. * Throws an error if the pixel format is not supported
  76665. * @param pixels - array buffer containing pixel values
  76666. * @returns Float32 of pixels
  76667. */
  76668. private _convertPixelArrayToFloat32;
  76669. /**
  76670. * Convert Specular Glossiness Textures to Metallic Roughness
  76671. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76672. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76673. * @param diffuseTexture texture used to store diffuse information
  76674. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76675. * @param factors specular glossiness material factors
  76676. * @param mimeType the mime type to use for the texture
  76677. * @returns pbr metallic roughness interface or null
  76678. */
  76679. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76680. /**
  76681. * Converts specular glossiness material properties to metallic roughness
  76682. * @param specularGlossiness interface with specular glossiness material properties
  76683. * @returns interface with metallic roughness material properties
  76684. */
  76685. private _convertSpecularGlossinessToMetallicRoughness;
  76686. /**
  76687. * Calculates the surface reflectance, independent of lighting conditions
  76688. * @param color Color source to calculate brightness from
  76689. * @returns number representing the perceived brightness, or zero if color is undefined
  76690. */
  76691. private _getPerceivedBrightness;
  76692. /**
  76693. * Returns the maximum color component value
  76694. * @param color
  76695. * @returns maximum color component value, or zero if color is null or undefined
  76696. */
  76697. private _getMaxComponent;
  76698. /**
  76699. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76700. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76701. * @param mimeType mime type to use for the textures
  76702. * @param images array of glTF image interfaces
  76703. * @param textures array of glTF texture interfaces
  76704. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76705. * @param imageData map of image file name to data
  76706. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76707. * @returns glTF PBR Metallic Roughness factors
  76708. */
  76709. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76710. private _getGLTFTextureSampler;
  76711. private _getGLTFTextureWrapMode;
  76712. private _getGLTFTextureWrapModesSampler;
  76713. /**
  76714. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76715. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76716. * @param mimeType mime type to use for the textures
  76717. * @param images array of glTF image interfaces
  76718. * @param textures array of glTF texture interfaces
  76719. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76720. * @param imageData map of image file name to data
  76721. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76722. * @returns glTF PBR Metallic Roughness factors
  76723. */
  76724. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76725. /**
  76726. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76727. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76728. * @param mimeType mime type to use for the textures
  76729. * @param images array of glTF image interfaces
  76730. * @param textures array of glTF texture interfaces
  76731. * @param materials array of glTF material interfaces
  76732. * @param imageData map of image file name to data
  76733. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76734. */
  76735. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76736. private setMetallicRoughnessPbrMaterial;
  76737. private getPixelsFromTexture;
  76738. /**
  76739. * Extracts a texture from a Babylon texture into file data and glTF data
  76740. * @param babylonTexture Babylon texture to extract
  76741. * @param mimeType Mime Type of the babylonTexture
  76742. * @return glTF texture info, or null if the texture format is not supported
  76743. */
  76744. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76745. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76746. /**
  76747. * Builds a texture from base64 string
  76748. * @param base64Texture base64 texture string
  76749. * @param baseTextureName Name to use for the texture
  76750. * @param mimeType image mime type for the texture
  76751. * @param images array of images
  76752. * @param textures array of textures
  76753. * @param imageData map of image data
  76754. * @returns glTF texture info, or null if the texture format is not supported
  76755. */
  76756. private _getTextureInfoFromBase64;
  76757. }
  76758. }
  76759. declare module BABYLON {
  76760. /**
  76761. * Class for holding and downloading glTF file data
  76762. */
  76763. export class GLTFData {
  76764. /**
  76765. * Object which contains the file name as the key and its data as the value
  76766. */
  76767. glTFFiles: {
  76768. [fileName: string]: string | Blob;
  76769. };
  76770. /**
  76771. * Initializes the glTF file object
  76772. */
  76773. constructor();
  76774. /**
  76775. * Downloads the glTF data as files based on their names and data
  76776. */
  76777. downloadFiles(): void;
  76778. }
  76779. }
  76780. declare module BABYLON {
  76781. /**
  76782. * Holds a collection of exporter options and parameters
  76783. */
  76784. export interface IExportOptions {
  76785. /**
  76786. * Function which indicates whether a babylon node should be exported or not
  76787. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76788. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76789. */
  76790. shouldExportNode?(node: Node): boolean;
  76791. /**
  76792. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76793. * @param metadata source metadata to read from
  76794. * @returns the data to store to glTF node extras
  76795. */
  76796. metadataSelector?(metadata: any): any;
  76797. /**
  76798. * The sample rate to bake animation curves
  76799. */
  76800. animationSampleRate?: number;
  76801. /**
  76802. * Begin serialization without waiting for the scene to be ready
  76803. */
  76804. exportWithoutWaitingForScene?: boolean;
  76805. /**
  76806. * Indicates if coordinate system swapping root nodes should be included in export
  76807. */
  76808. includeCoordinateSystemConversionNodes?: boolean;
  76809. }
  76810. /**
  76811. * Class for generating glTF data from a Babylon scene.
  76812. */
  76813. export class GLTF2Export {
  76814. /**
  76815. * Exports the geometry of the scene to .gltf file format asynchronously
  76816. * @param scene Babylon scene with scene hierarchy information
  76817. * @param filePrefix File prefix to use when generating the glTF file
  76818. * @param options Exporter options
  76819. * @returns Returns an object with a .gltf file and associates texture names
  76820. * as keys and their data and paths as values
  76821. */
  76822. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76823. private static _PreExportAsync;
  76824. private static _PostExportAsync;
  76825. /**
  76826. * Exports the geometry of the scene to .glb file format asychronously
  76827. * @param scene Babylon scene with scene hierarchy information
  76828. * @param filePrefix File prefix to use when generating glb file
  76829. * @param options Exporter options
  76830. * @returns Returns an object with a .glb filename as key and data as value
  76831. */
  76832. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76833. }
  76834. }
  76835. declare module BABYLON.GLTF2.Exporter {
  76836. /**
  76837. * @hidden
  76838. */
  76839. export class _GLTFUtilities {
  76840. /**
  76841. * Creates a buffer view based on the supplied arguments
  76842. * @param bufferIndex index value of the specified buffer
  76843. * @param byteOffset byte offset value
  76844. * @param byteLength byte length of the bufferView
  76845. * @param byteStride byte distance between conequential elements
  76846. * @param name name of the buffer view
  76847. * @returns bufferView for glTF
  76848. */
  76849. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76850. /**
  76851. * Creates an accessor based on the supplied arguments
  76852. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76853. * @param name The name of the accessor
  76854. * @param type The type of the accessor
  76855. * @param componentType The datatype of components in the attribute
  76856. * @param count The number of attributes referenced by this accessor
  76857. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76858. * @param min Minimum value of each component in this attribute
  76859. * @param max Maximum value of each component in this attribute
  76860. * @returns accessor for glTF
  76861. */
  76862. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76863. /**
  76864. * Calculates the minimum and maximum values of an array of position floats
  76865. * @param positions Positions array of a mesh
  76866. * @param vertexStart Starting vertex offset to calculate min and max values
  76867. * @param vertexCount Number of vertices to check for min and max values
  76868. * @returns min number array and max number array
  76869. */
  76870. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76871. min: number[];
  76872. max: number[];
  76873. };
  76874. /**
  76875. * Converts a new right-handed Vector3
  76876. * @param vector vector3 array
  76877. * @returns right-handed Vector3
  76878. */
  76879. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76880. /**
  76881. * Converts a Vector3 to right-handed
  76882. * @param vector Vector3 to convert to right-handed
  76883. */
  76884. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76885. /**
  76886. * Converts a three element number array to right-handed
  76887. * @param vector number array to convert to right-handed
  76888. */
  76889. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76890. /**
  76891. * Converts a new right-handed Vector3
  76892. * @param vector vector3 array
  76893. * @returns right-handed Vector3
  76894. */
  76895. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76896. /**
  76897. * Converts a Vector3 to right-handed
  76898. * @param vector Vector3 to convert to right-handed
  76899. */
  76900. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76901. /**
  76902. * Converts a three element number array to right-handed
  76903. * @param vector number array to convert to right-handed
  76904. */
  76905. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76906. /**
  76907. * Converts a Vector4 to right-handed
  76908. * @param vector Vector4 to convert to right-handed
  76909. */
  76910. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76911. /**
  76912. * Converts a Vector4 to right-handed
  76913. * @param vector Vector4 to convert to right-handed
  76914. */
  76915. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76916. /**
  76917. * Converts a Quaternion to right-handed
  76918. * @param quaternion Source quaternion to convert to right-handed
  76919. */
  76920. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76921. /**
  76922. * Converts a Quaternion to right-handed
  76923. * @param quaternion Source quaternion to convert to right-handed
  76924. */
  76925. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76926. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76927. }
  76928. }
  76929. declare module BABYLON.GLTF2.Exporter {
  76930. /**
  76931. * Converts Babylon Scene into glTF 2.0.
  76932. * @hidden
  76933. */
  76934. export class _Exporter {
  76935. /**
  76936. * Stores the glTF to export
  76937. */
  76938. _glTF: IGLTF;
  76939. /**
  76940. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76941. */
  76942. _bufferViews: IBufferView[];
  76943. /**
  76944. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76945. */
  76946. _accessors: IAccessor[];
  76947. /**
  76948. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76949. */
  76950. _nodes: INode[];
  76951. /**
  76952. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76953. */
  76954. private _scenes;
  76955. /**
  76956. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76957. */
  76958. private _meshes;
  76959. /**
  76960. * Stores all the generated material information, which represents the appearance of each primitive
  76961. */
  76962. _materials: IMaterial[];
  76963. _materialMap: {
  76964. [materialID: number]: number;
  76965. };
  76966. /**
  76967. * Stores all the generated texture information, which is referenced by glTF materials
  76968. */
  76969. _textures: ITexture[];
  76970. /**
  76971. * Stores all the generated image information, which is referenced by glTF textures
  76972. */
  76973. _images: IImage[];
  76974. /**
  76975. * Stores all the texture samplers
  76976. */
  76977. _samplers: ISampler[];
  76978. /**
  76979. * Stores all the generated animation samplers, which is referenced by glTF animations
  76980. */
  76981. /**
  76982. * Stores the animations for glTF models
  76983. */
  76984. private _animations;
  76985. /**
  76986. * Stores the total amount of bytes stored in the glTF buffer
  76987. */
  76988. private _totalByteLength;
  76989. /**
  76990. * Stores a reference to the Babylon scene containing the source geometry and material information
  76991. */
  76992. _babylonScene: Scene;
  76993. /**
  76994. * Stores a map of the image data, where the key is the file name and the value
  76995. * is the image data
  76996. */
  76997. _imageData: {
  76998. [fileName: string]: {
  76999. data: Uint8Array;
  77000. mimeType: ImageMimeType;
  77001. };
  77002. };
  77003. /**
  77004. * Stores a map of the unique id of a node to its index in the node array
  77005. */
  77006. _nodeMap: {
  77007. [key: number]: number;
  77008. };
  77009. /**
  77010. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77011. */
  77012. _convertToRightHandedSystem: boolean;
  77013. /**
  77014. * Specifies if a Babylon node should be converted to right-handed on export
  77015. */
  77016. _convertToRightHandedSystemMap: {
  77017. [nodeId: number]: boolean;
  77018. };
  77019. _includeCoordinateSystemConversionNodes: boolean;
  77020. /**
  77021. * Baked animation sample rate
  77022. */
  77023. private _animationSampleRate;
  77024. private _options;
  77025. private _localEngine;
  77026. _glTFMaterialExporter: _GLTFMaterialExporter;
  77027. private _extensions;
  77028. private static _ExtensionNames;
  77029. private static _ExtensionFactories;
  77030. private _applyExtension;
  77031. private _applyExtensions;
  77032. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77033. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77034. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77035. [key: number]: number;
  77036. }): Promise<Nullable<INode>>;
  77037. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77038. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77039. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77040. private _forEachExtensions;
  77041. private _extensionsOnExporting;
  77042. /**
  77043. * Load glTF serializer extensions
  77044. */
  77045. private _loadExtensions;
  77046. /**
  77047. * Creates a glTF Exporter instance, which can accept optional exporter options
  77048. * @param babylonScene Babylon scene object
  77049. * @param options Options to modify the behavior of the exporter
  77050. */
  77051. constructor(babylonScene: Scene, options?: IExportOptions);
  77052. dispose(): void;
  77053. /**
  77054. * Registers a glTF exporter extension
  77055. * @param name Name of the extension to export
  77056. * @param factory The factory function that creates the exporter extension
  77057. */
  77058. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77059. /**
  77060. * Un-registers an exporter extension
  77061. * @param name The name fo the exporter extension
  77062. * @returns A boolean indicating whether the extension has been un-registered
  77063. */
  77064. static UnregisterExtension(name: string): boolean;
  77065. /**
  77066. * Lazy load a local engine
  77067. */
  77068. _getLocalEngine(): Engine;
  77069. private reorderIndicesBasedOnPrimitiveMode;
  77070. /**
  77071. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77072. * clock-wise during export to glTF
  77073. * @param submesh BabylonJS submesh
  77074. * @param primitiveMode Primitive mode of the mesh
  77075. * @param sideOrientation the winding order of the submesh
  77076. * @param vertexBufferKind The type of vertex attribute
  77077. * @param meshAttributeArray The vertex attribute data
  77078. * @param byteOffset The offset to the binary data
  77079. * @param binaryWriter The binary data for the glTF file
  77080. * @param convertToRightHandedSystem Converts the values to right-handed
  77081. */
  77082. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77083. /**
  77084. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77085. * clock-wise during export to glTF
  77086. * @param submesh BabylonJS submesh
  77087. * @param primitiveMode Primitive mode of the mesh
  77088. * @param sideOrientation the winding order of the submesh
  77089. * @param vertexBufferKind The type of vertex attribute
  77090. * @param meshAttributeArray The vertex attribute data
  77091. * @param byteOffset The offset to the binary data
  77092. * @param binaryWriter The binary data for the glTF file
  77093. * @param convertToRightHandedSystem Converts the values to right-handed
  77094. */
  77095. private reorderTriangleFillMode;
  77096. /**
  77097. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77098. * clock-wise during export to glTF
  77099. * @param submesh BabylonJS submesh
  77100. * @param primitiveMode Primitive mode of the mesh
  77101. * @param sideOrientation the winding order of the submesh
  77102. * @param vertexBufferKind The type of vertex attribute
  77103. * @param meshAttributeArray The vertex attribute data
  77104. * @param byteOffset The offset to the binary data
  77105. * @param binaryWriter The binary data for the glTF file
  77106. * @param convertToRightHandedSystem Converts the values to right-handed
  77107. */
  77108. private reorderTriangleStripDrawMode;
  77109. /**
  77110. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77111. * clock-wise during export to glTF
  77112. * @param submesh BabylonJS submesh
  77113. * @param primitiveMode Primitive mode of the mesh
  77114. * @param sideOrientation the winding order of the submesh
  77115. * @param vertexBufferKind The type of vertex attribute
  77116. * @param meshAttributeArray The vertex attribute data
  77117. * @param byteOffset The offset to the binary data
  77118. * @param binaryWriter The binary data for the glTF file
  77119. * @param convertToRightHandedSystem Converts the values to right-handed
  77120. */
  77121. private reorderTriangleFanMode;
  77122. /**
  77123. * Writes the vertex attribute data to binary
  77124. * @param vertices The vertices to write to the binary writer
  77125. * @param byteOffset The offset into the binary writer to overwrite binary data
  77126. * @param vertexAttributeKind The vertex attribute type
  77127. * @param meshAttributeArray The vertex attribute data
  77128. * @param binaryWriter The writer containing the binary data
  77129. * @param convertToRightHandedSystem Converts the values to right-handed
  77130. */
  77131. private writeVertexAttributeData;
  77132. /**
  77133. * Writes mesh attribute data to a data buffer
  77134. * Returns the bytelength of the data
  77135. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77136. * @param meshAttributeArray Array containing the attribute data
  77137. * @param binaryWriter The buffer to write the binary data to
  77138. * @param indices Used to specify the order of the vertex data
  77139. * @param convertToRightHandedSystem Converts the values to right-handed
  77140. */
  77141. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77142. /**
  77143. * Generates glTF json data
  77144. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77145. * @param glTFPrefix Text to use when prefixing a glTF file
  77146. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77147. * @returns json data as string
  77148. */
  77149. private generateJSON;
  77150. /**
  77151. * Generates data for .gltf and .bin files based on the glTF prefix string
  77152. * @param glTFPrefix Text to use when prefixing a glTF file
  77153. * @param dispose Dispose the exporter
  77154. * @returns GLTFData with glTF file data
  77155. */
  77156. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77157. /**
  77158. * Creates a binary buffer for glTF
  77159. * @returns array buffer for binary data
  77160. */
  77161. private _generateBinaryAsync;
  77162. /**
  77163. * Pads the number to a multiple of 4
  77164. * @param num number to pad
  77165. * @returns padded number
  77166. */
  77167. private _getPadding;
  77168. /**
  77169. * @hidden
  77170. */
  77171. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77172. /**
  77173. * Sets the TRS for each node
  77174. * @param node glTF Node for storing the transformation data
  77175. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77176. * @param convertToRightHandedSystem Converts the values to right-handed
  77177. */
  77178. private setNodeTransformation;
  77179. private getVertexBufferFromMesh;
  77180. /**
  77181. * Creates a bufferview based on the vertices type for the Babylon mesh
  77182. * @param kind Indicates the type of vertices data
  77183. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77184. * @param binaryWriter The buffer to write the bufferview data to
  77185. * @param convertToRightHandedSystem Converts the values to right-handed
  77186. */
  77187. private createBufferViewKind;
  77188. /**
  77189. * The primitive mode of the Babylon mesh
  77190. * @param babylonMesh The BabylonJS mesh
  77191. */
  77192. private getMeshPrimitiveMode;
  77193. /**
  77194. * Sets the primitive mode of the glTF mesh primitive
  77195. * @param meshPrimitive glTF mesh primitive
  77196. * @param primitiveMode The primitive mode
  77197. */
  77198. private setPrimitiveMode;
  77199. /**
  77200. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77201. * @param meshPrimitive glTF mesh primitive
  77202. * @param attributeKind vertex attribute
  77203. * @returns boolean specifying if uv coordinates are present
  77204. */
  77205. private setAttributeKind;
  77206. /**
  77207. * Sets data for the primitive attributes of each submesh
  77208. * @param mesh glTF Mesh object to store the primitive attribute information
  77209. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77210. * @param binaryWriter Buffer to write the attribute data to
  77211. * @param convertToRightHandedSystem Converts the values to right-handed
  77212. */
  77213. private setPrimitiveAttributesAsync;
  77214. /**
  77215. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77216. * @param node The node to check
  77217. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77218. */
  77219. private isBabylonCoordinateSystemConvertingNode;
  77220. /**
  77221. * Creates a glTF scene based on the array of meshes
  77222. * Returns the the total byte offset
  77223. * @param babylonScene Babylon scene to get the mesh data from
  77224. * @param binaryWriter Buffer to write binary data to
  77225. */
  77226. private createSceneAsync;
  77227. /**
  77228. * Creates a mapping of Node unique id to node index and handles animations
  77229. * @param babylonScene Babylon Scene
  77230. * @param nodes Babylon transform nodes
  77231. * @param binaryWriter Buffer to write binary data to
  77232. * @returns Node mapping of unique id to index
  77233. */
  77234. private createNodeMapAndAnimationsAsync;
  77235. /**
  77236. * Creates a glTF node from a Babylon mesh
  77237. * @param babylonMesh Source Babylon mesh
  77238. * @param binaryWriter Buffer for storing geometry data
  77239. * @param convertToRightHandedSystem Converts the values to right-handed
  77240. * @param nodeMap Node mapping of unique id to glTF node index
  77241. * @returns glTF node
  77242. */
  77243. private createNodeAsync;
  77244. }
  77245. /**
  77246. * @hidden
  77247. *
  77248. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77249. */
  77250. export class _BinaryWriter {
  77251. /**
  77252. * Array buffer which stores all binary data
  77253. */
  77254. private _arrayBuffer;
  77255. /**
  77256. * View of the array buffer
  77257. */
  77258. private _dataView;
  77259. /**
  77260. * byte offset of data in array buffer
  77261. */
  77262. private _byteOffset;
  77263. /**
  77264. * Initialize binary writer with an initial byte length
  77265. * @param byteLength Initial byte length of the array buffer
  77266. */
  77267. constructor(byteLength: number);
  77268. /**
  77269. * Resize the array buffer to the specified byte length
  77270. * @param byteLength
  77271. */
  77272. private resizeBuffer;
  77273. /**
  77274. * Get an array buffer with the length of the byte offset
  77275. * @returns ArrayBuffer resized to the byte offset
  77276. */
  77277. getArrayBuffer(): ArrayBuffer;
  77278. /**
  77279. * Get the byte offset of the array buffer
  77280. * @returns byte offset
  77281. */
  77282. getByteOffset(): number;
  77283. /**
  77284. * Stores an UInt8 in the array buffer
  77285. * @param entry
  77286. * @param byteOffset If defined, specifies where to set the value as an offset.
  77287. */
  77288. setUInt8(entry: number, byteOffset?: number): void;
  77289. /**
  77290. * Gets an UInt32 in the array buffer
  77291. * @param entry
  77292. * @param byteOffset If defined, specifies where to set the value as an offset.
  77293. */
  77294. getUInt32(byteOffset: number): number;
  77295. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77296. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77297. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77298. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77299. /**
  77300. * Stores a Float32 in the array buffer
  77301. * @param entry
  77302. */
  77303. setFloat32(entry: number, byteOffset?: number): void;
  77304. /**
  77305. * Stores an UInt32 in the array buffer
  77306. * @param entry
  77307. * @param byteOffset If defined, specifies where to set the value as an offset.
  77308. */
  77309. setUInt32(entry: number, byteOffset?: number): void;
  77310. }
  77311. }
  77312. declare module BABYLON.GLTF2.Exporter {
  77313. /**
  77314. * @hidden
  77315. * Interface to store animation data.
  77316. */
  77317. export interface _IAnimationData {
  77318. /**
  77319. * Keyframe data.
  77320. */
  77321. inputs: number[];
  77322. /**
  77323. * Value data.
  77324. */
  77325. outputs: number[][];
  77326. /**
  77327. * Animation interpolation data.
  77328. */
  77329. samplerInterpolation: AnimationSamplerInterpolation;
  77330. /**
  77331. * Minimum keyframe value.
  77332. */
  77333. inputsMin: number;
  77334. /**
  77335. * Maximum keyframe value.
  77336. */
  77337. inputsMax: number;
  77338. }
  77339. /**
  77340. * @hidden
  77341. */
  77342. export interface _IAnimationInfo {
  77343. /**
  77344. * The target channel for the animation
  77345. */
  77346. animationChannelTargetPath: AnimationChannelTargetPath;
  77347. /**
  77348. * The glTF accessor type for the data.
  77349. */
  77350. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77351. /**
  77352. * Specifies if quaternions should be used.
  77353. */
  77354. useQuaternion: boolean;
  77355. }
  77356. /**
  77357. * @hidden
  77358. * Utility class for generating glTF animation data from BabylonJS.
  77359. */
  77360. export class _GLTFAnimation {
  77361. /**
  77362. * @ignore
  77363. *
  77364. * Creates glTF channel animation from BabylonJS animation.
  77365. * @param babylonTransformNode - BabylonJS mesh.
  77366. * @param animation - animation.
  77367. * @param animationChannelTargetPath - The target animation channel.
  77368. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77369. * @param useQuaternion - Specifies if quaternions are used.
  77370. * @returns nullable IAnimationData
  77371. */
  77372. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77373. private static _DeduceAnimationInfo;
  77374. /**
  77375. * @ignore
  77376. * Create node animations from the transform node animations
  77377. * @param babylonNode
  77378. * @param runtimeGLTFAnimation
  77379. * @param idleGLTFAnimations
  77380. * @param nodeMap
  77381. * @param nodes
  77382. * @param binaryWriter
  77383. * @param bufferViews
  77384. * @param accessors
  77385. * @param convertToRightHandedSystem
  77386. * @param animationSampleRate
  77387. */
  77388. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77389. [key: number]: number;
  77390. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77391. /**
  77392. * @ignore
  77393. * Create node animations from the animation groups
  77394. * @param babylonScene
  77395. * @param glTFAnimations
  77396. * @param nodeMap
  77397. * @param nodes
  77398. * @param binaryWriter
  77399. * @param bufferViews
  77400. * @param accessors
  77401. * @param convertToRightHandedSystemMap
  77402. * @param animationSampleRate
  77403. */
  77404. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77405. [key: number]: number;
  77406. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77407. [nodeId: number]: boolean;
  77408. }, animationSampleRate: number): void;
  77409. private static AddAnimation;
  77410. /**
  77411. * Create a baked animation
  77412. * @param babylonTransformNode BabylonJS mesh
  77413. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77414. * @param animationChannelTargetPath animation target channel
  77415. * @param minFrame minimum animation frame
  77416. * @param maxFrame maximum animation frame
  77417. * @param fps frames per second of the animation
  77418. * @param inputs input key frames of the animation
  77419. * @param outputs output key frame data of the animation
  77420. * @param convertToRightHandedSystem converts the values to right-handed
  77421. * @param useQuaternion specifies if quaternions should be used
  77422. */
  77423. private static _CreateBakedAnimation;
  77424. private static _ConvertFactorToVector3OrQuaternion;
  77425. private static _SetInterpolatedValue;
  77426. /**
  77427. * Creates linear animation from the animation key frames
  77428. * @param babylonTransformNode BabylonJS mesh
  77429. * @param animation BabylonJS animation
  77430. * @param animationChannelTargetPath The target animation channel
  77431. * @param frameDelta The difference between the last and first frame of the animation
  77432. * @param inputs Array to store the key frame times
  77433. * @param outputs Array to store the key frame data
  77434. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77435. * @param useQuaternion Specifies if quaternions are used in the animation
  77436. */
  77437. private static _CreateLinearOrStepAnimation;
  77438. /**
  77439. * Creates cubic spline animation from the animation key frames
  77440. * @param babylonTransformNode BabylonJS mesh
  77441. * @param animation BabylonJS animation
  77442. * @param animationChannelTargetPath The target animation channel
  77443. * @param frameDelta The difference between the last and first frame of the animation
  77444. * @param inputs Array to store the key frame times
  77445. * @param outputs Array to store the key frame data
  77446. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77447. * @param useQuaternion Specifies if quaternions are used in the animation
  77448. */
  77449. private static _CreateCubicSplineAnimation;
  77450. private static _GetBasePositionRotationOrScale;
  77451. /**
  77452. * Adds a key frame value
  77453. * @param keyFrame
  77454. * @param animation
  77455. * @param outputs
  77456. * @param animationChannelTargetPath
  77457. * @param basePositionRotationOrScale
  77458. * @param convertToRightHandedSystem
  77459. * @param useQuaternion
  77460. */
  77461. private static _AddKeyframeValue;
  77462. /**
  77463. * Determine the interpolation based on the key frames
  77464. * @param keyFrames
  77465. * @param animationChannelTargetPath
  77466. * @param useQuaternion
  77467. */
  77468. private static _DeduceInterpolation;
  77469. /**
  77470. * Adds an input tangent or output tangent to the output data
  77471. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77472. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77473. * @param outputs The animation data by keyframe
  77474. * @param animationChannelTargetPath The target animation channel
  77475. * @param interpolation The interpolation type
  77476. * @param keyFrame The key frame with the animation data
  77477. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77478. * @param useQuaternion Specifies if quaternions are used
  77479. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77480. */
  77481. private static AddSplineTangent;
  77482. /**
  77483. * Get the minimum and maximum key frames' frame values
  77484. * @param keyFrames animation key frames
  77485. * @returns the minimum and maximum key frame value
  77486. */
  77487. private static calculateMinMaxKeyFrames;
  77488. }
  77489. }
  77490. declare module BABYLON.GLTF2.Exporter {
  77491. /** @hidden */
  77492. export var textureTransformPixelShader: {
  77493. name: string;
  77494. shader: string;
  77495. };
  77496. }
  77497. declare module BABYLON.GLTF2.Exporter.Extensions {
  77498. /**
  77499. * @hidden
  77500. */
  77501. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77502. private _recordedTextures;
  77503. /** Name of this extension */
  77504. readonly name: string;
  77505. /** Defines whether this extension is enabled */
  77506. enabled: boolean;
  77507. /** Defines whether this extension is required */
  77508. required: boolean;
  77509. /** Reference to the glTF exporter */
  77510. private _wasUsed;
  77511. constructor(exporter: _Exporter);
  77512. dispose(): void;
  77513. /** @hidden */
  77514. get wasUsed(): boolean;
  77515. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77516. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77517. /**
  77518. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77519. * @param babylonTexture
  77520. * @param offset
  77521. * @param rotation
  77522. * @param scale
  77523. * @param scene
  77524. */
  77525. private _textureTransformTextureAsync;
  77526. }
  77527. }
  77528. declare module BABYLON.GLTF2.Exporter.Extensions {
  77529. /**
  77530. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77531. */
  77532. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77533. /** The name of this extension. */
  77534. readonly name: string;
  77535. /** Defines whether this extension is enabled. */
  77536. enabled: boolean;
  77537. /** Defines whether this extension is required */
  77538. required: boolean;
  77539. /** Reference to the glTF exporter */
  77540. private _exporter;
  77541. private _lights;
  77542. /** @hidden */
  77543. constructor(exporter: _Exporter);
  77544. /** @hidden */
  77545. dispose(): void;
  77546. /** @hidden */
  77547. get wasUsed(): boolean;
  77548. /** @hidden */
  77549. onExporting(): void;
  77550. /**
  77551. * Define this method to modify the default behavior when exporting a node
  77552. * @param context The context when exporting the node
  77553. * @param node glTF node
  77554. * @param babylonNode BabylonJS node
  77555. * @param nodeMap Node mapping of unique id to glTF node index
  77556. * @returns nullable INode promise
  77557. */
  77558. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77559. [key: number]: number;
  77560. }): Promise<Nullable<INode>>;
  77561. }
  77562. }
  77563. declare module BABYLON.GLTF2.Exporter.Extensions {
  77564. /**
  77565. * @hidden
  77566. */
  77567. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77568. /** Name of this extension */
  77569. readonly name: string;
  77570. /** Defines whether this extension is enabled */
  77571. enabled: boolean;
  77572. /** Defines whether this extension is required */
  77573. required: boolean;
  77574. /** Reference to the glTF exporter */
  77575. private _textureInfos;
  77576. private _exportedTextures;
  77577. private _wasUsed;
  77578. constructor(exporter: _Exporter);
  77579. dispose(): void;
  77580. /** @hidden */
  77581. get wasUsed(): boolean;
  77582. private _getTextureIndex;
  77583. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77584. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77585. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77586. }
  77587. }
  77588. declare module BABYLON {
  77589. /**
  77590. * Class for generating STL data from a Babylon scene.
  77591. */
  77592. export class STLExport {
  77593. /**
  77594. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77595. * @param meshes list defines the mesh to serialize
  77596. * @param download triggers the automatic download of the file.
  77597. * @param fileName changes the downloads fileName.
  77598. * @param binary changes the STL to a binary type.
  77599. * @param isLittleEndian toggle for binary type exporter.
  77600. * @returns the STL as UTF8 string
  77601. */
  77602. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77603. }
  77604. }
  77605. declare module "babylonjs-gltf2interface" {
  77606. export = BABYLON.GLTF2;
  77607. }
  77608. /**
  77609. * Module for glTF 2.0 Interface
  77610. */
  77611. declare module BABYLON.GLTF2 {
  77612. /**
  77613. * The datatype of the components in the attribute
  77614. */
  77615. const enum AccessorComponentType {
  77616. /**
  77617. * Byte
  77618. */
  77619. BYTE = 5120,
  77620. /**
  77621. * Unsigned Byte
  77622. */
  77623. UNSIGNED_BYTE = 5121,
  77624. /**
  77625. * Short
  77626. */
  77627. SHORT = 5122,
  77628. /**
  77629. * Unsigned Short
  77630. */
  77631. UNSIGNED_SHORT = 5123,
  77632. /**
  77633. * Unsigned Int
  77634. */
  77635. UNSIGNED_INT = 5125,
  77636. /**
  77637. * Float
  77638. */
  77639. FLOAT = 5126,
  77640. }
  77641. /**
  77642. * Specifies if the attirbute is a scalar, vector, or matrix
  77643. */
  77644. const enum AccessorType {
  77645. /**
  77646. * Scalar
  77647. */
  77648. SCALAR = "SCALAR",
  77649. /**
  77650. * Vector2
  77651. */
  77652. VEC2 = "VEC2",
  77653. /**
  77654. * Vector3
  77655. */
  77656. VEC3 = "VEC3",
  77657. /**
  77658. * Vector4
  77659. */
  77660. VEC4 = "VEC4",
  77661. /**
  77662. * Matrix2x2
  77663. */
  77664. MAT2 = "MAT2",
  77665. /**
  77666. * Matrix3x3
  77667. */
  77668. MAT3 = "MAT3",
  77669. /**
  77670. * Matrix4x4
  77671. */
  77672. MAT4 = "MAT4",
  77673. }
  77674. /**
  77675. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77676. */
  77677. const enum AnimationChannelTargetPath {
  77678. /**
  77679. * Translation
  77680. */
  77681. TRANSLATION = "translation",
  77682. /**
  77683. * Rotation
  77684. */
  77685. ROTATION = "rotation",
  77686. /**
  77687. * Scale
  77688. */
  77689. SCALE = "scale",
  77690. /**
  77691. * Weights
  77692. */
  77693. WEIGHTS = "weights",
  77694. }
  77695. /**
  77696. * Interpolation algorithm
  77697. */
  77698. const enum AnimationSamplerInterpolation {
  77699. /**
  77700. * The animated values are linearly interpolated between keyframes
  77701. */
  77702. LINEAR = "LINEAR",
  77703. /**
  77704. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77705. */
  77706. STEP = "STEP",
  77707. /**
  77708. * The animation's interpolation is computed using a cubic spline with specified tangents
  77709. */
  77710. CUBICSPLINE = "CUBICSPLINE",
  77711. }
  77712. /**
  77713. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77714. */
  77715. const enum CameraType {
  77716. /**
  77717. * A perspective camera containing properties to create a perspective projection matrix
  77718. */
  77719. PERSPECTIVE = "perspective",
  77720. /**
  77721. * An orthographic camera containing properties to create an orthographic projection matrix
  77722. */
  77723. ORTHOGRAPHIC = "orthographic",
  77724. }
  77725. /**
  77726. * The mime-type of the image
  77727. */
  77728. const enum ImageMimeType {
  77729. /**
  77730. * JPEG Mime-type
  77731. */
  77732. JPEG = "image/jpeg",
  77733. /**
  77734. * PNG Mime-type
  77735. */
  77736. PNG = "image/png",
  77737. }
  77738. /**
  77739. * The alpha rendering mode of the material
  77740. */
  77741. const enum MaterialAlphaMode {
  77742. /**
  77743. * The alpha value is ignored and the rendered output is fully opaque
  77744. */
  77745. OPAQUE = "OPAQUE",
  77746. /**
  77747. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77748. */
  77749. MASK = "MASK",
  77750. /**
  77751. * 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)
  77752. */
  77753. BLEND = "BLEND",
  77754. }
  77755. /**
  77756. * The type of the primitives to render
  77757. */
  77758. const enum MeshPrimitiveMode {
  77759. /**
  77760. * Points
  77761. */
  77762. POINTS = 0,
  77763. /**
  77764. * Lines
  77765. */
  77766. LINES = 1,
  77767. /**
  77768. * Line Loop
  77769. */
  77770. LINE_LOOP = 2,
  77771. /**
  77772. * Line Strip
  77773. */
  77774. LINE_STRIP = 3,
  77775. /**
  77776. * Triangles
  77777. */
  77778. TRIANGLES = 4,
  77779. /**
  77780. * Triangle Strip
  77781. */
  77782. TRIANGLE_STRIP = 5,
  77783. /**
  77784. * Triangle Fan
  77785. */
  77786. TRIANGLE_FAN = 6,
  77787. }
  77788. /**
  77789. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77790. */
  77791. const enum TextureMagFilter {
  77792. /**
  77793. * Nearest
  77794. */
  77795. NEAREST = 9728,
  77796. /**
  77797. * Linear
  77798. */
  77799. LINEAR = 9729,
  77800. }
  77801. /**
  77802. * Minification filter. All valid values correspond to WebGL enums
  77803. */
  77804. const enum TextureMinFilter {
  77805. /**
  77806. * Nearest
  77807. */
  77808. NEAREST = 9728,
  77809. /**
  77810. * Linear
  77811. */
  77812. LINEAR = 9729,
  77813. /**
  77814. * Nearest Mip-Map Nearest
  77815. */
  77816. NEAREST_MIPMAP_NEAREST = 9984,
  77817. /**
  77818. * Linear Mipmap Nearest
  77819. */
  77820. LINEAR_MIPMAP_NEAREST = 9985,
  77821. /**
  77822. * Nearest Mipmap Linear
  77823. */
  77824. NEAREST_MIPMAP_LINEAR = 9986,
  77825. /**
  77826. * Linear Mipmap Linear
  77827. */
  77828. LINEAR_MIPMAP_LINEAR = 9987,
  77829. }
  77830. /**
  77831. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77832. */
  77833. const enum TextureWrapMode {
  77834. /**
  77835. * Clamp to Edge
  77836. */
  77837. CLAMP_TO_EDGE = 33071,
  77838. /**
  77839. * Mirrored Repeat
  77840. */
  77841. MIRRORED_REPEAT = 33648,
  77842. /**
  77843. * Repeat
  77844. */
  77845. REPEAT = 10497,
  77846. }
  77847. /**
  77848. * glTF Property
  77849. */
  77850. interface IProperty {
  77851. /**
  77852. * Dictionary object with extension-specific objects
  77853. */
  77854. extensions?: {
  77855. [key: string]: any;
  77856. };
  77857. /**
  77858. * Application-Specific data
  77859. */
  77860. extras?: any;
  77861. }
  77862. /**
  77863. * glTF Child of Root Property
  77864. */
  77865. interface IChildRootProperty extends IProperty {
  77866. /**
  77867. * The user-defined name of this object
  77868. */
  77869. name?: string;
  77870. }
  77871. /**
  77872. * Indices of those attributes that deviate from their initialization value
  77873. */
  77874. interface IAccessorSparseIndices extends IProperty {
  77875. /**
  77876. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77877. */
  77878. bufferView: number;
  77879. /**
  77880. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77881. */
  77882. byteOffset?: number;
  77883. /**
  77884. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77885. */
  77886. componentType: AccessorComponentType;
  77887. }
  77888. /**
  77889. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77890. */
  77891. interface IAccessorSparseValues extends IProperty {
  77892. /**
  77893. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77894. */
  77895. bufferView: number;
  77896. /**
  77897. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77898. */
  77899. byteOffset?: number;
  77900. }
  77901. /**
  77902. * Sparse storage of attributes that deviate from their initialization value
  77903. */
  77904. interface IAccessorSparse extends IProperty {
  77905. /**
  77906. * The number of attributes encoded in this sparse accessor
  77907. */
  77908. count: number;
  77909. /**
  77910. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77911. */
  77912. indices: IAccessorSparseIndices;
  77913. /**
  77914. * 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
  77915. */
  77916. values: IAccessorSparseValues;
  77917. }
  77918. /**
  77919. * 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
  77920. */
  77921. interface IAccessor extends IChildRootProperty {
  77922. /**
  77923. * The index of the bufferview
  77924. */
  77925. bufferView?: number;
  77926. /**
  77927. * The offset relative to the start of the bufferView in bytes
  77928. */
  77929. byteOffset?: number;
  77930. /**
  77931. * The datatype of components in the attribute
  77932. */
  77933. componentType: AccessorComponentType;
  77934. /**
  77935. * Specifies whether integer data values should be normalized
  77936. */
  77937. normalized?: boolean;
  77938. /**
  77939. * The number of attributes referenced by this accessor
  77940. */
  77941. count: number;
  77942. /**
  77943. * Specifies if the attribute is a scalar, vector, or matrix
  77944. */
  77945. type: AccessorType;
  77946. /**
  77947. * Maximum value of each component in this attribute
  77948. */
  77949. max?: number[];
  77950. /**
  77951. * Minimum value of each component in this attribute
  77952. */
  77953. min?: number[];
  77954. /**
  77955. * Sparse storage of attributes that deviate from their initialization value
  77956. */
  77957. sparse?: IAccessorSparse;
  77958. }
  77959. /**
  77960. * Targets an animation's sampler at a node's property
  77961. */
  77962. interface IAnimationChannel extends IProperty {
  77963. /**
  77964. * The index of a sampler in this animation used to compute the value for the target
  77965. */
  77966. sampler: number;
  77967. /**
  77968. * The index of the node and TRS property to target
  77969. */
  77970. target: IAnimationChannelTarget;
  77971. }
  77972. /**
  77973. * The index of the node and TRS property that an animation channel targets
  77974. */
  77975. interface IAnimationChannelTarget extends IProperty {
  77976. /**
  77977. * The index of the node to target
  77978. */
  77979. node: number;
  77980. /**
  77981. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77982. */
  77983. path: AnimationChannelTargetPath;
  77984. }
  77985. /**
  77986. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77987. */
  77988. interface IAnimationSampler extends IProperty {
  77989. /**
  77990. * The index of an accessor containing keyframe input values, e.g., time
  77991. */
  77992. input: number;
  77993. /**
  77994. * Interpolation algorithm
  77995. */
  77996. interpolation?: AnimationSamplerInterpolation;
  77997. /**
  77998. * The index of an accessor, containing keyframe output values
  77999. */
  78000. output: number;
  78001. }
  78002. /**
  78003. * A keyframe animation
  78004. */
  78005. interface IAnimation extends IChildRootProperty {
  78006. /**
  78007. * An array of channels, each of which targets an animation's sampler at a node's property
  78008. */
  78009. channels: IAnimationChannel[];
  78010. /**
  78011. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78012. */
  78013. samplers: IAnimationSampler[];
  78014. }
  78015. /**
  78016. * Metadata about the glTF asset
  78017. */
  78018. interface IAsset extends IChildRootProperty {
  78019. /**
  78020. * A copyright message suitable for display to credit the content creator
  78021. */
  78022. copyright?: string;
  78023. /**
  78024. * Tool that generated this glTF model. Useful for debugging
  78025. */
  78026. generator?: string;
  78027. /**
  78028. * The glTF version that this asset targets
  78029. */
  78030. version: string;
  78031. /**
  78032. * The minimum glTF version that this asset targets
  78033. */
  78034. minVersion?: string;
  78035. }
  78036. /**
  78037. * A buffer points to binary geometry, animation, or skins
  78038. */
  78039. interface IBuffer extends IChildRootProperty {
  78040. /**
  78041. * 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
  78042. */
  78043. uri?: string;
  78044. /**
  78045. * The length of the buffer in bytes
  78046. */
  78047. byteLength: number;
  78048. }
  78049. /**
  78050. * A view into a buffer generally representing a subset of the buffer
  78051. */
  78052. interface IBufferView extends IChildRootProperty {
  78053. /**
  78054. * The index of the buffer
  78055. */
  78056. buffer: number;
  78057. /**
  78058. * The offset into the buffer in bytes
  78059. */
  78060. byteOffset?: number;
  78061. /**
  78062. * The lenth of the bufferView in bytes
  78063. */
  78064. byteLength: number;
  78065. /**
  78066. * The stride, in bytes
  78067. */
  78068. byteStride?: number;
  78069. }
  78070. /**
  78071. * An orthographic camera containing properties to create an orthographic projection matrix
  78072. */
  78073. interface ICameraOrthographic extends IProperty {
  78074. /**
  78075. * The floating-point horizontal magnification of the view. Must not be zero
  78076. */
  78077. xmag: number;
  78078. /**
  78079. * The floating-point vertical magnification of the view. Must not be zero
  78080. */
  78081. ymag: number;
  78082. /**
  78083. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78084. */
  78085. zfar: number;
  78086. /**
  78087. * The floating-point distance to the near clipping plane
  78088. */
  78089. znear: number;
  78090. }
  78091. /**
  78092. * A perspective camera containing properties to create a perspective projection matrix
  78093. */
  78094. interface ICameraPerspective extends IProperty {
  78095. /**
  78096. * The floating-point aspect ratio of the field of view
  78097. */
  78098. aspectRatio?: number;
  78099. /**
  78100. * The floating-point vertical field of view in radians
  78101. */
  78102. yfov: number;
  78103. /**
  78104. * The floating-point distance to the far clipping plane
  78105. */
  78106. zfar?: number;
  78107. /**
  78108. * The floating-point distance to the near clipping plane
  78109. */
  78110. znear: number;
  78111. }
  78112. /**
  78113. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78114. */
  78115. interface ICamera extends IChildRootProperty {
  78116. /**
  78117. * An orthographic camera containing properties to create an orthographic projection matrix
  78118. */
  78119. orthographic?: ICameraOrthographic;
  78120. /**
  78121. * A perspective camera containing properties to create a perspective projection matrix
  78122. */
  78123. perspective?: ICameraPerspective;
  78124. /**
  78125. * Specifies if the camera uses a perspective or orthographic projection
  78126. */
  78127. type: CameraType;
  78128. }
  78129. /**
  78130. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78131. */
  78132. interface IImage extends IChildRootProperty {
  78133. /**
  78134. * 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
  78135. */
  78136. uri?: string;
  78137. /**
  78138. * The image's MIME type
  78139. */
  78140. mimeType?: ImageMimeType;
  78141. /**
  78142. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78143. */
  78144. bufferView?: number;
  78145. }
  78146. /**
  78147. * Material Normal Texture Info
  78148. */
  78149. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78150. /**
  78151. * The scalar multiplier applied to each normal vector of the normal texture
  78152. */
  78153. scale?: number;
  78154. }
  78155. /**
  78156. * Material Occlusion Texture Info
  78157. */
  78158. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78159. /**
  78160. * A scalar multiplier controlling the amount of occlusion applied
  78161. */
  78162. strength?: number;
  78163. }
  78164. /**
  78165. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78166. */
  78167. interface IMaterialPbrMetallicRoughness {
  78168. /**
  78169. * The material's base color factor
  78170. */
  78171. baseColorFactor?: number[];
  78172. /**
  78173. * The base color texture
  78174. */
  78175. baseColorTexture?: ITextureInfo;
  78176. /**
  78177. * The metalness of the material
  78178. */
  78179. metallicFactor?: number;
  78180. /**
  78181. * The roughness of the material
  78182. */
  78183. roughnessFactor?: number;
  78184. /**
  78185. * The metallic-roughness texture
  78186. */
  78187. metallicRoughnessTexture?: ITextureInfo;
  78188. }
  78189. /**
  78190. * The material appearance of a primitive
  78191. */
  78192. interface IMaterial extends IChildRootProperty {
  78193. /**
  78194. * 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
  78195. */
  78196. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78197. /**
  78198. * The normal map texture
  78199. */
  78200. normalTexture?: IMaterialNormalTextureInfo;
  78201. /**
  78202. * The occlusion map texture
  78203. */
  78204. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78205. /**
  78206. * The emissive map texture
  78207. */
  78208. emissiveTexture?: ITextureInfo;
  78209. /**
  78210. * 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
  78211. */
  78212. emissiveFactor?: number[];
  78213. /**
  78214. * The alpha rendering mode of the material
  78215. */
  78216. alphaMode?: MaterialAlphaMode;
  78217. /**
  78218. * The alpha cutoff value of the material
  78219. */
  78220. alphaCutoff?: number;
  78221. /**
  78222. * Specifies whether the material is double sided
  78223. */
  78224. doubleSided?: boolean;
  78225. }
  78226. /**
  78227. * Geometry to be rendered with the given material
  78228. */
  78229. interface IMeshPrimitive extends IProperty {
  78230. /**
  78231. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78232. */
  78233. attributes: {
  78234. [name: string]: number;
  78235. };
  78236. /**
  78237. * The index of the accessor that contains the indices
  78238. */
  78239. indices?: number;
  78240. /**
  78241. * The index of the material to apply to this primitive when rendering
  78242. */
  78243. material?: number;
  78244. /**
  78245. * The type of primitives to render. All valid values correspond to WebGL enums
  78246. */
  78247. mode?: MeshPrimitiveMode;
  78248. /**
  78249. * 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
  78250. */
  78251. targets?: {
  78252. [name: string]: number;
  78253. }[];
  78254. }
  78255. /**
  78256. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78257. */
  78258. interface IMesh extends IChildRootProperty {
  78259. /**
  78260. * An array of primitives, each defining geometry to be rendered with a material
  78261. */
  78262. primitives: IMeshPrimitive[];
  78263. /**
  78264. * Array of weights to be applied to the Morph Targets
  78265. */
  78266. weights?: number[];
  78267. }
  78268. /**
  78269. * A node in the node hierarchy
  78270. */
  78271. interface INode extends IChildRootProperty {
  78272. /**
  78273. * The index of the camera referenced by this node
  78274. */
  78275. camera?: number;
  78276. /**
  78277. * The indices of this node's children
  78278. */
  78279. children?: number[];
  78280. /**
  78281. * The index of the skin referenced by this node
  78282. */
  78283. skin?: number;
  78284. /**
  78285. * A floating-point 4x4 transformation matrix stored in column-major order
  78286. */
  78287. matrix?: number[];
  78288. /**
  78289. * The index of the mesh in this node
  78290. */
  78291. mesh?: number;
  78292. /**
  78293. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78294. */
  78295. rotation?: number[];
  78296. /**
  78297. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78298. */
  78299. scale?: number[];
  78300. /**
  78301. * The node's translation along the x, y, and z axes
  78302. */
  78303. translation?: number[];
  78304. /**
  78305. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78306. */
  78307. weights?: number[];
  78308. }
  78309. /**
  78310. * Texture sampler properties for filtering and wrapping modes
  78311. */
  78312. interface ISampler extends IChildRootProperty {
  78313. /**
  78314. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78315. */
  78316. magFilter?: TextureMagFilter;
  78317. /**
  78318. * Minification filter. All valid values correspond to WebGL enums
  78319. */
  78320. minFilter?: TextureMinFilter;
  78321. /**
  78322. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78323. */
  78324. wrapS?: TextureWrapMode;
  78325. /**
  78326. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78327. */
  78328. wrapT?: TextureWrapMode;
  78329. }
  78330. /**
  78331. * The root nodes of a scene
  78332. */
  78333. interface IScene extends IChildRootProperty {
  78334. /**
  78335. * The indices of each root node
  78336. */
  78337. nodes: number[];
  78338. }
  78339. /**
  78340. * Joints and matrices defining a skin
  78341. */
  78342. interface ISkin extends IChildRootProperty {
  78343. /**
  78344. * 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
  78345. */
  78346. inverseBindMatrices?: number;
  78347. /**
  78348. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78349. */
  78350. skeleton?: number;
  78351. /**
  78352. * 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)
  78353. */
  78354. joints: number[];
  78355. }
  78356. /**
  78357. * A texture and its sampler
  78358. */
  78359. interface ITexture extends IChildRootProperty {
  78360. /**
  78361. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78362. */
  78363. sampler?: number;
  78364. /**
  78365. * The index of the image used by this texture
  78366. */
  78367. source: number;
  78368. }
  78369. /**
  78370. * Reference to a texture
  78371. */
  78372. interface ITextureInfo extends IProperty {
  78373. /**
  78374. * The index of the texture
  78375. */
  78376. index: number;
  78377. /**
  78378. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78379. */
  78380. texCoord?: number;
  78381. }
  78382. /**
  78383. * The root object for a glTF asset
  78384. */
  78385. interface IGLTF extends IProperty {
  78386. /**
  78387. * An array of accessors. An accessor is a typed view into a bufferView
  78388. */
  78389. accessors?: IAccessor[];
  78390. /**
  78391. * An array of keyframe animations
  78392. */
  78393. animations?: IAnimation[];
  78394. /**
  78395. * Metadata about the glTF asset
  78396. */
  78397. asset: IAsset;
  78398. /**
  78399. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78400. */
  78401. buffers?: IBuffer[];
  78402. /**
  78403. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78404. */
  78405. bufferViews?: IBufferView[];
  78406. /**
  78407. * An array of cameras
  78408. */
  78409. cameras?: ICamera[];
  78410. /**
  78411. * Names of glTF extensions used somewhere in this asset
  78412. */
  78413. extensionsUsed?: string[];
  78414. /**
  78415. * Names of glTF extensions required to properly load this asset
  78416. */
  78417. extensionsRequired?: string[];
  78418. /**
  78419. * An array of images. An image defines data used to create a texture
  78420. */
  78421. images?: IImage[];
  78422. /**
  78423. * An array of materials. A material defines the appearance of a primitive
  78424. */
  78425. materials?: IMaterial[];
  78426. /**
  78427. * An array of meshes. A mesh is a set of primitives to be rendered
  78428. */
  78429. meshes?: IMesh[];
  78430. /**
  78431. * An array of nodes
  78432. */
  78433. nodes?: INode[];
  78434. /**
  78435. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78436. */
  78437. samplers?: ISampler[];
  78438. /**
  78439. * The index of the default scene
  78440. */
  78441. scene?: number;
  78442. /**
  78443. * An array of scenes
  78444. */
  78445. scenes?: IScene[];
  78446. /**
  78447. * An array of skins. A skin is defined by joints and matrices
  78448. */
  78449. skins?: ISkin[];
  78450. /**
  78451. * An array of textures
  78452. */
  78453. textures?: ITexture[];
  78454. }
  78455. /**
  78456. * The glTF validation results
  78457. * @ignore
  78458. */
  78459. interface IGLTFValidationResults {
  78460. info: {
  78461. generator: string;
  78462. hasAnimations: boolean;
  78463. hasDefaultScene: boolean;
  78464. hasMaterials: boolean;
  78465. hasMorphTargets: boolean;
  78466. hasSkins: boolean;
  78467. hasTextures: boolean;
  78468. maxAttributesUsed: number;
  78469. primitivesCount: number
  78470. };
  78471. issues: {
  78472. messages: Array<string>;
  78473. numErrors: number;
  78474. numHints: number;
  78475. numInfos: number;
  78476. numWarnings: number;
  78477. truncated: boolean
  78478. };
  78479. mimeType: string;
  78480. uri: string;
  78481. validatedAt: string;
  78482. validatorVersion: string;
  78483. }
  78484. /**
  78485. * The glTF validation options
  78486. */
  78487. interface IGLTFValidationOptions {
  78488. /** Uri to use */
  78489. uri?: string;
  78490. /** Function used to load external resources */
  78491. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78492. /** Boolean indicating that we need to validate accessor data */
  78493. validateAccessorData?: boolean;
  78494. /** max number of issues allowed */
  78495. maxIssues?: number;
  78496. /** Ignored issues */
  78497. ignoredIssues?: Array<string>;
  78498. /** Value to override severy settings */
  78499. severityOverrides?: Object;
  78500. }
  78501. /**
  78502. * The glTF validator object
  78503. * @ignore
  78504. */
  78505. interface IGLTFValidator {
  78506. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78507. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78508. }
  78509. }
  78510. declare module BABYLON {
  78511. /** @hidden */
  78512. export var cellPixelShader: {
  78513. name: string;
  78514. shader: string;
  78515. };
  78516. }
  78517. declare module BABYLON {
  78518. /** @hidden */
  78519. export var cellVertexShader: {
  78520. name: string;
  78521. shader: string;
  78522. };
  78523. }
  78524. declare module BABYLON {
  78525. export class CellMaterial extends BABYLON.PushMaterial {
  78526. private _diffuseTexture;
  78527. diffuseTexture: BABYLON.BaseTexture;
  78528. diffuseColor: BABYLON.Color3;
  78529. _computeHighLevel: boolean;
  78530. computeHighLevel: boolean;
  78531. private _disableLighting;
  78532. disableLighting: boolean;
  78533. private _maxSimultaneousLights;
  78534. maxSimultaneousLights: number;
  78535. private _renderId;
  78536. constructor(name: string, scene: BABYLON.Scene);
  78537. needAlphaBlending(): boolean;
  78538. needAlphaTesting(): boolean;
  78539. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78542. getAnimatables(): BABYLON.IAnimatable[];
  78543. getActiveTextures(): BABYLON.BaseTexture[];
  78544. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78545. dispose(forceDisposeEffect?: boolean): void;
  78546. getClassName(): string;
  78547. clone(name: string): CellMaterial;
  78548. serialize(): any;
  78549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78550. }
  78551. }
  78552. declare module BABYLON {
  78553. export class CustomShaderStructure {
  78554. FragmentStore: string;
  78555. VertexStore: string;
  78556. constructor();
  78557. }
  78558. export class ShaderSpecialParts {
  78559. constructor();
  78560. Fragment_Begin: string;
  78561. Fragment_Definitions: string;
  78562. Fragment_MainBegin: string;
  78563. Fragment_Custom_Diffuse: string;
  78564. Fragment_Before_Lights: string;
  78565. Fragment_Before_Fog: string;
  78566. Fragment_Custom_Alpha: string;
  78567. Fragment_Before_FragColor: string;
  78568. Vertex_Begin: string;
  78569. Vertex_Definitions: string;
  78570. Vertex_MainBegin: string;
  78571. Vertex_Before_PositionUpdated: string;
  78572. Vertex_Before_NormalUpdated: string;
  78573. Vertex_MainEnd: string;
  78574. }
  78575. export class CustomMaterial extends BABYLON.StandardMaterial {
  78576. static ShaderIndexer: number;
  78577. CustomParts: ShaderSpecialParts;
  78578. _isCreatedShader: boolean;
  78579. _createdShaderName: string;
  78580. _customUniform: string[];
  78581. _newUniforms: string[];
  78582. _newUniformInstances: any[];
  78583. _newSamplerInstances: BABYLON.Texture[];
  78584. FragmentShader: string;
  78585. VertexShader: string;
  78586. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78587. ReviewUniform(name: string, arr: string[]): string[];
  78588. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78589. constructor(name: string, scene: BABYLON.Scene);
  78590. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78591. Fragment_Begin(shaderPart: string): CustomMaterial;
  78592. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78593. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78594. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78595. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78596. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78597. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78598. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78599. Vertex_Begin(shaderPart: string): CustomMaterial;
  78600. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78601. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78602. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78603. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78604. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78605. }
  78606. }
  78607. declare module BABYLON {
  78608. export class ShaderAlebdoParts {
  78609. constructor();
  78610. Fragment_Begin: string;
  78611. Fragment_Definitions: string;
  78612. Fragment_MainBegin: string;
  78613. Fragment_Custom_Albedo: string;
  78614. Fragment_Before_Lights: string;
  78615. Fragment_Custom_MetallicRoughness: string;
  78616. Fragment_Custom_MicroSurface: string;
  78617. Fragment_Before_Fog: string;
  78618. Fragment_Custom_Alpha: string;
  78619. Fragment_Before_FragColor: string;
  78620. Vertex_Begin: string;
  78621. Vertex_Definitions: string;
  78622. Vertex_MainBegin: string;
  78623. Vertex_Before_PositionUpdated: string;
  78624. Vertex_Before_NormalUpdated: string;
  78625. Vertex_MainEnd: string;
  78626. }
  78627. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78628. static ShaderIndexer: number;
  78629. CustomParts: ShaderAlebdoParts;
  78630. _isCreatedShader: boolean;
  78631. _createdShaderName: string;
  78632. _customUniform: string[];
  78633. _newUniforms: string[];
  78634. _newUniformInstances: any[];
  78635. _newSamplerInstances: BABYLON.Texture[];
  78636. FragmentShader: string;
  78637. VertexShader: string;
  78638. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78639. ReviewUniform(name: string, arr: string[]): string[];
  78640. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78641. constructor(name: string, scene: BABYLON.Scene);
  78642. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78643. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78644. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78645. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78646. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78647. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78648. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78649. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78650. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78651. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78652. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78653. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78654. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78655. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78656. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78657. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78658. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78659. }
  78660. }
  78661. declare module BABYLON {
  78662. /** @hidden */
  78663. export var firePixelShader: {
  78664. name: string;
  78665. shader: string;
  78666. };
  78667. }
  78668. declare module BABYLON {
  78669. /** @hidden */
  78670. export var fireVertexShader: {
  78671. name: string;
  78672. shader: string;
  78673. };
  78674. }
  78675. declare module BABYLON {
  78676. export class FireMaterial extends BABYLON.PushMaterial {
  78677. private _diffuseTexture;
  78678. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78679. private _distortionTexture;
  78680. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78681. private _opacityTexture;
  78682. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78683. diffuseColor: BABYLON.Color3;
  78684. speed: number;
  78685. private _scaledDiffuse;
  78686. private _renderId;
  78687. private _lastTime;
  78688. constructor(name: string, scene: BABYLON.Scene);
  78689. needAlphaBlending(): boolean;
  78690. needAlphaTesting(): boolean;
  78691. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78692. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78693. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78694. getAnimatables(): BABYLON.IAnimatable[];
  78695. getActiveTextures(): BABYLON.BaseTexture[];
  78696. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78697. getClassName(): string;
  78698. dispose(forceDisposeEffect?: boolean): void;
  78699. clone(name: string): FireMaterial;
  78700. serialize(): any;
  78701. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78702. }
  78703. }
  78704. declare module BABYLON {
  78705. /** @hidden */
  78706. export var furPixelShader: {
  78707. name: string;
  78708. shader: string;
  78709. };
  78710. }
  78711. declare module BABYLON {
  78712. /** @hidden */
  78713. export var furVertexShader: {
  78714. name: string;
  78715. shader: string;
  78716. };
  78717. }
  78718. declare module BABYLON {
  78719. export class FurMaterial extends BABYLON.PushMaterial {
  78720. private _diffuseTexture;
  78721. diffuseTexture: BABYLON.BaseTexture;
  78722. private _heightTexture;
  78723. heightTexture: BABYLON.BaseTexture;
  78724. diffuseColor: BABYLON.Color3;
  78725. furLength: number;
  78726. furAngle: number;
  78727. furColor: BABYLON.Color3;
  78728. furOffset: number;
  78729. furSpacing: number;
  78730. furGravity: BABYLON.Vector3;
  78731. furSpeed: number;
  78732. furDensity: number;
  78733. furOcclusion: number;
  78734. furTexture: BABYLON.DynamicTexture;
  78735. private _disableLighting;
  78736. disableLighting: boolean;
  78737. private _maxSimultaneousLights;
  78738. maxSimultaneousLights: number;
  78739. highLevelFur: boolean;
  78740. _meshes: BABYLON.AbstractMesh[];
  78741. private _renderId;
  78742. private _furTime;
  78743. constructor(name: string, scene: BABYLON.Scene);
  78744. get furTime(): number;
  78745. set furTime(furTime: number);
  78746. needAlphaBlending(): boolean;
  78747. needAlphaTesting(): boolean;
  78748. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78749. updateFur(): void;
  78750. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78751. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78752. getAnimatables(): BABYLON.IAnimatable[];
  78753. getActiveTextures(): BABYLON.BaseTexture[];
  78754. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78755. dispose(forceDisposeEffect?: boolean): void;
  78756. clone(name: string): FurMaterial;
  78757. serialize(): any;
  78758. getClassName(): string;
  78759. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78760. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78761. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78762. }
  78763. }
  78764. declare module BABYLON {
  78765. /** @hidden */
  78766. export var gradientPixelShader: {
  78767. name: string;
  78768. shader: string;
  78769. };
  78770. }
  78771. declare module BABYLON {
  78772. /** @hidden */
  78773. export var gradientVertexShader: {
  78774. name: string;
  78775. shader: string;
  78776. };
  78777. }
  78778. declare module BABYLON {
  78779. export class GradientMaterial extends BABYLON.PushMaterial {
  78780. private _maxSimultaneousLights;
  78781. maxSimultaneousLights: number;
  78782. topColor: BABYLON.Color3;
  78783. topColorAlpha: number;
  78784. bottomColor: BABYLON.Color3;
  78785. bottomColorAlpha: number;
  78786. offset: number;
  78787. scale: number;
  78788. smoothness: number;
  78789. private _disableLighting;
  78790. disableLighting: boolean;
  78791. private _renderId;
  78792. constructor(name: string, scene: BABYLON.Scene);
  78793. needAlphaBlending(): boolean;
  78794. needAlphaTesting(): boolean;
  78795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78798. getAnimatables(): BABYLON.IAnimatable[];
  78799. dispose(forceDisposeEffect?: boolean): void;
  78800. clone(name: string): GradientMaterial;
  78801. serialize(): any;
  78802. getClassName(): string;
  78803. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78804. }
  78805. }
  78806. declare module BABYLON {
  78807. /** @hidden */
  78808. export var gridPixelShader: {
  78809. name: string;
  78810. shader: string;
  78811. };
  78812. }
  78813. declare module BABYLON {
  78814. /** @hidden */
  78815. export var gridVertexShader: {
  78816. name: string;
  78817. shader: string;
  78818. };
  78819. }
  78820. declare module BABYLON {
  78821. /**
  78822. * The grid materials allows you to wrap any shape with a grid.
  78823. * Colors are customizable.
  78824. */
  78825. export class GridMaterial extends BABYLON.PushMaterial {
  78826. /**
  78827. * Main color of the grid (e.g. between lines)
  78828. */
  78829. mainColor: BABYLON.Color3;
  78830. /**
  78831. * Color of the grid lines.
  78832. */
  78833. lineColor: BABYLON.Color3;
  78834. /**
  78835. * The scale of the grid compared to unit.
  78836. */
  78837. gridRatio: number;
  78838. /**
  78839. * Allows setting an offset for the grid lines.
  78840. */
  78841. gridOffset: BABYLON.Vector3;
  78842. /**
  78843. * The frequency of thicker lines.
  78844. */
  78845. majorUnitFrequency: number;
  78846. /**
  78847. * The visibility of minor units in the grid.
  78848. */
  78849. minorUnitVisibility: number;
  78850. /**
  78851. * The grid opacity outside of the lines.
  78852. */
  78853. opacity: number;
  78854. /**
  78855. * Determine RBG output is premultiplied by alpha value.
  78856. */
  78857. preMultiplyAlpha: boolean;
  78858. private _opacityTexture;
  78859. opacityTexture: BABYLON.BaseTexture;
  78860. private _gridControl;
  78861. private _renderId;
  78862. /**
  78863. * constructor
  78864. * @param name The name given to the material in order to identify it afterwards.
  78865. * @param scene The scene the material is used in.
  78866. */
  78867. constructor(name: string, scene: BABYLON.Scene);
  78868. /**
  78869. * Returns wehter or not the grid requires alpha blending.
  78870. */
  78871. needAlphaBlending(): boolean;
  78872. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78873. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78874. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78875. /**
  78876. * Dispose the material and its associated resources.
  78877. * @param forceDisposeEffect will also dispose the used effect when true
  78878. */
  78879. dispose(forceDisposeEffect?: boolean): void;
  78880. clone(name: string): GridMaterial;
  78881. serialize(): any;
  78882. getClassName(): string;
  78883. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78884. }
  78885. }
  78886. declare module BABYLON {
  78887. /** @hidden */
  78888. export var lavaPixelShader: {
  78889. name: string;
  78890. shader: string;
  78891. };
  78892. }
  78893. declare module BABYLON {
  78894. /** @hidden */
  78895. export var lavaVertexShader: {
  78896. name: string;
  78897. shader: string;
  78898. };
  78899. }
  78900. declare module BABYLON {
  78901. export class LavaMaterial extends BABYLON.PushMaterial {
  78902. private _diffuseTexture;
  78903. diffuseTexture: BABYLON.BaseTexture;
  78904. noiseTexture: BABYLON.BaseTexture;
  78905. fogColor: BABYLON.Color3;
  78906. speed: number;
  78907. movingSpeed: number;
  78908. lowFrequencySpeed: number;
  78909. fogDensity: number;
  78910. private _lastTime;
  78911. diffuseColor: BABYLON.Color3;
  78912. private _disableLighting;
  78913. disableLighting: boolean;
  78914. private _unlit;
  78915. unlit: boolean;
  78916. private _maxSimultaneousLights;
  78917. maxSimultaneousLights: number;
  78918. private _scaledDiffuse;
  78919. private _renderId;
  78920. constructor(name: string, scene: BABYLON.Scene);
  78921. needAlphaBlending(): boolean;
  78922. needAlphaTesting(): boolean;
  78923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78924. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78925. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78926. getAnimatables(): BABYLON.IAnimatable[];
  78927. getActiveTextures(): BABYLON.BaseTexture[];
  78928. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78929. dispose(forceDisposeEffect?: boolean): void;
  78930. clone(name: string): LavaMaterial;
  78931. serialize(): any;
  78932. getClassName(): string;
  78933. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78934. }
  78935. }
  78936. declare module BABYLON {
  78937. /** @hidden */
  78938. export var mixPixelShader: {
  78939. name: string;
  78940. shader: string;
  78941. };
  78942. }
  78943. declare module BABYLON {
  78944. /** @hidden */
  78945. export var mixVertexShader: {
  78946. name: string;
  78947. shader: string;
  78948. };
  78949. }
  78950. declare module BABYLON {
  78951. export class MixMaterial extends BABYLON.PushMaterial {
  78952. /**
  78953. * Mix textures
  78954. */
  78955. private _mixTexture1;
  78956. mixTexture1: BABYLON.BaseTexture;
  78957. private _mixTexture2;
  78958. mixTexture2: BABYLON.BaseTexture;
  78959. /**
  78960. * Diffuse textures
  78961. */
  78962. private _diffuseTexture1;
  78963. diffuseTexture1: BABYLON.Texture;
  78964. private _diffuseTexture2;
  78965. diffuseTexture2: BABYLON.Texture;
  78966. private _diffuseTexture3;
  78967. diffuseTexture3: BABYLON.Texture;
  78968. private _diffuseTexture4;
  78969. diffuseTexture4: BABYLON.Texture;
  78970. private _diffuseTexture5;
  78971. diffuseTexture5: BABYLON.Texture;
  78972. private _diffuseTexture6;
  78973. diffuseTexture6: BABYLON.Texture;
  78974. private _diffuseTexture7;
  78975. diffuseTexture7: BABYLON.Texture;
  78976. private _diffuseTexture8;
  78977. diffuseTexture8: BABYLON.Texture;
  78978. /**
  78979. * Uniforms
  78980. */
  78981. diffuseColor: BABYLON.Color3;
  78982. specularColor: BABYLON.Color3;
  78983. specularPower: number;
  78984. private _disableLighting;
  78985. disableLighting: boolean;
  78986. private _maxSimultaneousLights;
  78987. maxSimultaneousLights: number;
  78988. private _renderId;
  78989. constructor(name: string, scene: BABYLON.Scene);
  78990. needAlphaBlending(): boolean;
  78991. needAlphaTesting(): boolean;
  78992. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78993. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78994. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78995. getAnimatables(): BABYLON.IAnimatable[];
  78996. getActiveTextures(): BABYLON.BaseTexture[];
  78997. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78998. dispose(forceDisposeEffect?: boolean): void;
  78999. clone(name: string): MixMaterial;
  79000. serialize(): any;
  79001. getClassName(): string;
  79002. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79003. }
  79004. }
  79005. declare module BABYLON {
  79006. /** @hidden */
  79007. export var normalPixelShader: {
  79008. name: string;
  79009. shader: string;
  79010. };
  79011. }
  79012. declare module BABYLON {
  79013. /** @hidden */
  79014. export var normalVertexShader: {
  79015. name: string;
  79016. shader: string;
  79017. };
  79018. }
  79019. declare module BABYLON {
  79020. export class NormalMaterial extends BABYLON.PushMaterial {
  79021. private _diffuseTexture;
  79022. diffuseTexture: BABYLON.BaseTexture;
  79023. diffuseColor: BABYLON.Color3;
  79024. private _disableLighting;
  79025. disableLighting: boolean;
  79026. private _maxSimultaneousLights;
  79027. maxSimultaneousLights: number;
  79028. private _renderId;
  79029. constructor(name: string, scene: BABYLON.Scene);
  79030. needAlphaBlending(): boolean;
  79031. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79032. needAlphaTesting(): boolean;
  79033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79036. getAnimatables(): BABYLON.IAnimatable[];
  79037. getActiveTextures(): BABYLON.BaseTexture[];
  79038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79039. dispose(forceDisposeEffect?: boolean): void;
  79040. clone(name: string): NormalMaterial;
  79041. serialize(): any;
  79042. getClassName(): string;
  79043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79044. }
  79045. }
  79046. declare module BABYLON {
  79047. /** @hidden */
  79048. export var shadowOnlyPixelShader: {
  79049. name: string;
  79050. shader: string;
  79051. };
  79052. }
  79053. declare module BABYLON {
  79054. /** @hidden */
  79055. export var shadowOnlyVertexShader: {
  79056. name: string;
  79057. shader: string;
  79058. };
  79059. }
  79060. declare module BABYLON {
  79061. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79062. private _renderId;
  79063. private _activeLight;
  79064. constructor(name: string, scene: BABYLON.Scene);
  79065. shadowColor: BABYLON.Color3;
  79066. needAlphaBlending(): boolean;
  79067. needAlphaTesting(): boolean;
  79068. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79069. get activeLight(): BABYLON.IShadowLight;
  79070. set activeLight(light: BABYLON.IShadowLight);
  79071. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79072. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79073. clone(name: string): ShadowOnlyMaterial;
  79074. serialize(): any;
  79075. getClassName(): string;
  79076. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79077. }
  79078. }
  79079. declare module BABYLON {
  79080. /** @hidden */
  79081. export var simplePixelShader: {
  79082. name: string;
  79083. shader: string;
  79084. };
  79085. }
  79086. declare module BABYLON {
  79087. /** @hidden */
  79088. export var simpleVertexShader: {
  79089. name: string;
  79090. shader: string;
  79091. };
  79092. }
  79093. declare module BABYLON {
  79094. export class SimpleMaterial extends BABYLON.PushMaterial {
  79095. private _diffuseTexture;
  79096. diffuseTexture: BABYLON.BaseTexture;
  79097. diffuseColor: BABYLON.Color3;
  79098. private _disableLighting;
  79099. disableLighting: boolean;
  79100. private _maxSimultaneousLights;
  79101. maxSimultaneousLights: number;
  79102. private _renderId;
  79103. constructor(name: string, scene: BABYLON.Scene);
  79104. needAlphaBlending(): boolean;
  79105. needAlphaTesting(): boolean;
  79106. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79107. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79108. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79109. getAnimatables(): BABYLON.IAnimatable[];
  79110. getActiveTextures(): BABYLON.BaseTexture[];
  79111. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79112. dispose(forceDisposeEffect?: boolean): void;
  79113. clone(name: string): SimpleMaterial;
  79114. serialize(): any;
  79115. getClassName(): string;
  79116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79117. }
  79118. }
  79119. declare module BABYLON {
  79120. /** @hidden */
  79121. export var skyPixelShader: {
  79122. name: string;
  79123. shader: string;
  79124. };
  79125. }
  79126. declare module BABYLON {
  79127. /** @hidden */
  79128. export var skyVertexShader: {
  79129. name: string;
  79130. shader: string;
  79131. };
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79136. * @see https://doc.babylonjs.com/extensions/sky
  79137. */
  79138. export class SkyMaterial extends BABYLON.PushMaterial {
  79139. /**
  79140. * Defines the overall luminance of sky in interval ]0, 1[.
  79141. */
  79142. luminance: number;
  79143. /**
  79144. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79145. */
  79146. turbidity: number;
  79147. /**
  79148. * Defines the sky appearance (light intensity).
  79149. */
  79150. rayleigh: number;
  79151. /**
  79152. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79153. */
  79154. mieCoefficient: number;
  79155. /**
  79156. * Defines the amount of haze particles following the Mie scattering theory.
  79157. */
  79158. mieDirectionalG: number;
  79159. /**
  79160. * Defines the distance of the sun according to the active scene camera.
  79161. */
  79162. distance: number;
  79163. /**
  79164. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79165. * "inclined".
  79166. */
  79167. inclination: number;
  79168. /**
  79169. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79170. * an object direction and a reference direction.
  79171. */
  79172. azimuth: number;
  79173. /**
  79174. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79175. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79176. */
  79177. sunPosition: BABYLON.Vector3;
  79178. /**
  79179. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79180. * .sunPosition property.
  79181. */
  79182. useSunPosition: boolean;
  79183. /**
  79184. * Defines an offset vector used to get a horizon offset.
  79185. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79186. */
  79187. cameraOffset: BABYLON.Vector3;
  79188. private _cameraPosition;
  79189. private _renderId;
  79190. /**
  79191. * Instantiates a new sky material.
  79192. * This material allows to create dynamic and texture free
  79193. * effects for skyboxes by taking care of the atmosphere state.
  79194. * @see https://doc.babylonjs.com/extensions/sky
  79195. * @param name Define the name of the material in the scene
  79196. * @param scene Define the scene the material belong to
  79197. */
  79198. constructor(name: string, scene: BABYLON.Scene);
  79199. /**
  79200. * Specifies if the material will require alpha blending
  79201. * @returns a boolean specifying if alpha blending is needed
  79202. */
  79203. needAlphaBlending(): boolean;
  79204. /**
  79205. * Specifies if this material should be rendered in alpha test mode
  79206. * @returns false as the sky material doesn't need alpha testing.
  79207. */
  79208. needAlphaTesting(): boolean;
  79209. /**
  79210. * Get the texture used for alpha test purpose.
  79211. * @returns null as the sky material has no texture.
  79212. */
  79213. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79214. /**
  79215. * Get if the submesh is ready to be used and all its information available.
  79216. * Child classes can use it to update shaders
  79217. * @param mesh defines the mesh to check
  79218. * @param subMesh defines which submesh to check
  79219. * @param useInstances specifies that instances should be used
  79220. * @returns a boolean indicating that the submesh is ready or not
  79221. */
  79222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79223. /**
  79224. * Binds the submesh to this material by preparing the effect and shader to draw
  79225. * @param world defines the world transformation matrix
  79226. * @param mesh defines the mesh containing the submesh
  79227. * @param subMesh defines the submesh to bind the material to
  79228. */
  79229. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79230. /**
  79231. * Get the list of animatables in the material.
  79232. * @returns the list of animatables object used in the material
  79233. */
  79234. getAnimatables(): BABYLON.IAnimatable[];
  79235. /**
  79236. * Disposes the material
  79237. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79238. */
  79239. dispose(forceDisposeEffect?: boolean): void;
  79240. /**
  79241. * Makes a duplicate of the material, and gives it a new name
  79242. * @param name defines the new name for the duplicated material
  79243. * @returns the cloned material
  79244. */
  79245. clone(name: string): SkyMaterial;
  79246. /**
  79247. * Serializes this material in a JSON representation
  79248. * @returns the serialized material object
  79249. */
  79250. serialize(): any;
  79251. /**
  79252. * Gets the current class name of the material e.g. "SkyMaterial"
  79253. * Mainly use in serialization.
  79254. * @returns the class name
  79255. */
  79256. getClassName(): string;
  79257. /**
  79258. * Creates a sky material from parsed material data
  79259. * @param source defines the JSON representation of the material
  79260. * @param scene defines the hosting scene
  79261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79262. * @returns a new sky material
  79263. */
  79264. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79265. }
  79266. }
  79267. declare module BABYLON {
  79268. /** @hidden */
  79269. export var terrainPixelShader: {
  79270. name: string;
  79271. shader: string;
  79272. };
  79273. }
  79274. declare module BABYLON {
  79275. /** @hidden */
  79276. export var terrainVertexShader: {
  79277. name: string;
  79278. shader: string;
  79279. };
  79280. }
  79281. declare module BABYLON {
  79282. export class TerrainMaterial extends BABYLON.PushMaterial {
  79283. private _mixTexture;
  79284. mixTexture: BABYLON.BaseTexture;
  79285. private _diffuseTexture1;
  79286. diffuseTexture1: BABYLON.Texture;
  79287. private _diffuseTexture2;
  79288. diffuseTexture2: BABYLON.Texture;
  79289. private _diffuseTexture3;
  79290. diffuseTexture3: BABYLON.Texture;
  79291. private _bumpTexture1;
  79292. bumpTexture1: BABYLON.Texture;
  79293. private _bumpTexture2;
  79294. bumpTexture2: BABYLON.Texture;
  79295. private _bumpTexture3;
  79296. bumpTexture3: BABYLON.Texture;
  79297. diffuseColor: BABYLON.Color3;
  79298. specularColor: BABYLON.Color3;
  79299. specularPower: number;
  79300. private _disableLighting;
  79301. disableLighting: boolean;
  79302. private _maxSimultaneousLights;
  79303. maxSimultaneousLights: number;
  79304. private _renderId;
  79305. constructor(name: string, scene: BABYLON.Scene);
  79306. needAlphaBlending(): boolean;
  79307. needAlphaTesting(): boolean;
  79308. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79310. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79311. getAnimatables(): BABYLON.IAnimatable[];
  79312. getActiveTextures(): BABYLON.BaseTexture[];
  79313. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79314. dispose(forceDisposeEffect?: boolean): void;
  79315. clone(name: string): TerrainMaterial;
  79316. serialize(): any;
  79317. getClassName(): string;
  79318. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /** @hidden */
  79323. export var triplanarPixelShader: {
  79324. name: string;
  79325. shader: string;
  79326. };
  79327. }
  79328. declare module BABYLON {
  79329. /** @hidden */
  79330. export var triplanarVertexShader: {
  79331. name: string;
  79332. shader: string;
  79333. };
  79334. }
  79335. declare module BABYLON {
  79336. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79337. mixTexture: BABYLON.BaseTexture;
  79338. private _diffuseTextureX;
  79339. diffuseTextureX: BABYLON.BaseTexture;
  79340. private _diffuseTextureY;
  79341. diffuseTextureY: BABYLON.BaseTexture;
  79342. private _diffuseTextureZ;
  79343. diffuseTextureZ: BABYLON.BaseTexture;
  79344. private _normalTextureX;
  79345. normalTextureX: BABYLON.BaseTexture;
  79346. private _normalTextureY;
  79347. normalTextureY: BABYLON.BaseTexture;
  79348. private _normalTextureZ;
  79349. normalTextureZ: BABYLON.BaseTexture;
  79350. tileSize: number;
  79351. diffuseColor: BABYLON.Color3;
  79352. specularColor: BABYLON.Color3;
  79353. specularPower: number;
  79354. private _disableLighting;
  79355. disableLighting: boolean;
  79356. private _maxSimultaneousLights;
  79357. maxSimultaneousLights: number;
  79358. private _renderId;
  79359. constructor(name: string, scene: BABYLON.Scene);
  79360. needAlphaBlending(): boolean;
  79361. needAlphaTesting(): boolean;
  79362. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79365. getAnimatables(): BABYLON.IAnimatable[];
  79366. getActiveTextures(): BABYLON.BaseTexture[];
  79367. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79368. dispose(forceDisposeEffect?: boolean): void;
  79369. clone(name: string): TriPlanarMaterial;
  79370. serialize(): any;
  79371. getClassName(): string;
  79372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79373. }
  79374. }
  79375. declare module BABYLON {
  79376. /** @hidden */
  79377. export var waterPixelShader: {
  79378. name: string;
  79379. shader: string;
  79380. };
  79381. }
  79382. declare module BABYLON {
  79383. /** @hidden */
  79384. export var waterVertexShader: {
  79385. name: string;
  79386. shader: string;
  79387. };
  79388. }
  79389. declare module BABYLON {
  79390. export class WaterMaterial extends BABYLON.PushMaterial {
  79391. renderTargetSize: BABYLON.Vector2;
  79392. private _bumpTexture;
  79393. bumpTexture: BABYLON.BaseTexture;
  79394. diffuseColor: BABYLON.Color3;
  79395. specularColor: BABYLON.Color3;
  79396. specularPower: number;
  79397. private _disableLighting;
  79398. disableLighting: boolean;
  79399. private _maxSimultaneousLights;
  79400. maxSimultaneousLights: number;
  79401. /**
  79402. * @param {number}: Represents the wind force
  79403. */
  79404. windForce: number;
  79405. /**
  79406. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79407. */
  79408. windDirection: BABYLON.Vector2;
  79409. /**
  79410. * @param {number}: Wave height, represents the height of the waves
  79411. */
  79412. waveHeight: number;
  79413. /**
  79414. * @param {number}: Bump height, represents the bump height related to the bump map
  79415. */
  79416. bumpHeight: number;
  79417. /**
  79418. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79419. */
  79420. private _bumpSuperimpose;
  79421. bumpSuperimpose: boolean;
  79422. /**
  79423. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79424. */
  79425. private _fresnelSeparate;
  79426. fresnelSeparate: boolean;
  79427. /**
  79428. * @param {boolean}: bump Waves modify the reflection.
  79429. */
  79430. private _bumpAffectsReflection;
  79431. bumpAffectsReflection: boolean;
  79432. /**
  79433. * @param {number}: The water color blended with the refraction (near)
  79434. */
  79435. waterColor: BABYLON.Color3;
  79436. /**
  79437. * @param {number}: The blend factor related to the water color
  79438. */
  79439. colorBlendFactor: number;
  79440. /**
  79441. * @param {number}: The water color blended with the reflection (far)
  79442. */
  79443. waterColor2: BABYLON.Color3;
  79444. /**
  79445. * @param {number}: The blend factor related to the water color (reflection, far)
  79446. */
  79447. colorBlendFactor2: number;
  79448. /**
  79449. * @param {number}: Represents the maximum length of a wave
  79450. */
  79451. waveLength: number;
  79452. /**
  79453. * @param {number}: Defines the waves speed
  79454. */
  79455. waveSpeed: number;
  79456. /**
  79457. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79458. * will avoid calculating useless pixels in the pixel shader of the water material.
  79459. */
  79460. disableClipPlane: boolean;
  79461. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79462. private _mesh;
  79463. private _refractionRTT;
  79464. private _reflectionRTT;
  79465. private _reflectionTransform;
  79466. private _lastTime;
  79467. private _lastDeltaTime;
  79468. private _renderId;
  79469. private _useLogarithmicDepth;
  79470. private _waitingRenderList;
  79471. private _imageProcessingConfiguration;
  79472. private _imageProcessingObserver;
  79473. /**
  79474. * Gets a boolean indicating that current material needs to register RTT
  79475. */
  79476. get hasRenderTargetTextures(): boolean;
  79477. /**
  79478. * Constructor
  79479. */
  79480. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79481. get useLogarithmicDepth(): boolean;
  79482. set useLogarithmicDepth(value: boolean);
  79483. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79484. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79485. addToRenderList(node: any): void;
  79486. enableRenderTargets(enable: boolean): void;
  79487. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79488. get renderTargetsEnabled(): boolean;
  79489. needAlphaBlending(): boolean;
  79490. needAlphaTesting(): boolean;
  79491. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79492. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79493. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79494. private _createRenderTargets;
  79495. getAnimatables(): BABYLON.IAnimatable[];
  79496. getActiveTextures(): BABYLON.BaseTexture[];
  79497. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79498. dispose(forceDisposeEffect?: boolean): void;
  79499. clone(name: string): WaterMaterial;
  79500. serialize(): any;
  79501. getClassName(): string;
  79502. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79503. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /** @hidden */
  79508. export var asciiartPixelShader: {
  79509. name: string;
  79510. shader: string;
  79511. };
  79512. }
  79513. declare module BABYLON {
  79514. /**
  79515. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79516. *
  79517. * It basically takes care rendering the font front the given font size to a texture.
  79518. * This is used later on in the postprocess.
  79519. */
  79520. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79521. private _font;
  79522. private _text;
  79523. private _charSize;
  79524. /**
  79525. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79526. */
  79527. get charSize(): number;
  79528. /**
  79529. * Create a new instance of the Ascii Art FontTexture class
  79530. * @param name the name of the texture
  79531. * @param font the font to use, use the W3C CSS notation
  79532. * @param text the caracter set to use in the rendering.
  79533. * @param scene the scene that owns the texture
  79534. */
  79535. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79536. /**
  79537. * Gets the max char width of a font.
  79538. * @param font the font to use, use the W3C CSS notation
  79539. * @return the max char width
  79540. */
  79541. private getFontWidth;
  79542. /**
  79543. * Gets the max char height of a font.
  79544. * @param font the font to use, use the W3C CSS notation
  79545. * @return the max char height
  79546. */
  79547. private getFontHeight;
  79548. /**
  79549. * Clones the current AsciiArtTexture.
  79550. * @return the clone of the texture.
  79551. */
  79552. clone(): AsciiArtFontTexture;
  79553. /**
  79554. * Parses a json object representing the texture and returns an instance of it.
  79555. * @param source the source JSON representation
  79556. * @param scene the scene to create the texture for
  79557. * @return the parsed texture
  79558. */
  79559. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79560. }
  79561. /**
  79562. * Option available in the Ascii Art Post Process.
  79563. */
  79564. export interface IAsciiArtPostProcessOptions {
  79565. /**
  79566. * The font to use following the w3c font definition.
  79567. */
  79568. font?: string;
  79569. /**
  79570. * The character set to use in the postprocess.
  79571. */
  79572. characterSet?: string;
  79573. /**
  79574. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79575. * This number is defined between 0 and 1;
  79576. */
  79577. mixToTile?: number;
  79578. /**
  79579. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79580. * This number is defined between 0 and 1;
  79581. */
  79582. mixToNormal?: number;
  79583. }
  79584. /**
  79585. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79586. *
  79587. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79588. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79589. */
  79590. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79591. /**
  79592. * The font texture used to render the char in the post process.
  79593. */
  79594. private _asciiArtFontTexture;
  79595. /**
  79596. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79597. * This number is defined between 0 and 1;
  79598. */
  79599. mixToTile: number;
  79600. /**
  79601. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79602. * This number is defined between 0 and 1;
  79603. */
  79604. mixToNormal: number;
  79605. /**
  79606. * Instantiates a new Ascii Art Post Process.
  79607. * @param name the name to give to the postprocess
  79608. * @camera the camera to apply the post process to.
  79609. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79610. */
  79611. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79612. }
  79613. }
  79614. declare module BABYLON {
  79615. /** @hidden */
  79616. export var digitalrainPixelShader: {
  79617. name: string;
  79618. shader: string;
  79619. };
  79620. }
  79621. declare module BABYLON {
  79622. /**
  79623. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79624. *
  79625. * It basically takes care rendering the font front the given font size to a texture.
  79626. * This is used later on in the postprocess.
  79627. */
  79628. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79629. private _font;
  79630. private _text;
  79631. private _charSize;
  79632. /**
  79633. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79634. */
  79635. get charSize(): number;
  79636. /**
  79637. * Create a new instance of the Digital Rain FontTexture class
  79638. * @param name the name of the texture
  79639. * @param font the font to use, use the W3C CSS notation
  79640. * @param text the caracter set to use in the rendering.
  79641. * @param scene the scene that owns the texture
  79642. */
  79643. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79644. /**
  79645. * Gets the max char width of a font.
  79646. * @param font the font to use, use the W3C CSS notation
  79647. * @return the max char width
  79648. */
  79649. private getFontWidth;
  79650. /**
  79651. * Gets the max char height of a font.
  79652. * @param font the font to use, use the W3C CSS notation
  79653. * @return the max char height
  79654. */
  79655. private getFontHeight;
  79656. /**
  79657. * Clones the current DigitalRainFontTexture.
  79658. * @return the clone of the texture.
  79659. */
  79660. clone(): DigitalRainFontTexture;
  79661. /**
  79662. * Parses a json object representing the texture and returns an instance of it.
  79663. * @param source the source JSON representation
  79664. * @param scene the scene to create the texture for
  79665. * @return the parsed texture
  79666. */
  79667. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79668. }
  79669. /**
  79670. * Option available in the Digital Rain Post Process.
  79671. */
  79672. export interface IDigitalRainPostProcessOptions {
  79673. /**
  79674. * The font to use following the w3c font definition.
  79675. */
  79676. font?: string;
  79677. /**
  79678. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79679. * This number is defined between 0 and 1;
  79680. */
  79681. mixToTile?: number;
  79682. /**
  79683. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79684. * This number is defined between 0 and 1;
  79685. */
  79686. mixToNormal?: number;
  79687. }
  79688. /**
  79689. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79690. *
  79691. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79692. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79693. */
  79694. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79695. /**
  79696. * The font texture used to render the char in the post process.
  79697. */
  79698. private _digitalRainFontTexture;
  79699. /**
  79700. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79701. * This number is defined between 0 and 1;
  79702. */
  79703. mixToTile: number;
  79704. /**
  79705. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79706. * This number is defined between 0 and 1;
  79707. */
  79708. mixToNormal: number;
  79709. /**
  79710. * Instantiates a new Digital Rain Post Process.
  79711. * @param name the name to give to the postprocess
  79712. * @camera the camera to apply the post process to.
  79713. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79714. */
  79715. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79716. }
  79717. }
  79718. declare module BABYLON {
  79719. /** @hidden */
  79720. export var brickProceduralTexturePixelShader: {
  79721. name: string;
  79722. shader: string;
  79723. };
  79724. }
  79725. declare module BABYLON {
  79726. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79727. private _numberOfBricksHeight;
  79728. private _numberOfBricksWidth;
  79729. private _jointColor;
  79730. private _brickColor;
  79731. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79732. updateShaderUniforms(): void;
  79733. get numberOfBricksHeight(): number;
  79734. set numberOfBricksHeight(value: number);
  79735. get numberOfBricksWidth(): number;
  79736. set numberOfBricksWidth(value: number);
  79737. get jointColor(): BABYLON.Color3;
  79738. set jointColor(value: BABYLON.Color3);
  79739. get brickColor(): BABYLON.Color3;
  79740. set brickColor(value: BABYLON.Color3);
  79741. /**
  79742. * Serializes this brick procedural texture
  79743. * @returns a serialized brick procedural texture object
  79744. */
  79745. serialize(): any;
  79746. /**
  79747. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79748. * @param parsedTexture defines parsed texture data
  79749. * @param scene defines the current scene
  79750. * @param rootUrl defines the root URL containing brick procedural texture information
  79751. * @returns a parsed Brick Procedural BABYLON.Texture
  79752. */
  79753. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79754. }
  79755. }
  79756. declare module BABYLON {
  79757. /** @hidden */
  79758. export var cloudProceduralTexturePixelShader: {
  79759. name: string;
  79760. shader: string;
  79761. };
  79762. }
  79763. declare module BABYLON {
  79764. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79765. private _skyColor;
  79766. private _cloudColor;
  79767. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79768. updateShaderUniforms(): void;
  79769. get skyColor(): BABYLON.Color4;
  79770. set skyColor(value: BABYLON.Color4);
  79771. get cloudColor(): BABYLON.Color4;
  79772. set cloudColor(value: BABYLON.Color4);
  79773. /**
  79774. * Serializes this cloud procedural texture
  79775. * @returns a serialized cloud procedural texture object
  79776. */
  79777. serialize(): any;
  79778. /**
  79779. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79780. * @param parsedTexture defines parsed texture data
  79781. * @param scene defines the current scene
  79782. * @param rootUrl defines the root URL containing cloud procedural texture information
  79783. * @returns a parsed Cloud Procedural BABYLON.Texture
  79784. */
  79785. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79786. }
  79787. }
  79788. declare module BABYLON {
  79789. /** @hidden */
  79790. export var fireProceduralTexturePixelShader: {
  79791. name: string;
  79792. shader: string;
  79793. };
  79794. }
  79795. declare module BABYLON {
  79796. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79797. private _time;
  79798. private _speed;
  79799. private _autoGenerateTime;
  79800. private _fireColors;
  79801. private _alphaThreshold;
  79802. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79803. updateShaderUniforms(): void;
  79804. render(useCameraPostProcess?: boolean): void;
  79805. static get PurpleFireColors(): BABYLON.Color3[];
  79806. static get GreenFireColors(): BABYLON.Color3[];
  79807. static get RedFireColors(): BABYLON.Color3[];
  79808. static get BlueFireColors(): BABYLON.Color3[];
  79809. get autoGenerateTime(): boolean;
  79810. set autoGenerateTime(value: boolean);
  79811. get fireColors(): BABYLON.Color3[];
  79812. set fireColors(value: BABYLON.Color3[]);
  79813. get time(): number;
  79814. set time(value: number);
  79815. get speed(): BABYLON.Vector2;
  79816. set speed(value: BABYLON.Vector2);
  79817. get alphaThreshold(): number;
  79818. set alphaThreshold(value: number);
  79819. /**
  79820. * Serializes this fire procedural texture
  79821. * @returns a serialized fire procedural texture object
  79822. */
  79823. serialize(): any;
  79824. /**
  79825. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79826. * @param parsedTexture defines parsed texture data
  79827. * @param scene defines the current scene
  79828. * @param rootUrl defines the root URL containing fire procedural texture information
  79829. * @returns a parsed Fire Procedural BABYLON.Texture
  79830. */
  79831. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79832. }
  79833. }
  79834. declare module BABYLON {
  79835. /** @hidden */
  79836. export var grassProceduralTexturePixelShader: {
  79837. name: string;
  79838. shader: string;
  79839. };
  79840. }
  79841. declare module BABYLON {
  79842. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79843. private _grassColors;
  79844. private _groundColor;
  79845. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79846. updateShaderUniforms(): void;
  79847. get grassColors(): BABYLON.Color3[];
  79848. set grassColors(value: BABYLON.Color3[]);
  79849. get groundColor(): BABYLON.Color3;
  79850. set groundColor(value: BABYLON.Color3);
  79851. /**
  79852. * Serializes this grass procedural texture
  79853. * @returns a serialized grass procedural texture object
  79854. */
  79855. serialize(): any;
  79856. /**
  79857. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79858. * @param parsedTexture defines parsed texture data
  79859. * @param scene defines the current scene
  79860. * @param rootUrl defines the root URL containing grass procedural texture information
  79861. * @returns a parsed Grass Procedural BABYLON.Texture
  79862. */
  79863. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79864. }
  79865. }
  79866. declare module BABYLON {
  79867. /** @hidden */
  79868. export var marbleProceduralTexturePixelShader: {
  79869. name: string;
  79870. shader: string;
  79871. };
  79872. }
  79873. declare module BABYLON {
  79874. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79875. private _numberOfTilesHeight;
  79876. private _numberOfTilesWidth;
  79877. private _amplitude;
  79878. private _jointColor;
  79879. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79880. updateShaderUniforms(): void;
  79881. get numberOfTilesHeight(): number;
  79882. set numberOfTilesHeight(value: number);
  79883. get amplitude(): number;
  79884. set amplitude(value: number);
  79885. get numberOfTilesWidth(): number;
  79886. set numberOfTilesWidth(value: number);
  79887. get jointColor(): BABYLON.Color3;
  79888. set jointColor(value: BABYLON.Color3);
  79889. /**
  79890. * Serializes this marble procedural texture
  79891. * @returns a serialized marble procedural texture object
  79892. */
  79893. serialize(): any;
  79894. /**
  79895. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79896. * @param parsedTexture defines parsed texture data
  79897. * @param scene defines the current scene
  79898. * @param rootUrl defines the root URL containing marble procedural texture information
  79899. * @returns a parsed Marble Procedural BABYLON.Texture
  79900. */
  79901. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79902. }
  79903. }
  79904. declare module BABYLON {
  79905. /** @hidden */
  79906. export var normalMapProceduralTexturePixelShader: {
  79907. name: string;
  79908. shader: string;
  79909. };
  79910. }
  79911. declare module BABYLON {
  79912. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79913. private _baseTexture;
  79914. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79915. updateShaderUniforms(): void;
  79916. render(useCameraPostProcess?: boolean): void;
  79917. resize(size: any, generateMipMaps: any): void;
  79918. get baseTexture(): BABYLON.Texture;
  79919. set baseTexture(texture: BABYLON.Texture);
  79920. /**
  79921. * Serializes this normal map procedural texture
  79922. * @returns a serialized normal map procedural texture object
  79923. */
  79924. serialize(): any;
  79925. /**
  79926. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79927. * @param parsedTexture defines parsed texture data
  79928. * @param scene defines the current scene
  79929. * @param rootUrl defines the root URL containing normal map procedural texture information
  79930. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79931. */
  79932. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /** @hidden */
  79937. export var perlinNoiseProceduralTexturePixelShader: {
  79938. name: string;
  79939. shader: string;
  79940. };
  79941. }
  79942. declare module BABYLON {
  79943. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79944. time: number;
  79945. timeScale: number;
  79946. translationSpeed: number;
  79947. private _currentTranslation;
  79948. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79949. updateShaderUniforms(): void;
  79950. render(useCameraPostProcess?: boolean): void;
  79951. resize(size: any, generateMipMaps: any): void;
  79952. /**
  79953. * Serializes this perlin noise procedural texture
  79954. * @returns a serialized perlin noise procedural texture object
  79955. */
  79956. serialize(): any;
  79957. /**
  79958. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79959. * @param parsedTexture defines parsed texture data
  79960. * @param scene defines the current scene
  79961. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79962. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79963. */
  79964. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79965. }
  79966. }
  79967. declare module BABYLON {
  79968. /** @hidden */
  79969. export var roadProceduralTexturePixelShader: {
  79970. name: string;
  79971. shader: string;
  79972. };
  79973. }
  79974. declare module BABYLON {
  79975. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79976. private _roadColor;
  79977. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79978. updateShaderUniforms(): void;
  79979. get roadColor(): BABYLON.Color3;
  79980. set roadColor(value: BABYLON.Color3);
  79981. /**
  79982. * Serializes this road procedural texture
  79983. * @returns a serialized road procedural texture object
  79984. */
  79985. serialize(): any;
  79986. /**
  79987. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79988. * @param parsedTexture defines parsed texture data
  79989. * @param scene defines the current scene
  79990. * @param rootUrl defines the root URL containing road procedural texture information
  79991. * @returns a parsed Road Procedural BABYLON.Texture
  79992. */
  79993. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79994. }
  79995. }
  79996. declare module BABYLON {
  79997. /** @hidden */
  79998. export var starfieldProceduralTexturePixelShader: {
  79999. name: string;
  80000. shader: string;
  80001. };
  80002. }
  80003. declare module BABYLON {
  80004. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80005. private _time;
  80006. private _alpha;
  80007. private _beta;
  80008. private _zoom;
  80009. private _formuparam;
  80010. private _stepsize;
  80011. private _tile;
  80012. private _brightness;
  80013. private _darkmatter;
  80014. private _distfading;
  80015. private _saturation;
  80016. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80017. updateShaderUniforms(): void;
  80018. get time(): number;
  80019. set time(value: number);
  80020. get alpha(): number;
  80021. set alpha(value: number);
  80022. get beta(): number;
  80023. set beta(value: number);
  80024. get formuparam(): number;
  80025. set formuparam(value: number);
  80026. get stepsize(): number;
  80027. set stepsize(value: number);
  80028. get zoom(): number;
  80029. set zoom(value: number);
  80030. get tile(): number;
  80031. set tile(value: number);
  80032. get brightness(): number;
  80033. set brightness(value: number);
  80034. get darkmatter(): number;
  80035. set darkmatter(value: number);
  80036. get distfading(): number;
  80037. set distfading(value: number);
  80038. get saturation(): number;
  80039. set saturation(value: number);
  80040. /**
  80041. * Serializes this starfield procedural texture
  80042. * @returns a serialized starfield procedural texture object
  80043. */
  80044. serialize(): any;
  80045. /**
  80046. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80047. * @param parsedTexture defines parsed texture data
  80048. * @param scene defines the current scene
  80049. * @param rootUrl defines the root URL containing startfield procedural texture information
  80050. * @returns a parsed Starfield Procedural BABYLON.Texture
  80051. */
  80052. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80053. }
  80054. }
  80055. declare module BABYLON {
  80056. /** @hidden */
  80057. export var woodProceduralTexturePixelShader: {
  80058. name: string;
  80059. shader: string;
  80060. };
  80061. }
  80062. declare module BABYLON {
  80063. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80064. private _ampScale;
  80065. private _woodColor;
  80066. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80067. updateShaderUniforms(): void;
  80068. get ampScale(): number;
  80069. set ampScale(value: number);
  80070. get woodColor(): BABYLON.Color3;
  80071. set woodColor(value: BABYLON.Color3);
  80072. /**
  80073. * Serializes this wood procedural texture
  80074. * @returns a serialized wood procedural texture object
  80075. */
  80076. serialize(): any;
  80077. /**
  80078. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80079. * @param parsedTexture defines parsed texture data
  80080. * @param scene defines the current scene
  80081. * @param rootUrl defines the root URL containing wood procedural texture information
  80082. * @returns a parsed Wood Procedural BABYLON.Texture
  80083. */
  80084. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80085. }
  80086. }